集群环境系统配置
参考链接:集群环境搭建-系统配置
术语解释
为了方便阅读理解,规范以下术语
- 主节点:master节点
- 非主节点:worker节点
上传文件
- 文件链接: CDH安装文件
提取码:un3w - 文件列表
- 将文件列表中的文件上传到master节点
为了后面便于说明,我上传到了/root/auto-cdh/softPKG目录下,和上图所示的一致
安装MySQL数据库
- 卸载Mariadb
CentOS7.9默认自带Mariadb,查看并卸载 master节点必须执行,worker节点非必须
rpm -qa | grep -i mariadb
yum -y remove mariadb-*
- 删除mariadb和mysql的残留文件
master节点必须执行,worker节点非必须
find / -iname mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /usr/lib/firewalld/services/mysql.xml
rm -rf /usr/lib64/mysql
- 安装MySQL
master节点执行
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql-server
systemctl start mysqld
systemctl enable mysqld
- 初始化MySQL
grep 'temporary password' /var/log/mysqld.log | cut -d " " -f11
mysql_secure_installation
5. 配置mysql的root用户可远程访问,并创建cm各个组件所需的数据库
mysql -uroot -ppwd <<EOF
grant all privileges on *.* to 'root' @'%' identified by 'pwd';
flush privileges;
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hive DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
exit
EOF
安装JDK
在所有节点都安装 说明:CDH6.3.2依赖JDK1.8,官方推荐使用1.8.0_181,测试发现1.8.0_221也可以,所以介绍两种安装方法,任选一种即可
if [[ ! -d /usr/java ]];then
mkdir /usr/java
fi
tar -zxvf /root/auto-cdh/softPKG/jdk-8u221-linux-x64.tar.gz -C /usr/java/
scp -P 20885 -r /usr/java root@dbnode2:/usr
scp -P 20886 -r /usr/java root@dbnode3:/usr
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
rpm -ivh /root/auto-cdh/softPKG/cm/cm6.3.0/RPMS/x86_64/oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm
if [[ ! -d /usr/java ]];then
mkdir /usr/java
fi
scp -P 20885 -r /usr/java root@dbnode2:/usr
scp -P 20886 -r /usr/java root@dbnode3:/usr
cat >> /etc/profile << EOF
#JDK env
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
export PATH=\$JAVA_HOME/bin:$PATH
EOF
source /etc/profile
安装Cloudera Manager (CM)
- 创建CDH的yum仓库
在master节点使用python2启动一个HTTP服务
cd /root/auto-cdh/softPKG
nohup python -m SimpleHTTPServer 8900 > /dev/null 2>&1 &
- 配置yum源
在所有节点上都执行
cat >> /etc/yum.repos.d/cloudera-manager.repo << EOF
[cloudera-manager]
name=cloudera-manager
baseurl=http://dbnode1:8900/cm/cm6.3.0
gpgkey=https://archive.cloudera.com/cm6/6.3.0/redhat7/yum/RPM-GPG-KEY-cloudera
gpgcheck=0
enabled=1
autorefresh=0
type=rpm-md
EOF
- 安装Cloudera Manager (CM)
yum -y install cloudera-manager-server cloudera-manager-agent cloudera-manager-daemons
yum -y install cloudera-manager-agent cloudera-manager-daemons
- 配置cloudera-scm-agent
在所有节点上都执行
sed -i 's/^server_host=.*/server_host=dbnode1/' /etc/cloudera-scm-agent/config.ini
- 初始化Cloudera Manager (CM)数据库
if [[ ! -d /usr/share/java ]];then
mkdir /usr/share/java
fi
scp -P 20884 /root/auto-cdh/softPKG/mysql-connector-java.jar root@dbnode1:/usr/share/java
scp -P 20885 /root/auto-cdh/softPKG/mysql-connector-java.jar root@dbnode2:/usr/share/java
scp -P 20886 /root/auto-cdh/softPKG/mysql-connector-java.jar root@dbnode3:/usr/share/java
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm root pwd
启动CM服务
在所有节点执行
- 编写集群启动脚本
cat >> /usr/bin/xcall.sh << EOF
#!/bin/bash
#cm启动脚本
ssh -p 20884 dbnode1 "\$*"
ssh -p 20885 dbnode2 "\$*"
ssh -p 20886 dbnode3 "\$*"
EOF
chmod 755 /usr/bin/xcall.sh
- 启动CM服务
systemctl start cloudera-scm-server
xcall.sh systemctl start cloudera-scm-agent
- 关闭CM服务
xcall.sh systemctl stop cloudera-scm-agent
systemctl stop cloudera-scm-server
4.查看服务日志
tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
|