天天看點

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