#!/bin/bash
#centos7通用脚本
echo "centos7 初始化脚本"
yum install -y lrzsz yum-utils device-mapper-persistent-data lvm2 git
yum install -y epel-release
yum install -y python-pip git
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
pip install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple
#curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
function port_set(){
echo "关闭selinux和防火墙"
setenforce 0
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
systemctl start docker
systemctl enable docker
}
function sys_config(){
echo "<<<<<<<<<<<<<<<<<<<<<<添加系统配置>>>>>>>>>>>>>>>>>>>>"
sed -i '/#seclover head/, /#seclover tail/d' /etc/security/limits.conf
cat >> /etc/security/limits.conf <<'EOF'
#seclover head/
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
#seclover tail
EOF
sed -i '/#centos head/, /#centos tail/d' /etc/sysctl.conf
cat >> /etc/sysctl.conf <<"EOF"
#centos head/
fs.file-max = 102400
#centos tail
EOF
sysctl -p
source /etc/profile
}
function main(){
port_set
sys_config
}
main
网友评论