centos安装ambari前初始化服务器脚本
复制脚本内容后,根据实际情况修改部分参数,配置完成后将自动重启
#!/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 EOF chmod +x /etc/rc.d/rc.local #设置hosts,一般集群内有多台服务器,多个自行添加指令 echo ‘192.168.230.1 nd1 nd1.hdp’ >> /ect/hosts echo ‘192.168.230.* nd8 nd*.hdp’ >> /ect/hosts hostnamectl set-hostname nd1.hdp #修改yum镜像源 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 #安装时间同步 yum install -y ntp systemctl start ntpd.service systemctl enable ntpd.service #配置JDK #tar包或rpm安装,另行单独安装,安装完成后记录位置,后面要用 echo ‘export JAVA_HOME=/usr/java/jdk1.8.0_202’ >> /etc/profile echo ‘export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar’ >> /etc/profile echo ‘export PATH=$PATH:$JAVA_HOME/bin’ >> /etc/profile source /etc/profile #修改文件打开限制 cat >> /etc/security/limits.conf <<'EOF' * soft nofile 65535 * hard nofile 65535 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 = 94500000 915000000 927000000 EOF /sbin/sysctl -p
#重启
reboot
转载请注明“转载”
原创地址:https://www.cnblogs.com/beiguapipi/