天天看点

backlog配置_Linux Centos7 初始化配置脚本

安装Linux 操作系统之后,一般都会进行一个简单的初始化配置。我的这个脚本,一般是适合自己的一个配置,跟大家分享一下,具体个人的情况可以参考下面一些简单的介绍来进行修改。

#!/bin/bashif [ -n "$1" ] || [ -n "$2" ]then    idelse    echo "Usage: ./centosinit.sh newhostname whatfor"    exit 1fi#修改sshd_config的配置记录日志sed -i.orig '/#LogLevel INFO/aLogLevel VERBOSE' /etc/ssh/sshd_config#可以临时或者永久关闭firewalldsystemctl stop firewalld.servicesystemctl disable firewalld.servicep#自定义shell的历史记录cat << EOF >> /etc/profile.d/tx-history.shHISTTIMEFORMAT="%Y-%m-%d %H:%M:%S:::"export HISTTIMEFORMATexport HISTSIZE=100000export HISTFILESIZE=20000EOF#关闭selinxsed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config#设置主机名hostname "$1"hostnamectl set-hostname "$1"cat << EOF >> /etc/profile.d/tx-alias.shHOST="${2}"export PS1='[033[01;31m]$HOST[033[00m] [email protected]:w$ 'export GREP_OPTIONS='--color=auto'EOF#内核优化 可以根据个人情况参考来决定是否使用cat << EOF >> /etc/sysctl.conffs.file-max = 1491124net.ipv4.tcp_max_tw_buckets = 15000net.ipv4.conf.default.accept_source_route = 0net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_syncookies = 1net.ipv4.tcp_keepalive_probes = 3net.ipv4.tcp_keepalive_intvl = 15net.ipv4.tcp_max_syn_backlog = 8388608net.core.netdev_max_backlog = 8388608net.ipv4.tcp_keepalive_time = 3600net.ipv4.tcp_window_scaling = 0net.ipv4.tcp_sack = 0net.ipv4.tcp_timestamps = 0net.ipv4.ip_local_port_range = 1024 65000EOFsysctl -pcat << EOF >> /etc/security/limits.confroot hard nofile 204800root soft nofile 204800nginx hard nofile 204800nginx soft nofile 204800* hard nofile 204800* soft nofile 204800* soft noproc 204800* hard noproc 204800EOFecho "" > /etc/security/limits.d/90-nproc.confcat << EOF >> /etc/security/limits.d/90-nproc.conf* soft nproc 204800root soft nproc unlimitedEOF           

执行起来如下比如脚本命名是centosinit.sh赋予这个文件可执行权限,在root用户下执行即可

./centosinit.sh newhostname whatfor

8 2020-09-22 08:34:43:::./centosinit.sh parallels centos7

效果如下:

backlog配置_Linux Centos7 初始化配置脚本

centos7 [email protected]:~# pwd

/root

centos7 [email protected]:~# uname -a

Linux parallels 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux