zoukankan      html  css  js  c++  java
  • 新建linux服务器初始化操作

    1.关闭不需要的服务

    首先确定服务器有没有ntsysv命令,如果没有的话,直接使用yum安装即可。

    使用ntsysv关闭不需要的服务以节省服务器资源

    需要打开的服务如下:

    crond:周期性计划任务

    network:linux网络服务

    sshd:OpenSSH服务守护进程

    rsyslog:linux日志系统服务

    2.关闭不需要的TTY

    centos 7已经默认启用一个TTY,如果使用centos 6系统修改建议参考  https://antoinemaze.wordpress.com/2014/02/26/modify-the-number-of-tty-in-centos-6/

    3.对TCP/IP网络参数进行调整

    echo 'net.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf

    sysctl -p

    4.修改SHELL命令的histor记录数

    vim /etc/profile

    HISTSIZE=1000

    根据工作情况而定,修改完成后执行以下命令

    source /etc/profile = . /etc/profile

    5.定时校正服务器时间

    yum -y install ntp

    crontab -e 

    */5 * * * * /usr/sbin/ntpdate ntp.api.bz

    6.关闭vip6网络服务

    ifconfig 

    echo "install vip6 /bin/true" > /etc/modprobe.d/disable-vip6.conf

    #每当系统需要加载vip6模块时,强制执行/bin/true来代替实际加载的模块

    echo "IPV6INIT=no" >> /etc/sysconfig/network-scripts/ifcfg-eth0

    7.调整linux的最大打开文件数

    ulimit -n  查看当前打开的最大的文件数

    修改配置文件

    vim /etc/security/limit.conf

    soft nofile 65535

    hard nofile 65535

    还需要在系统的/etc/rc.local文件里添加如下内容:

    ulimit -SHn 65535

    8.关闭写磁盘I/O功能

    加入此台服务器是一台web服务器,而这台服务器上包含很多的图片文件,那么我们是不需要记录这些小文件的访问时间的,这样的话就可以节省磁盘的I/O

    修改系统配置文件/etc/fstab,在包含大量的小文件的分区中使用noatime和nodiratime

    /dev/sda5 /data/pics ext3 noatime,nodiartime 0 0

    9.配置SSH登录

    修改/etc/ssh/sshd_config

    禁止使用root用户登录

    禁止使用空密码登录

    关闭SSH反向查询

    10.设置用户sudo权限

    对于经常需要管理员权限的用户进行设置,修改/etc/sudoers或者使用visudo命令

    admin ALL=(ALL) NOPASSWD:ALL

  • 相关阅读:
    git ssh配置
    spring事务的传播行为
    springboot tomcat启动
    error while loading shared libraries: libstdc++.so.6: cannot open shared object file
    centos7安装nginx1
    linux jdk 配置
    NET CORE 3.1 UPLOAD
    vue table formrt datetime languer
    net core 3.1 swagger
    css
  • 原文地址:https://www.cnblogs.com/Cherry-Linux/p/7361175.html
Copyright © 2011-2022 走看看