centos模板机制作前修改配置

前端之家收集整理的这篇文章主要介绍了centos模板机制作前修改配置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.关闭selinux@H_502_1@sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config@H_502_1@setenforce 0 临时生效,想要长期生效,重启系统@H_502_1@getenforce 查看selinux状态@H_502_1@2.关闭防火墙@H_502_1@/etc/init.d/iptables stop@H_502_1@/etc/init.d/iptables stop 要关闭至少2次@H_502_1@chkconfig iptables off@H_502_1@3.精简开机自启动服务@H_502_1@chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig",$1,"off"}'|bash@H_502_1@export LANG=en@H_502_1@chkconfig --list|grep 3:on

4.提权oldboy可以sudo@H_502_1@useradd oldboy@H_502_1@\cp /etc/sudoers /etc/sudoers.ori@H_502_1@echo "oldboy ALL=(ALL) NOPASSWD:ALL">>/etc/sudoers@H_502_1@tail -l /etc/sudoers@H_502_1@visudo -c

5.中文字符集@H_502_1@先查看@H_502_1@[root@oldboy ~]# cat /etc/sysconfig/i18n @H_502_1@LANG="en_US.UTF-8"@H_502_1@SYSFONT="latarcyrheb-sun16"@H_502_1@再备份@H_502_1@[root@oldboy ~]# cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori@H_502_1@再修改@H_502_1@[root@oldboy ~]# echo 'LANG="zh_CN.UTF-8"'>/etc/sysconfig/i18n@H_502_1@[root@oldboy ~]# source /etc/sysconfig/i18n @H_502_1@#使上文修改生效@H_502_1@[root@oldboy ~]# echo $LANG@H_502_1@查看当前字符集状态

6.时间同步@H_502_1@[root@oldboy ~]# echo '#time sync by oldboy at 2010-2-1'>>/var/spool/cron/root@H_502_1@[root@oldboy ~]# echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1' >>/var/spool/cron/root@H_502_1@[root@oldboy ~]# crontab -l@H_502_1@#time sync by oldboy at 2010-2-1@H_502_1@*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1

@H_502_1@

7.命令行安全

[root@oldboy ~]# #time sync by oldboy at 2010-2-1@H_502_1@[root@oldboy ~]# echo 'export TMOUT=300' >>/etc/profile@H_502_1@[root@oldboy ~]# echo 'export HISTSIZE=5' >>/etc/profile @H_502_1@[root@oldboy ~]# echo 'export HISTFILESIZE=5' >>/etc/profile@H_502_1@[root@oldboy ~]# tail -3 /etc/profile

[root@oldboy ~]# . /etc/profile

@H_502_1@

8.加大文件描述

[root@oldboy ~]# echo '* - nofile 65535' >>/etc/security/limits.conf

[root@oldboy ~]# tail -1 /etc/security/limits.conf @H_502_1@* - nofile 65535

@H_502_1@

9.内核优化

cat >>/etc/sysctl.conf<<EOF@H_502_1@net.ipv4.tcp_fin_timeout = 2

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_keepalive_time = 600

net.ipv4.ip_local_port_range = 400065000

net.ipv4.tcp_max_syn_backlog = 16384

net.ipv4.tcp_max_tw_buckets = 36000

net.ipv4.route.gc_timeout = 100

net.ipv4.tcp_syn_retries = 1

net.ipv4.tcp_synack_retries = 1

net.core.somaxconn = 16384

net.core.netdev_max_backlog = 16384

net.ipv4.tcp_max_orphans = 16384@H_502_1@#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。@H_502_1@#以下参数是对iptables防火墙的优化。@H_502_1@#CentOS 6.X:

net.netfilter.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_tcp_timeout_established = 180

net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60

net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120

#注意:在此优化过程中可能会有报错

#举例:

#5.8版本上

error: "net.ipv4.ip_conntrack_max"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_max"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait"is an unknown key

#6.4版本上

error: "net.nf_conntrack_max"isan unknown key

error: "net.netfilter.nf_conntrack_max"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_established"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_time_wait"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_close_wait"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_fin_wait"isan unknown key

#6.4版本上

error: "net.bridge.bridge-nf-call-ip6tables"isan unknown key

error: "net.bridge.bridge-nf-call-iptables"isan unknown key

error: "net.bridge.bridge-nf-call-arptables"isan unknown keyEOF

猜你在找的CentOS相关文章