搭建OceanBase集群时,主机数量还是挺多的。
为了降低搭建主机时的配置工作,把命令集中写了一个脚本,降低工作量。
#!/bin/bash
#changed ip address
OBSERVER=192.168.2.71
OCP=192.168.2.70
OBSERVER1=192.168.2.71
OBSERVER2=192.168.2.72
OBSERVER3=192.168.2.73
NETMASK=255.255.255.0
GATEWAY=192.168.2.254
DNS1=192.168.2.254
ifcfgname=ifcfg-ens192
##modify Network file
sed -i '$a IPADDR='${OBSERVER}'' /etc/sysconfig/network-scripts/${ifcfgname}
sed -i '$a NETMASK='${NETMASK}'' /etc/sysconfig/network-scripts/${ifcfgname}
sed -i '$a GATEWAY='${GATEWAY}'' /etc/sysconfig/network-scripts/${ifcfgname}
sed -i '$a DNS1='${DNS1}'' /etc/sysconfig/network-scripts/${ifcfgname}
sed -i 's/BOOTPROTO=dhcp/#BOOTPROTO=dhcp/g' /etc/sysconfig/network-scripts/${ifcfgname}
sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/${ifcfgname}
##modify Hosts file
sed -i '$a '${OCP}' ocp ocp' /etc/hosts
sed -i '$a '${OBSERVER1}' observer1 observer1' /etc/hosts
sed -i '$a '${OBSERVER2}' observer2 observer2' /etc/hosts
sed -i '$a '${OBSERVER3}' observer3 observer3' /etc/hosts
##Stop firewall
systemctl stop firewalld
systemctl disable firewalld
##modify selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
##restart
init 6