前言
脚本说明
脚本下载
系统初始化
一键执行脚本
sh system_init_v4.sh
手动执行过程
配置yum源
yum install -y wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
yum clean all
yum makecache
安装必要的软件,创建目录
yum install -y vim wget lrzsz telnet traceroute iotop tree rsync
yum install -y git zlib-devel openssl-devel unzip xz libxslt-devel libxml2-devel libcurl-devel
#yum -y install ipset ipset-service >/dev/null 2>&1
yum -y install net-tools.x86_64 vim lsof
yum install -y openssl openssl-devel openssh openssh-server
yum install -y ntpdate crontabs
修改系统限制
cat <<EOF >>/etc/security/limits.conf
* soft nofile 1048576
* hard nofile 1048576
EOF
cat <<EOF >/etc/security/limits.d/20-nproc.conf
* soft nproc 1048576
* soft nproc 1048576
EOF
增加操作系统记录数量
if ! grep "HISTTIMEFORMAT" /etc/profile >/dev/null 2>&1
then echo '
UserIP=$(who -u am i | cut -d"(" -f 2 | sed -e "s/[()]//g")
export HISTTIMEFORMAT="[%F %T] [`whoami`] [${UserIP}] " ' >> /etc/profile;
fi
sed -i "s/HISTSIZE=1000/HISTSIZE=999999999/" /etc/profile
系统内核优化
cat <<EOF > /etc/sysctl.conf
fs.file-max = 6553560
net.core.netdev_max_backlog = 32768
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.wmem_max = 16777216
net.ipv4.conf.all.arp_ignore = 0
net.ipv4.conf.lo.arp_announce = 0
net.ipv4.conf.lo.arp_ignore = 0
net.ipv4.ip_local_port_range = 5000 65000
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
vm.overcommit_memory = 1
EOF
关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
yum -y remove firewalld
yum -y install iptables-services iptables
同步系统时间,时区设置
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
/usr/sbin/ntpdate ntp.ntsc.ac.cn
/usr/sbin/hwclock -w
#计划任务,每5分钟同步系统时间
echo "*/5 * * * * flock -xn /tmp/ntp.lock -c '/usr/sbin/ntpdate ntp.ntsc.ac.cn >> /tmp/ntp.log 2>&1 &'" >> /var/spool/cron/root
登录欢迎语设置
/usr/bin/cp -f ../support/login.sh /usr/local/bin/login.sh && chmod +x /usr/local/bin/login.sh
echo "/usr/local/bin/login.sh" >> /etc/profile
docker安装
一键执行脚本
sh app_install_docker.sh
手动执行过程
安装python3环境
yum update -y
yum groupinstall Development tools -y
yum -y install zlib-devel
yum install -y openssl-devel libxslt-devel libxml2-devel libcurl-devel
yum install python3 -y
安装docker-ce
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-edge
yum install -y docker-ce
安装docker-compose编排工具
/bin/cp -f ../support/docker-compose /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
docker服务开机自启
/bin/systemctl enable --now docker
喜欢这篇文章,作者666,文章真棒!
终于找到这篇文章了,感谢作者的分享!
谢谢分享
感谢博主
受益匪浅,感谢博主。
继续努力啊,多一些脚本啊::(嗯哼)
好的,一起学习
受益匪浅,感谢博主。对小白真的很友好,写的很全面。
这篇文章肯定会火,作者666大顺
牛逼
对小白真的很友好,写的很全面。
喜欢这篇文章,作者666,文章真棒!