存档

‘Other’ 分类的存档

安装配置一台 apache+php+mysql 的rh el4服务器

2007年9月16日 wd 没有评论

系统

rh el4 是四张盘,用第一张启动电脑。前面没啥好说的了,后面选择软件的时候,不要选x界面的东西,开发工具全选上,别的好像默认就行了,大概需要2G好像是。

Apache

apache的下载地址:http://httpd.apache.org/download.cgi,选一个mirror,下载就行了。

编译选项: ./configure –prefix=/usr/local/apache/ –enable-rewrite –enable-so

rewrite还是很有必要装上的,enable so让apache可以加载php模块。

Mysql

mysql 的下载地址(以5.0为例):http://mysql.org/downloads/mysql/5.0.html#source

注意我们这里下载的是 source,要自己来编译。这样可以控制mysql默认的字符集是什么。

编译选项: ./configure –prefix=/data/mysql –with-charset=gbk –with-extra-charsets=all

这里设置的字符集是gbk,根据需要自己来设计自己的。别的安装的过程可以参考源码目录里面的INSTALL文件,基本按照那个一步一步来就行了。

libjpeg

安装php之前,先需要自己编译一个 libjpeg 和 libpng,系统安装的少东西,php编译不过去。

libjpeg 的下载地址:ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

编译选项:./configure –enable-static –enable-shared –prefix=/usr/local/libjpeg

libpng

libpng的下载地址:http://prdownloads.sourceforge.net/libpng/libpng-1.2.20.tar.bz2?download

编译选项:./configure –prefix=/usr/local/libpng

php

php的下载地址(目前的最新版):http://cn.php.net/get/php-5.2.4.tar.bz2/from/this/mirror

编译选项:

./configure –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/data/mysql/  –prefix=/usr/local/php5/ –with-config-file-path=/usr/local/php5/etc –with-openssl –enable-mbstring –with-iconv –with-curl –with-gd –with-zlib  –with-png-dir=/usr/local/libpng –with-jpeg-dir=/usr/local/libjpeg

分类: Linux, Other 标签:

gdm登陆窗口的方块乱码

2007年9月16日 wd 没有评论

这几天一直有个问题解决不了,gdm的登陆窗口上面的字体是方块。我一般都是使用home下面的.fonts.conf 来配置字体的。不过gdm启动的时候好像也不会读取你home的下吧,所以还是把他放到了/etc/fonts/local.conf 里面。

使用gdm的时候,配置为theme的时候,gdm会起不了,不停的尝试,最后出一个提示窗口,全是方块。不过应该是提示没办法启动welcome窗口的。配置为简介模式的话,gdm至少能起来,虽然上面的字体全是方块,连我输入的字也是方块,就算是英文。

开始以为是字体设置的问题,把我的自定义设置全部去掉也不行。locale改成英文就正常了。不过还是不爽,搜了半天没找到解决办法,后来有篇文章提示了一下,会不会是字体权限的问题?我才想起来自己添加的雅黑字体,去看了一下,果然只有root可读。修改权限之后,方块的现象没了。

分类: Linux, Other 标签:

给ibm server设置raid

2007年9月16日 wd 2 条评论

昨天去给一台没拆封的ibm server装系统,头一次弄了raid,发现操作起来也不难。之前心里没底,就去yahoo搜索了一下,发现图解的都是使用server guide 那个光盘安装windows的(其实就一篇文章,n多人转载了),这次装就顺便拍了一下,呵呵。

server guide 光盘的图,用serverguide安装也挺简单的,光盘启动之后按照提示一步一步来就行了。

阅读全文…

分类: Linux, Other 标签:

涉及到linux系统安全的几个文件

2007年7月24日 wd 2 条评论

部分内容转自这里

1 cron.allow,cron.deny

If the cron.allow file exists, then you must be listed therein in order to be allowed to use this command. If the cron.allow file does not exist but the cron.deny file does exist, then you must not be listed in the cron.deny file in order to use this command. If neither of these files exists, only the super user will be allowed to use this command.

上面是引用 man crontab 里面的一段解释。如果 cron.allow 存在,那里面的用户可以使用crontab命令。如果cron.allow 不存在,而 cron.deny 存在,那么列在里面的用户不可以使用crontab命令。如果都不存在,那么只允许super用户来使用这个命令。

安装rh的时候,默认就会存在一个 cron.deny 的空文件,所以普通用户也可以使用crontab。

2 at.allow,at.deny

The superuser may use these commands in any case. For other users, permission to use at is determined by the files
/etc/at.allow and /etc/at.deny.

If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at.

If /etc/at.allow does not exist, /etc/at.deny is checked, every username not mentioned in it is then allowed to use at.

If neither exists, only the superuser is allowed use of at.

An empty /etc/at.deny means that every user is allowed use these commands, this is the default configuration.

这个其实和上面那个是类似的。默认也是有个空的 at.deny 文件,允许所有用户使用at。

3 /etc/security/access.conf

# Login access control table.
#
# When someone logs in, the table is scanned for the first entry that
# matches the (user, host) combination, or, in case of non-networked
# logins, the first entry that matches the (user, tty) combination. The
# permissions field of that table entry determines whether the login will
# be accepted or refused.

login 权限控制表。可以控制允许登陆的ip,登陆的tty等信息。

# Disallow console logins to all but a few accounts.
#
#-:ALL EXCEPT wheel shutdown sync:LOCAL

比如可以设置只允许某些用户从本地登陆。建议设置root用户不能从本地登陆。

4 /etc/securetty

该文件可控制根用户登录的设备,该文件里记录的是可以作为根用户登录的设备名,如tty1、tty2等。用户是不能从不存在于该文件里的设备登录为根用户的。这种情况用户只能以普通用户登录进来,再用su命令转为根用户。/etc/securetty文件的格式如下:

# /etc/securetty: list of terminals on which root is allowed to login.
# See securetty(5) and login(1).
console

# for people with serial port consoles
ttyS0

# for devfs
tts/0

# Standard consoles
tty1
tty2
tty3
...

如果/etc/securetty是一个空文件,则根用户就不能从任务的设备登录系统。只能以普通用户登录,再用su命令转成根用户。如果/etc/securetty文件不存在,那么根用户可以从任何地方登录。这样会引发安全问题,所以/etc/securetty文件在系统中是一定要存在的。

5 /etc/login.defs

login.defs是设置用户帐号限制的文件,在这里我们可配置密码的最大过期天数,密码的最大长度约束等内容。该文件里的配置对root用户无效。如果/etc/shadow文件里有相同的选项,则以/etc/shadow里的设置为准,也就是说/etc/shadow的配置优先级高于 /etc/login.defs。下面内容是该文件的节选:

...
#
# Password aging controls:
#
#       PASS_MAX_DAYS   Maximum number of days a password may be used.
#       PASS_MIN_DAYS   Minimum number of days allowed between password change.
#       PASS_WARN_AGE   Number of days warning given before a password expires.
#
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_WARN_AGE 7
...
#
# Number of significant characters in the password for crypt().
# Default is 8, don't change unless your crypt() is better.
# If using MD5 in your PAM configuration, set this higher.
#
PASS_MAX_LEN            8
...

6 /etc/pam.d/su

通过pam来限制su命令的使用。比如可以设置哪些组,哪些用户才能使用。

#auth sufficient /lib/security/$ISA/pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the “wheel” group.
auth required /lib/security/$ISA/pam_wheel.so group=admin

分类: Linux, Other 标签:

smsd 发送中文短信乱码

2007年7月5日 wd 没有评论

smsd是使用mysql数据库的,所以这个乱码很容易把人搞晕。我之前写过gnokii发送短信是和locale有关系的,只要在utf8的locale下面就可以正常发送中文短信了。而smsd也和这个类似,也需要utf8的locale。但是还需要注意的一点就是mysql也是有编码设置的。所以可能会认为,文本插入数据库之前是不是也需要对数据库做utf8的设置呢?其实是不需要的,这么做反而会造成乱码。

smsd连接mysql用的是mysql默认的字符集,那么我们插入文本的时候,也同样需要使用这个字符集,需要注意的是,这个文本也需要是utf8编码的。mysql默认的字符集通常是 “default-character-set             latin1”。

我写的一个python的用来插入数据库要发送的信息的程序。

#!/usr/bin/env python2.3
#coding=utf-8
import sys
import MySQLdb
 
#  inbox
#+------------+------------------+------+-----+---------------------+----------------+
#| Field      | Type             | Null | Key | Default             | Extra          |
#+------------+------------------+------+-----+---------------------+----------------+
#| id         | int(10) unsigned |      | PRI | NULL                | auto_increment |
#| number     | varchar(20)      |      |     |                     |                |
#| smsdate    | datetime         |      |     | 0000-00-00 00:00:00 |                |
#| insertdate | timestamp        | YES  |     | CURRENT_TIMESTAMP   |                |
#| text       | varchar(160)     | YES  |     | NULL                |                |
#| phone      | tinyint(4)       | YES  |     | NULL                |                |
#| processed  | tinyint(4)       |      |     | 0                   |                |
#+------------+------------------+------+-----+---------------------+----------------+
 
#  outbox
#+----------------+------------------+------+-----+---------------------+----------------+
#| Field          | Type             | Null | Key | Default             | Extra          |
#+----------------+------------------+------+-----+---------------------+----------------+
#| id             | int(10) unsigned |      | PRI | NULL                | auto_increment |
#| number         | varchar(20)      |      |     |                     |                |
#| processed_date | timestamp        | YES  |     | CURRENT_TIMESTAMP   |                |
#| insertdate     | timestamp        | YES  |     | 0000-00-00 00:00:00 |                |
#| text           | varchar(160)     | YES  |     | NULL                |                |
#| phone          | tinyint(4)       | YES  |     | NULL                |                |
#| processed      | tinyint(4)       |      |     | 0                   |                |
#| error          | tinyint(4)       |      |     | -1                  |                |
#| dreport        | tinyint(4)       |      |     | 0                   |                |
#| not_before     | time             |      |     | 00:00:00            |                |
#| not_after      | time             |      |     | 23:59:59            |                |
#+----------------+------------------+------+-----+---------------------+----------------+
 
class Mydb:
        def __init__(self):
                try:
                        self.db=MySQLdb.Connection(host="localhost",user="gnokii",
                                passwd="gnokii",db="gnokii")
 
                except MySQLdb.OperationalError, message:
                        errorMessage = "Error %d:\n%s" % (message[ 0 ], message[ 1 ] )
                        print errorMessage
                        sys.exit(1)
                else:   
                        self.cursor = self.db.cursor()
#                       self.cursor.execute("SET NAMES 'utf8'")
                        return
 
        def insert(self,sql):
                self.cursor.execute(sql)
 
        def showdata(self,sql):
                self.cursor.execute(sql)
                return self.cursor.fetchall()
 
        def __del__(self):
                self.cursor.close
                self.db.close
 
text = sys.stdin.read()
db = Mydb()
 
if len(sys.argv) > 1 and len(text):
        number = sys.argv[1]
        sql = 'insert into outbox (number,text) VALUES ("' + number + '","' + text + '")'
 
        db.insert(sql)
 
else:   
        print 
        print "    ********** outbox ********** "
        for rs in db.showdata("select * from outbox"):
                print rs[0],rs[1],rs[2],rs[-7],rs[-5]
 
        print "    ********** inbox *********"
        for rs2 in db.showdata("select * from inbox"):
                print rs2[0],rs2[1],rs2[-3]
分类: Linux, Other 标签: ,

oracle 的 job 又遇到问题了

2007年6月29日 wd 没有评论

还是高级复制的问题,这次可能是因为job执行过程中,对方机器刚好重启导致的。反正job是卡在那里了,都10多天了。

查看 dba_jobs_running 表,可以看到卡住的job的 job_id 和 sid 。查看 dba_jobs 表,可以看到相应 job 的信息,this_date 如果有数据的话,表示的是 job 开始执行的时间,next_date 是下次执行 job 的时间,如果 job 正常执行完毕,那么 this_date 应该是空的。根据 sid 还可以查看 v$session_wait 和 v$session 里面的这个 job 的一些状态。

尝试了下面的方法来重新运行job,当时好像不好用,不过今天来看的时候,job是执行了。现在也不清楚是不是我这个操作起作用了,真晕。

SQL> exec dbms_job.broken(109,true);
 
PL/SQL procedure successfully completed.
 
SQL> commit;
 
Commit complete.
 
SQL> select job,sid from dba_jobs_running;
 
       JOB        SID
---------- ----------
       109        656
 
SQL> select saddr,sid,serial#,paddr,username,status from v$session where username = 'REPADMIN';
 
SADDR           SID    SERIAL# PADDR    USERNAME                       STATUS
-------- ---------- ---------- -------- ------------------------------ --------
973CF8C4        626         27 98F96BB8 REPADMIN                       ACTIVE
973D2E7C        629         10 98F88670 REPADMIN                       ACTIVE
973F11F4        656         10 98F88174 REPADMIN                       ACTIVE
 
SQL> alter system kill session '656,10';
 
System altered.
 
SQL> select saddr,sid,serial#,paddr,username,status from v$session where username = 'REPADMIN';
 
no rows selected
 
SQL> select job,sid from dba_jobs_running;
 
no rows selected
 
SQL> select job,log_user,last_date,next_date from dba_jobs where log_user='REPADMIN';
 
       JOB LOG_USER                       LAST_DATE
---------- ------------------------------ -------------------
NEXT_DATE
-------------------
       106 REPADMIN                       2007-06-28 16:25:43
2007-06-28 16:35:43
 
       109 REPADMIN                       2007-06-28 16:07:38
4000-01-01 00:00:00
 
       110 REPADMIN                       2007-06-28 16:25:43
2007-06-28 16:35:43
 
 
SQL> exec dbms_job.broken(109,false,sysdate);
 
PL/SQL procedure successfully completed.
 
SQL> commit;
 
Commit complete.
 
SQL> select job,log_user,last_date,next_date from dba_jobs where log_user='REPADMIN';
 
       JOB LOG_USER                       LAST_DATE
---------- ------------------------------ -------------------
NEXT_DATE
-------------------
       106 REPADMIN                       2007-06-28 16:25:43
2007-06-28 16:35:43
 
       109 REPADMIN                       2007-06-28 16:07:38
2007-06-28 16:28:40
 
       110 REPADMIN                       2007-06-28 16:25:43
2007-06-28 16:35:43

此后就我所知道的,就只能等着了。dbms_job.run(job_id) 也可以让 job 立即执行。关键是看 this_date ,他的值就是开始执行 job 的时间,job 如果执行时间太长,而下次执行又太快的话,可能也会导致问题。所以还可以尝试手动执行 job 看看。 dba_jobs 的 waht 字段就是对于的语句。

分类: Linux, Other 标签: , ,

稍微深入了解了一下cacti的thold插件的邮件通知

2007年6月28日 wd 3 条评论

通过cacti的thold插件,可以做到snmp抓取到的数值低于你规定的值的时候进行邮件通知,例如我用他来监控磁盘空间,当磁盘空间低于某个数的时候就会给指定的email发邮件。但是有一点郁闷的是,有时候,可能是由于网络原因,抓取会超时,这样就会导致触发trigger,给你发送邮件。5分钟抓取一次,我这里的情况是几乎每个小时总会有2,3封这种邮件,很烦人,而且根本没意义。早就想屏蔽掉这种情况了,看了代码挺复杂就懒得弄,今天实在受不了了,深入了解了一下。

其实thold本身已经考虑到了这种情况,在 thold 的设置里面,就有一项 Default Trigger Count (Number of consecutive times the data source must be in breach of the threshold for an alert to be raised),就是连续触发几次才认为他真的低于 thold 了,才发送邮件。我尝试过修改这个设置,发现不管用。看了代码才了解,每个 Thresholds 都有自己的 trigger 值,那个 default trigger count 只对新建的 thresholds 才有用。所以针对现有的,需要逐个去修改才行。如果不设置这个选项,那么使用的就是上面设置的那个默认的,所以没特殊需要,还是不要针对每个 thresholds 设置自己的 trigger 值比较好,这样方便修改。我通过修改数据库的方法,直接把这些都修改了。

UPDATE thold_data SET thold_fail_trigger = NULL;

修改了之后还没有收到,这下应该清净了吧?

分类: Linux, Other 标签: , ,

为resin配置oracle连接池

2007年6月27日 wd 没有评论

resin 2.x 的配置方法和 3.x 的方法有区别。按照官方文档,做下面的配置。

<database>
  <jndi-name>oraPool</jndi-name>
  <driver>
    <type>oracle.jdbc.pool.OracleConnectionPoolDataSource</type>
    <url>jdbc:oracle:thin:@localhost:1521:dbname</url>
    <user>username</user>
    <password>password</password>
  </driver>
#....
</database>

 在上面的 …. 这里还可以添加其他的配置信息。配置好之后启动resin,会发现提示类似下面的信息。

conf/resin.conf:218: java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource

提示没有找到连接oracle数据库的jdbc驱动。这个驱动在oracle的安装目录里面有。比如我这里是在 /db/oracle/10.1.0/product/10g/jdbc/lib/ 。里面好多文件,具体都什么作用可以看这里

复制这个目录里面的 classes12.jar 和 nls_charset12.jar 到resin的 lib 目录下面,重新启动 resin 就可以了。本文完成过程中参考了这篇文章。如何使用这个pool,官方文档也有说明

分类: Linux, Other 标签: ,

resin 的安装步骤

2007年6月21日 wd 没有评论

resin目前已经到了3.1版本,从resin网站上面下载的resin不带jdk,需要自己去下载。resin的下载页面在这里。下载最新的 Resin Pro 3.1.1 版本。

jdk的下载地址在 这里 ,resin 3.1需要1.5及以上版本的jdk。

先来安装resin:

tar zxvf resin-pro-3.1.1
cd resin-pro-3.1.1
./configure --prefix=/usr/local/resin #安装的目的地址
make &amp;&amp; make install

安装完resin之后,安装jdk:

cd /usr/local
chmod +x /root/jdk-6u1-linux-i586.bin
/root/jdk-6u1-linux-i586.bin

此后会在/usr/local/下面建立一个jdk1.6.0_01目录,jdk就安装完毕了。

resin 的配置文件在 /usr/loca/resin/conf 下面,主要是 resin.conf 。默认的端口是8080。

<http port="8080" address="*">

然后就是添加自己的应用地址了。

<host id="" root-directory=".">
      <web-app id="/" root-directory="webapps/ROOT">

在这下面添加一行

<web-app id="/test" root-directory="/www/test/">

此后呢,访问 http://ip:8080/test 就可以访问到你的应用了。

分类: Linux, Other 标签:

linux tuning

2007年6月4日 wd 没有评论

地址 http://www.enigma.id.au/linux_tuning.txt

# Linux kernel tweaking for performance and security on a busy Linux
# server with a decent amount of memory.
#
# This file should be saved as /etc/sysctl.conf
# You can source it manually if your system has booted by using:
# sysctl -e -p /etc/sysctl.conf
#
# Paul Day, paul (at) bur.st
#
# Last updated 02/03/05 and tested on 2.6.9
#
 
# Increase RPC slots
sunrpc.tcp_slot_table_entries = 32
sunrpc.udp_slot_table_entries = 32
# Increase size of RPC datagram queue length
net.unix.max_dgram_qlen = 50
# Log spoofed, source routed and redirects
net.ipv4.conf.default.log_martians = 1
# Don't accept source routes
net.ipv4.conf.default.accept_source_route = 0
# Don't send redirects
net.ipv4.conf.default.send_redirects = 0
# Source route verification on - incoming packets must match outgoing routing
net.ipv4.conf.default.rp_filter = 1
# Don't accept redirects
net.ipv4.conf.default.accept_redirects = 0
# Don't forward source routes
net.ipv4.conf.default.mc_forwarding = 0
# Disable forwarding 
net.ipv4.conf.default.forwarding = 0
# Log spoofed, source routed and redirects
net.ipv4.conf.all.log_martians = 1
# Don't relay bootp
net.ipv4.conf.all.bootp_relay = 0
# Don't proxy arp for anyone
net.ipv4.conf.all.proxy_arp = 0
# Don't accept source route packets
net.ipv4.conf.all.accept_source_route = 0
# Don't send redirects
net.ipv4.conf.all.send_redirects = 0
# Source route verification on - incoming packets must match outgoing routing
net.ipv4.conf.all.rp_filter = 1
# Don't accept redirects
net.ipv4.conf.all.accept_redirects = 0
# Don't forward source routes
net.ipv4.conf.all.mc_forwarding = 0
# Don't enable forwarding
net.ipv4.conf.all.forwarding = 0
# Don't allow the arp table to become bigger than this
net.ipv4.neigh.default.gc_thresh3 = 2048
# Tell the gc when to become aggressive with arp table cleaning.
# Adjust this based on size of the LAN. 256 is suitable for most
net.ipv4.neigh.default.gc_thresh2 = 1024
# Adjust where the gc will leave arp table alone - set to 32.
net.ipv4.neigh.default.gc_thresh1 = 32
# Adjust to arp table gc to clean-up more often
net.ipv4.neigh.default.gc_interval = 30
# Increase TCP
net.ipv4.neigh.default.proxy_qlen = 96
net.ipv4.neigh.default.unres_qlen = 6
# Increase size of socket buffers
net.ipv4.tcp_rmem = 4096	98304	349520
net.ipv4.tcp_wmem = 4096	65535	262142
net.ipv4.tcp_mem = 98304	262142	393216
# Turn off sack
net.ipv4.tcp_dsack = 0
# Don't use ECN because too many sites have wacky routers that can't handle it`
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_reordering = 3
# Turn off sack/fack
net.ipv4.tcp_fack = 0
# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Ignore broadcasts pings, could become part of a Smurf
net.ipv4.icmp_echo_ignore_broadcasts = 1
# But don't ignore directed pings
net.ipv4.icmp_echo_ignore_all = 0
# Widen local port range
net.ipv4.ip_local_port_range = 33000	60000
# Bump up TCP socket queuer to help with syn floods
net.ipv4.tcp_max_syn_backlog = 2048
# Turn syn-cookie protection on
net.ipv4.tcp_syncookies = 1
# Drop it so lack of FIN times out quicker
net.ipv4.tcp_fin_timeout = 30
# How many times to retry killing an alive TCP connection
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3
# Enable a fix for RFC1337 - time-wait assassination hazards in TCP
net.ipv4.tcp_rfc1337 = 1
# Drop keep-alive time
net.ipv4.tcp_keepalive_time = 3600
# Set number of times to retry a SYN-ACK in a half-open new connections
net.ipv4.tcp_synack_retries = 5
# Set number of times to retry SYN in a new connection
net.ipv4.tcp_syn_retries = 5
# Turn off sack
net.ipv4.tcp_sack = 0
# Enable really big (>65kB) TCP window scaling if we want it.
net.ipv4.tcp_window_scaling = 1
# Turn off timestamps
# Turn this back on if you're on a gigabit or very busy network
# Having it off is one less thing the IP stack needs to work on
net.ipv4.tcp_timestamps = 0
# Increase number of incoming connections backlog
net.core.somaxconn = 512
# Bump optmem_max up
net.core.optmem_max = 20480
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 1024
net.core.dev_weight = 64
# Bump up default r/wmem to max
net.core.rmem_default = 262141
net.core.wmem_default = 262141
# Bump up max r/wmem
net.core.rmem_max = 262141
net.core.wmem_max = 262141
# Increase size of file handles and inode cache
fs.file-max = 209708

Powered by ScribeFire.

分类: Linux, Other 标签: , ,