一.CDH简介
官网:https://www.cloudera.com/
CDH,全称Cloudera's Distribution, including Apache Hadoop。是Hadoop众多分支中对应中的一种,由Cloudera维护,基于稳定版本的Apache Hadoop构建,提供了Hadoop的核心(可扩展存储、分布式计算),最为重要的是提供基于web的用户界面。
优点:版本划分清晰,更新速度快,支持Kerberos安全认证,支持多种安装方式(如Yum、rpm等)。CDH分为Cloudera Manager管理平台和CDH parcel(parcel包含各种组件的安装包)。这里采用CM6.3.1(2019-10-11)和CDH6.3.2(2019-11-12更新)。
二.CDH三节点集群搭建环境配置准备
1.四台台机器配置及ip,
centos7.6 主节点 ip:192.168.37.101
centos7.6 从节点 ip:192.168.37.102
centos7.6 从节点 ip:192.168.37.103
单独分一台机器部署mysql
centos7.6 主节点 ip:192.168.37.107
2.修改主机名
hostnamectl set-hostname centos001
hostnamectl set-hostname centos002
hostnamectl set-hostname centos003
hostnamectl set-hostname centos007
3.关闭selinux,firewalld
(1)不重启的关闭 # setenforce 0 #重启电脑后失效
(2)重启电脑的关闭 # vi /etc/selinux/config
把SELINUX=enforce 改成disabled就可以了,#重启电脑,永久生效
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 禁用防火墙开机自启
4.三台主机添加hosts,好能相互解析
echo -e "192.168.37.101 centos001
192.168.37.102 centos002
192.168.37.103 centos003
" >> /etc/hosts
5.NTP时间同步
NTP安装
sudo yum -y install ntp
sudo /etc/ntp.conf
## 加入时间服务器:
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
PS: 或在https://www.pool.ntp.org/zone/asia找最适合的时间服务器
systemctl start ntpd.service 启动NTP时间服务器
systemctl enable ntpd.service 设置NTP开机自动启动
systemctl status ntpd.service 查看NTP是否正常运行
查看与时间同步服务器的时间偏差:ntpdc -c loopinfo
查看当前同步的时间服务器:ntpq -p
查看状态:ntpstat
6.三台机器相互免密
ssh-keygen && ssh-copy-id -i user@B
每个节点上执行:
ssh-keygen
ssh-copy-id -i root@centos001
ssh-copy-id -i root@centos002
ssh-copy-id -i root@centos003
7.安装JDK(所有节点)
注意:CDH的安装 要求使用指定版本的oracle-j2sdk1.8
查询是否有已经安装的jdk
rpm -qa | grep java
如果之前安装过Java组件,先将其卸载
yum remove java* -y
上传安装包 oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm 到/soft/download目录
启动安装
rpm -ivh oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm
查找jdk安装路径
find / -name java
配置环境变量
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
source /etc/profile
验证java -version
8.各节点安装mysql驱动
下载jdbc依赖,上传JDBC依赖包(所有节点)
mysql-connector-java-8.0.12.jar
创建目录mkdir -p /usr/share/java
上传mysql-connector-java-8.0.12.jar包
重命名 mv mysql-connector-java-8.0.12.jar mysql-connector-java.jar
三.安装CDH三节点集群
1.主节点安装Apache Httpd服务
安装启动
yum install httpd -y
systemctl start httpd
systemctl enable httpd
2.安装mysql
可参考:https://www.cnblogs.com/pinghengxing/p/9402825.html
3.创建数据库
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 rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hive DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hbase DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE monitor DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
4.配置Cloudera Manager安装包yum源(master节点,此集群中为centos001,centos002和centos003要配置该源)
创建目录(master节点)
mkdir -p /var/www/html/cloudera-repos/cm6
cdh6.3.2的下载地址:
链接: https://pan.baidu.com/s/16Hw38qZfLGZzLsrtHDWwhg 提取码: w1h2 复制这段内容后打开百度网盘手机App,操作更方便哦
--来自百度网盘超级会员v2的分享
将下载好的rmp安装包上传到(其中CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1 需去掉最后的1)
/var/www/html/cloudera-repos/cm6
创建仓库(master节点)
cd /var/www/html/cloudera-repos/cm6
yum install -y createrepo
createrepo .
创建repo文件(所有节点)
vi /etc/yum.repos.d/cloudera-manager.repo
[cloudera-manager]
name=Cloudera Manager 6.3.1
baseurl=http://centos001/cloudera-repos/cm6
#gpgkey=https://archive.cloudera.com/cm6/6.3.1/redhat7/yum/RPM-GPG-KEY-cloudera
gpgcheck=0
enabled=1
#autorefresh=0
#type=rpm-md
清理并缓存(所有节点):更新yum源
yum clean all
yum makecache
yum repolist
5.安装 Cloudera Manager(master节点)
执行安装
yum install -y cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
安装完CM后/opt/ 下会出现cloudera目录
6,执行CM初始化脚本
mysql数据库与CM Server是同一台主机
执行命令:/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm root 123456
mysql数据库与CM Server不在同一台主机上
执行命令:
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql -h192.168.37.107 -P3306 scm root PHXwlj.19901022
7.启动cm
systemctl start cloudera-scm-server.service
systemctl stop cloudera-scm-server.service
systemctl status cloudera-scm-server.service
systemctl enable cloudera-scm-server.service
sudo tail -100f /var/log/cloudera-scm-server/cloudera-scm-server.log
登陆
http://192.168.37.101:7180
admin/admin/
8.手动安装cloudera-manager-agent,在两台从机上安装(也可以通过管理界面安装cloudera-manager-agent)
yum install cloudera-manager-daemons cloudera-manager-agent -y
yum install cloudera-manager-agent -y
vi /etc/cloudera-scm-agent/config.ini
# 将server_host修改为CM-Server所在的主机名
server_host=centos001
systemctl start cloudera-scm-agent
systemctl status cloudera-scm-agent
systemctl stop cloudera-scm-agent
systemctl enable cloudera-scm-agent
tail -100f /var/log/cloudera-scm-agent/cloudera-scm-agent.log