暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

openGauss运行环境初始化脚本

1942

        在直播openGauss训练营后,有部分朋友私下找我要当时执行环境初始化的脚本。其实我的这个脚本比较简单,算是所有shell操作的简单集合吧,在这里贴出来,供需要的小伙伴复制粘贴,提高大家安装openGauss的效率。

#!/bin/bash ##Configure Linux environment For openGauss ## 1.Configure Hosts File hostnamectl set-hostname prod.opengauss.com sed -i '/192.168.0.21/d' /etc/hosts echo "192.168.0.21 prod.opengauss.com #Gauss OM IP Hosts Mapping" >> /etc/hosts cat /etc/hosts echo "1.Configure /etc/hosts completed." echo -e "\n" ## 2.Disable firewalld service systemctl disable firewalld.service systemctl stop firewalld.service echo "Firewalld " `systemctl status firewalld|grep Active` echo "2.Disable firewalld service completed." echo -e "\n" ## 3.Disable SELINUX sed -i '/^SELINUX=/d' /etc/selinux/config echo "SELINUX=disabled" >> /etc/selinux/config cat /etc/selinux/config|grep "SELINUX=disabled" echo "3.Disable SELINUX completed." echo -e "\n" ## 4.Configure encoding echo "LANG=en_US.UTF-8" >> /etc/profile source /etc/profile echo $LANG echo "4.Configure encoding completed." echo -e "\n" ## 5. Configure Timezone rm -fr /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime date -R hwclock echo "5.Configure Timezone completed." echo -e "\n" ## 6. Turn off SWAP sed -i '/swap/s/^/#/' /etc/fstab swapoff -a free -m echo "6.Close swap partition completed." echo -e "\n" ## optional options,please take care of this ## echo "MTU=8192" >> /etc/sysconfig/network-scripts/ifcfg-ens34 ## For 10GB Ethernet environment , please set rx = 4096、tx = 4096 ## 7. Configure SSH Service sed -i '/Banner/s/^/#/' /etc/ssh/sshd_config sed -i '/PermitRootLogin/s/^/#/' /etc/ssh/sshd_config echo -e "\n" >> /etc/ssh/sshd_config echo "Banner none " >> /etc/ssh/sshd_config echo "PermitRootLogin yes" >> /etc/ssh/sshd_config cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRoot|Banner' echo "7.Configure SSH Service completed." echo -e "\n" ## 8. Configure YUM and Install Packages mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/ wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo yum clean all yum install -y bzip2 python3 yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel echo "8.Configure YUM and Install Packages completed." echo -e "\n" ## 9. Configure sysctl.conf cat >> /etc/sysctl.conf << EOF net.ipv4.tcp_max_tw_buckets = 10000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_keepalive_time = 30 net.ipv4.tcp_keepalive_probes = 9 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.tcp_retries1 = 5 net.ipv4.tcp_syn_retries = 5 net.ipv4.tcp_synack_retries = 5 net.sctp.path_max_retrans = 10 net.sctp.max_init_retransmits = 10 net.ipv4.tcp_retries2 = 12 vm.overcommit_memory = 0 net.ipv4.tcp_rmem = 8192 250000 16777216 net.ipv4.tcp_wmem = 8192 250000 16777216 net.core.wmem_max = 21299200 net.core.rmem_max = 21299200 net.core.wmem_default = 21299200 net.core.rmem_default = 21299200 net.ipv4.ip_local_port_range = 26000 65535 net.ipv4.ip_local_reserved_ports = 20050-26007 kernel.sem = 250 6400000 1000 25600 vm.min_free_kbytes = 400428 ##suggest to set as physical memory * 5% net.core.somaxconn = 65535 net.ipv4.tcp_syncookies = 1 net.core.netdev_max_backlog = 65535 net.ipv4.tcp_max_syn_backlog = 65535 net.ipv4.tcp_fin_timeout = 60 kernel.shmall = 1152921504606846720 kernel.shmmax = 18446744073709551615 net.ipv4.tcp_sack = 1 net.ipv4.tcp_timestamps = 1 vm.extfrag_threshold = 500 vm.overcommit_ratio = 90 EOF sysctl -p echo "9.Configure sysctl.conf completed." echo -e "\n" ## 10. Configure resource limits echo "* soft stack 3072" >> /etc/security/limits.conf echo "* hard stack 3072" >> /etc/security/limits.conf echo "* soft nofile 1000000" >> /etc/security/limits.conf echo "* hard nofile 1000000" >> /etc/security/limits.conf echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf tail -n 4 /etc/security/limits.conf tail -n 1 /etc/security/limits.d/90-nproc.conf echo "10.Configure resource limits completed." echo -e "\n" ## 11. Close transparent_hugepage ################Only for CentOS [Close transparent_hugepage]##################### cat >>/etc/rc.d/rc.local<<EOF if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi EOF chmod +x /etc/rc.d/rc.local ## [可选]方法二: ## sed -i '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub ## echo "GRUB_CMDLINE_LINUX=\"rhgb quiet transparent_hugepage=never\"" >> /etc/default/grub ## grub2-mkconfig -o /boot/grub2/grub.cfg ## echo "11.Close transparent_hugepage completed." echo -e "\n" ################################################################################ ################Only for openEuler[Disable RemoveIPC]##################### ## sed -i '/^RemoveIPC/d' /etc/systemd/logind.conf ## sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service ## echo "RemoveIPC=no" >> /etc/systemd/logind.conf ## echo "RemoveIPC=no" >> /usr/lib/systemd/system/systemd-logind.service ## systemctl daemon-reload ## systemctl restart systemd-logind ## loginctl show-session | grep RemoveIPC ## systemctl show systemd-logind | grep RemoveIPC ## echo "12.Disable RemoveIPC completed." ## echo -e "\n" ## echo -e "\n" ##########################################################################
最后修改时间:2021-04-01 19:25:13
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论