(2009-10-2)CentOS初始化

(2009-10-2)CentOS初始化

编辑文章

本文HTML永久地址doc

添加主机名

vi /etc/sysconfig/network
HOSTNAME="www.15099.net"
和
echo '***.***.***.*** www.15099.net www' >> /etc/hosts
reboot重启生效,使用hostname -f验证主机名是否设置正确

shell初始化 修改用户主提示符

echo 'PS1="[\u@\H \W]\$"'>> .bash_profile
更多相关帮助使用info bash 搜寻PS1

添加一个日常管理帐号

useradd sysadm
passwd sysadm
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
echo "AllowUsers sysadm" >> /etc/ssh/sshd_config
/etc/init.d/sshd restart

调整vi编辑习惯

yum -y install vim-enhanced
mv /bin/vi /bin/vi.bak
ln -s /usr/bin/vim /bin/vi
echo "set nu" >> /etc/vimrc

设置时间同步

mv /etc/localtime /etc/localtime.bak
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
或
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
其次,使服务器时间同步化:
yum install -y ntp
ntpdate -d us.pool.ntp.org

安装中文支持包,大概30M

yum -y install Deployment_Guide-zh-TW Deployment_Guide-zh-CN lv
echo "LANG=zh_CN.UTF-8" >> .bash_profile

关闭不必要的服务

/etc/init.d/iptables stop
/etc/init.d/mcstrans stop
/etc/init.d/messagebus stop
/etc/init.d/restorecond stop
/etc/init.d/httpd stop
/etc/init.d/xinetd stop
/etc/init.d/sendmail stop
/etc/init.d/saslauthd stop

chkconfig --level 345 iptables off
chkconfig --level 345 mcstrans off
chkconfig --level 345 messagebus off
chkconfig --level 345 restorecond off
chkconfig --level 345 httpd off
chkconfig --level 345 xinetd off
chkconfig --level 345 sendmail off
chkconfig --level 345 saslauthd off

设置自动升级

echo -ne "00 23 * * * yum -y update > /root/update.log\n" >> /var/spool/cron/root
/etc/init.d/crond restart
yum -y update 

平台兼容

如果是x8664平台,果你系统为x8664,而你的程序只支持i386平台,可以运行下列命令,这个命令为32位和64位兼容命令:

echo "i686-redhat-linux" > /etc/rpm/platform

关闭IPV6

vi /etc/sysconfig/network
hostname="www.15099.net"
NETWORKING_IPV6=no
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf

磁盘调优

vi /etc/fstab
/dev/sda1 / ext3 noatime,nodiratime 0 0

关闭ssh反IP解析

echo "UseDNS no" >> /etc/ssh/ssh_config

定义yum的非官方库

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

unixbench性能测试

cd /usr/src
wget http://members.cox.net/yikes2000/unixbench-4.1.0-wht.tar.gz
wget http://members.dslextreme.com/users/andylee/unixbench-4.1.0-wht.tar.gz
tar zxvf unixbench-4.1.0-wht.tar.gz
cd unixbench-4.1.0-wht-2
./Run

没有评论 :

发表评论