centos server initialization script before installing ambari

After you copy the contents of the script, modify some parameters according to the actual situation, the configuration will automatically restart

#!/bin/bash
#关闭防火墙、selinux、关闭开机自启,关闭THP服务:
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g'  /etc/selinux/config
cat >> /etc/rc.d/rc.local <<’EOF’

if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/redhat_transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
Fi
The EOF 
the chmod + X /etc/rc.d/ the rc.local 

# Set the hosts, multiple servers within a cluster in general, add their own instructions plurality of 
echo '192.168.230.1 ND1 nd1.hdp' >> / ECT / the hosts 
echo '192.168 .230. * * Nd ND8 .hdp '>> / ECT / the hosts 

hostnamectl SET-hostname nd1.hdp 
# modify yum mirroring 
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos. D / CentOS- Base.repo.backup 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7 .repo 
yum makecache 
# installation time synchronization 
yum install - the y-ntp 
systemctl Start ntpd.service 
systemctl enable ntpd.service 
# configure the JDK 
#tar package or rpm installed separately installed separately, after the installation is complete recording position used later 
echo 'Export the JAVA_HOME = /usr/java/jdk1.8.0_202 ' >> / etc / Profile 
echo 'Export the CLASSPATH = .: $ the JAVA_HOME / JRE / lib / rt.jar: $ the JAVA_HOME /lib/dt.jar: $ the JAVA_HOME /lib/tools.jar '>> / etc / Profile 
echo' Export the PATH = $ the PATH : $ the JAVA_HOME / bin '>> / etc / Profile 
Source / etc / Profile
 # modify the file open limit 
CAT >> / etc / Security / limits.conf << 'EOF'
 * Soft nofile 65535 
* 65535 Hard nofile 
EOF 
CAT > /etc/security/limits.d/20-nproc.conf <<'EOF'
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
#nproc
*          soft    nproc     65535
root       soft    nproc     unlimited
*          hard    nproc     65535
root       hard    nproc     unlimited
EOF
cat >> /etc/systemd/system.conf <<'EOF'
DefaultLimitCORE=infinity
DefaultLimitNOFILE=100000
DefaultLimitNPROC=100000
EOFcat >>  /etc/systemd/user.conf <<'EOF'
DefaultLimitCORE=infinity
DefaultLimitNOFILE=100000
DefaultLimitNPROC=100000
EOF
source /etc/profile
#优化网络配置
cat >> /etc/sysctl.conf <<'EOF'
net.ipv4.ip_forward = 1
#net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.route.gc_timeout = 20
net.ipv4.ip_local_port_range = 1025 65535
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_max_tw_buckets = 200000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_wmem = 8192 131072 16777216
net.ipv4.tcp_rmem = 32768 131072 16777216
net.ipv4.tcp_mem = 915 000 000 927 000 000 94.5 million 
the EOF
 / sbin / sysctl -p 
# restart
reboot

Guess you like

Origin www.cnblogs.com/beiguapipi/p/11233680.html