centos 7初始化系统(补充中)
1、关闭selinux:setenfore 0 ;sed -i “s/enable/disabled/” /etc/config/selinx
2、关闭firewalld:sys:systemctl stop firewalld;systemctl disabled firewalld
3、设置会话连接超时时间和History历史记录配置:在/etc/profile文件中末尾添加2行:
export TMOUT=1800
export HISTTIMEFORMAT="%F %T whoami "
4、更新阿里云yum源
备份yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载阿里云yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e ‘/mirrors.cloud.aliyuncs.com/d’ -e ‘/mirrors.aliyuncs.com/d’ /etc/yum.repos.d/CentOS-Base.repo
清理yum源缓存 yum -y clean all
产生缓存 yum makecache
查看当前源 yum repolist
更新软件 yum -y update
5、配置时间同步:yum install -y vim && yum install -y ntpdate && /usr/sbin/ntpdate 1.cn.pool.ntp.org
执行crontab -e命令,添加:0 * * * * /usr/sbin/ntpdate 1.cn.pool.ntp.org
内容
6、YUM安装必要软件
``yum install -y wget epel-release net-tools vim
7、关闭不必要的服务
systemctl stop postfix && systemctl disable postfix
systemctl stop NetworkManager && systemctl disable NetworkManager
8、内核优化
cat > /etc/sysctl.conf << EOF
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
fs.file-max = 131072
kernel.panic=1
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_no_metrics_save = 1
net.core.netdev_max_backlog = 3072
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_max_tw_buckets = 720000
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_retries1 = 2
net.ipv4.tcp_retries2 = 10
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_syncookies = 1
EOF
sysctl -p
cat >> /etc/security/limits.conf << EOF
* soft nproc 2048
* hard nproc 16384
* soft nofile 8192
* hard nofile 65536
EOF
9、安装zabbix客户端
- 安装官方yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm`
2、安装zabbix客户端软件包
`yum -y install zabbix-agent`
3、关闭防火墙或者开放10050和10051端口。
4、修改zabbix-agent.conf配置文件,将zabbix-server的地址修改为zabbix-server实际的IP地址。
`sed -i '/^#/d;/^$/d' /etc/zabbix/zabbix_agentd.conf && sed -i 's/127.0.0.1/10.61.1.139/g' /etc/zabbix/zabbix_agentd.conf `
5、启动zabbix-agent服务并设置开机启动
systemctl start zabbix-agent && /sbin/chkconfig zabbix-agent on