• Linux 初始化服务器


    1、升级默认安装包

       apt-get  update或yum update all

    2、检查磁盘,格式化

       df -h    #查看挂载情况

       fdisk -l     #查看所有磁盘,没有使用的磁盘需要先格式化

       fdisk  /dev/sdb     #格式化/dev/sdb磁盘

       mkfs -t ext3 /dev/sdb    #给/dev/sdb创建文件系统,这里是ext3的文件系统

       mkdir /data  && mount  -t ext3   /dev/sdb  /data           #创建一个目录,将磁盘挂载到这个目录上

     vim /etc/fstab    #编辑/etc/fstab,设置开机磁盘自动挂载,保存后,一定要测试能不能挂载成功,先确定卸载(umount),再执行mount -a,如果没有报错,成功挂载了,就没有问题

        /dev/sdb /data  ext3  defaults  0 0

     

    3、检查系统时间

       date

       cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

       echo “export TZ='Asia/Shanghai' ”  >> ~/.bashrc  && source ~/.bashrc

       date -s “xxxx/xx/xx  14:00:00”

    4、检查系统语言环境

       echo $LANG

       vim  /etc/sysconfig/i18n  (centos)

               LANG="en_US.UTF-8"

               SYSFONT="latarcyrheb-sun16"

      vim /etc/default/locale    (ubuntu)

               LANG="en_US.UTF-8"

               SYSFONT="latarcyrheb-sun16"

    5、检查ulimit

       ulimit -a    #显示当前的各种用户进程限制

       ulimit -c unlimited    #设置core文件的最大值

       ulimit -SHn 100001   #-n 每个进程可以打开的最大文件数;-S 给指定资源设置软极限 

       vim /etc/profile 

         ulimit -c unlimited

         ulimit -SHn 100001

       vim /etc/security/limits.conf

     @users soft nofile 102400

     @users hard nofile 102400

     @root  soft nofile 102400

     @root  hard nofile 102400

       vim /etc/pam.d/login

        session required /lib/security/pam_limits.so

    6、检查防火墙和selinux

       chkconfig iptables on

       setenforce 0

       vim  /etc/selinux/config

            SELINUX=disabled

       vim /etc/sysconfig/iptables

       service iptables restart

       ufw enable

       ufw allow xxxx

     7、设置内核参数(sysctl -p 生效)

    vim /etc/sysctl.conf

    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 = 68719476736
    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.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_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 = 12000 65535
    vm.swappiness = 10

    8、重启服务器,检查之前改的有没有生效或者遗漏

  • 相关阅读:
    73. Set Matrix Zeroes (Array)
    79. Word Search (Array; DFS,Back-Track)
    59. Spiral Matrix II (Array)
    PAT 1082. Read Number in Chinese
    PAT 1067 Sort with Swap(0,*)
    LeetCode Min Stack
    LeetCode Find Minimum In Rotated Sorted Array
    PAT 1071. Speech Patterns
    PAT 1022. Digital Library
    PAT 1041. Be Unique
  • 原文地址:https://www.cnblogs.com/Christine-ting/p/10697680.html
Copyright © 2020-2023  润新知