分类: 系统运维
2012-09-21 16:56:02
摘要: CentOS 初始化设置 +基本web环境配置,yum方式
############# 第一部分 上线之前 基本环境检查,配置 ###################
######### LAMP 环境安装之前的基本设置、校准操作######################
####### 1 配置、校准部分
# data
###### 如时间显示不对,时区不对
# cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
########校准系统时间,写入硬件时钟芯片 ###########
####### 2.启用 ntp服务同步时间
# yum -y install ntp
# ntpdate us.pool.ntp.org
#chkconfig ntpd on
#hwclock --systohc## or clock -w
######### 3. 加入监控
# yum install net-snmpd
# chkconfig snmpd on
# vi /etc/snmp/snmpd.conf
######## 加入监控服务器IP ###########################
############ 替换以下内容即可#########################
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser 123.456.0.1 server_ID
# Second, map the security name into a group name:
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
####
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact all none none
## incl/excl subtree mask
view all included .1 80
###################### end of snmpd.conf #####################
####### 4 全更新
######### 默认CentOS yum源来升级版本
# yum update -y
###### 5. 关闭服务 不需要的服务
### setup --- > system service
#Or
### 1/ chkconfig –level 345 bluetooth off
### 2/ chkconfig --level 345 dund off
### 3/ chkconfig --level 345 cups/ cupspeed off
### 4/ chkconfig --level 345 firstboot off
### 5/ chkconfig --level 345 isdn off
########### 没连 isci 存储设置的话,可关
### 6/ chkconfig --level 345 iscsi off
### 7/ chkconfig --level 345 iscsid off
### 8/ chkconfig --level 345 pcscd off
### 9/ chkconfig --level 345 portmap off
########### 如无 nfs 网络服务,关闭 nfsclock
### 10/ chkconfig --level 345 nfscolck off
### 11/ chkconfig --level 345 sendmail off
### 12/ chkconfig --level 345 iptables off
### 13/ chkconfig --level 345 ip6tables off
### 14 / chkconfig --level 345 named off### 方便调试 关闭 iptables
## /etc/init.d/iptables stop
#######根据实际情况 卸载 与web无关的服务和包
## yum groupremove "Mail Server"
## yum groupremove "Dialup Networking Support"
###### 7. 设置 ssh port #############################
## vi /etc/ssh/sshd_config
## PORT 22―――>改为非 22端口 如 9991
######## 8. 根据实际情况 关闭 SELinux ################
### vi /etc/selinux/config
SELINUX=disabled
### 需要 重启OS后生效
########### 9 . 如为负载环境,加上 本地loopback IP绑定 #################
#### 换回地址 lo :0 上绑定 vip 123.123.1.232
vi /etc/sysconfig/network-scripts/ifcfg-lo:0
IPADDR= 123.123.1.232 ### 此处写入负载的虚拟IP
NETMASK=255.255.255.255
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
ONBOOT=yes
NAME=loopback
##################### 负载的web server 127 128 上
# vi /etc/sysctl.conf
# sysctl.conf加入 net.ipv4.conf.eth0.arp_ignore = 1
# net.ipv4.conf.eth0.arp_announce = 2
#sysctl -p 生效下
# service network restart
#### 重启下网络服务生效 #
#### 检查下 ip 是否绑定
##### ifconfig |grep addr