前期准备
1 最小化安装CentOS7.9(其他系统也可以)
2 配置系统
2.2 hostname及hosts配置(每个节点执行)
hostnamectl set-hostname ds1
cat >> /etc/hosts << EOF
192.168.42.201 ds1
192.168.42.202 ds2
192.168.42.203 ds3
EOF
2.3 配置ssh互相(每个节点执行)
cat /etc/ssh/sshd_config
PasswordAuthentication yes
ChallengeResponseAuthentication no
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
ssh-copy-id root@ds1
ssh-copy-id root@ds2
ssh-copy-id root@ds3
2.4 关闭防火墙及selinux(每个节点执行)
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.5 卸载自带的mariadb(每个节点执行)
yum -y remove mariadb-*
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /usr/lib/firewalld/services/mysql.xml
rm -rf /usr/lib64/mysql
2.6 时钟同步chrony配置(主节点和其他节点配置不同)
2.6.1 主节点配置
sed -i '/server /d' /etc/chrony.conf
sed -i "/# Please/a server ntp1.aliyun.com iburst" /etc/chrony.conf
sed -i "/#allow/a allow 0.0.0.0/0" /etc/chrony.conf
sed -i 's/#local/local/g' /etc/chrony.conf
systemctl restart chronyd
chronyc -a makestep
chronyc sources -v
2.6.2 其他节点配置(除主节点外的其他所有节点)
sed -i '/server /d' /etc/chrony.conf
sed -i "/# Please/a server ds1 iburst" /etc/chrony.conf
systemctl restart chronyd
chronyc -a makestep
chronyc sources -v
3 安装JDK并添加到PATH
3.1 安装JDK(主节点执行)
mkdir /usr/java
tar -zxvf /root/softPkg/jdk-8u221-linux-x64.tar.gz -C /usr/java/
scp -r /usr/java root@ds2:/usr
scp -r /usr/java root@ds3:/usr
3.2 配置JDK环境变量(每个节点执行)
cat >> /etc/profile << EOF
#JDK env
export JAVA_HOME=/usr/java/jdk1.8.0_221
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
export PATH=\$JAVA_HOME/bin:\$PATH
EOF
source /etc/profile
java -version