系統安裝后的初始化操作:
1.關閉ipv6:
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf
chkconfig ip6tables off
2.關閉selinux:
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
setenforce 0
3.關閉iptables:
chkconfig iptables off
service iptables stop
systemctl stop firewalld
systemctl disable firewalld
4.配置遠程管理ssh服務:
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config
systemctl restart sshd
service sshd restart
5.安裝必備軟件包:
cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup/
curl -s -o ./Centos-7.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum install -y epel-release && yum clean all && yum makecache && yum -y install unzip zip gcc gcc-c++ make autoconf libtool-ltdl-devel gd freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip ncurses-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool system-config-network-tui system-config-firewall-tui ntp libaio-devel wget nmap finger elinks tree tcl sysstat vim wget net-tools tree telnet
yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip ncurses-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool system-config-network-tui system-config-firewall-tui ntp libaio-devel wget nmap finger elinks tree tcl sysstat
systemctl stop NetworkManager
systemctl disable NetworkManager
chkconfig NetworkManager off
chkconfig bluetooth off
chkconfig postfix off
6.設置DNS服務器:
echo "nameserver 202.106.0.20" >> /etc/resolv.conf
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
7.設置時間同步:
echo "*/5 * * * * /usr/sbin/ntpdate ntp.tuna.tsinghua.edu.cn > /dev/null 2>&1" >> /var/spool/cron/root
echo "*/5 * * * * /usr/sbin/ntpdate ntp.tuna.tsinghua.edu.cn > /dev/null 2>&1" >> /var/spool/cron/root
service crond restart
systemctl restart crond
8.設置軟件硬件資源與內核同時打開文件最大值
#並發連接數
echo "root soft nofile 65535" >> /etc/security/limits.conf
echo "root hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo -e "root soft nofile 65535\nroot hard nofile 65535\n* soft nofile 65535\n* hard nofile 65535\n" >> /etc/security/limits.conf
sed -i 's#4096#65535#g' /etc/security/limits.d/20-nproc.conf
echo "ulimit -SHn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile 102400
* hard nofile 102400
* soft nproc 102400
* hard nproc 102400
EOF
chmod +x /etc/rc.d/rc.local
9.關閉control-alt-delete3鍵重啟
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf
1 0.調整內核參數
true > /etc/sysctl.conf
cat >> /etc/sysctl.conf << EOF
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 65536
kernel.shmall = 4294967296
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 65535
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65535
EOF
/sbin/sysctl -p
11.增加系統進程數(線程)的限制
sed -i 's/1024/102400/' /etc/security/limits.d/90-nproc.conf
12.設置系統默認啟動級別:
sed -i '/^id/s/5/3/' /etc/inittab
也可以將以上命令 寫到腳本中 然后運行腳本
給男生個小建議哦~
記住她喜歡吃酸的還是甜的
喜歡下雨還是下雪
她想你了 你陪陪她 她在外面受委屈了 你安慰她 她生氣了你哄哄她 她哭了 你抱抱她
還不行 就直接動嘴親親她!!!!!!!!!!!