zoukankan      html  css  js  c++  java
  • 服务器初始化脚本

    #!/bin/bash
    #关闭防火墙
    Version=`cat /proc/version |awk '{print $3}' |cut -d"." -f1`
    if [ $Version -eq 2 ];then
    sudo service iptables stop
    sudo chkconfig iptables off
    else
    sudo systemctl stop firewalld
    sudo systemctl disable firewalld
    fi

    #修改默认打开句柄数
    cd /etc/security/limits.d/
    File=`ls`

    cat <<EOF>>/etc/security/limits.d/$File
    * soft nproc 20480
    * hard nproc 20480
    * soft nofile 1048576
    * hard nofile 1048576
    EOF

    #修改内核参数
    cat <<FOF>>/etc/sysctl.conf
    net.core.somaxconn = 4096
    net.ipv4.ip_local_port_range = 2048 65535
    net.core.netdev_max_backlog = 65000
    net.ipv4.tcp_max_syn_backlog = 8196
    net.ipv4.ip_forward = 1
    FOF

    sudo sysctl -p /etc/sysctl.conf

    #关闭selinx
    setenforce 0

    #添加hosts文件
    IP=`ifconfig eth0 | grep "inets" | awk '{ print $2}'`
    Host=`hostname`
    echo $IP $Host >>/etc/hosts

    * soft nproc 20480
    * hard nproc 20480
    root soft nproc unlimited
    root hard nproc unlimited
    * soft nofile 1048576
    * hard nofile 1048576

  • 相关阅读:
    ACM学习
    吴翼大神
    心急的C小加(两种解法)
    万圣节派对(水题)
    poj 1163 The Triangle
    POJ 1088滑雪
    1690 开关灯
    908. 校园网
    STL之stack栈
    1163 访问艺术馆
  • 原文地址:https://www.cnblogs.com/qinghe123/p/8127086.html
Copyright © 2011-2022 走看看