美文网首页
Centos7.*系统优化

Centos7.*系统优化

作者: 读书人司马缸 | 来源:发表于2019-10-23 11:50 被阅读0次

    #!/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/

    net.ipv4.tcp_tw_reuse = 1

    net.ipv4.tcp_tw_recycle = 1

    fs.file-max = 102400

    vm.max_map_count=262144

    #centos tail

    EOF

    sysctl -p

    source /etc/profile

    }

    function main(){

        port_set

        sys_config

    }

    main

    相关文章

      网友评论

          本文标题:Centos7.*系统优化

          本文链接:https://www.haomeiwen.com/subject/feohvctx.html