参考
https://www.cmgine.com/archives/19130.html
https://segmentfault.com/a/1190000012540680
https://segmentfault.com/a/1190000011341408#articleHeader5
环境说明
- Cloudera Manager:5.13.2
- CDH: 5.13.2
- CentOS 7.3 x64
- JDK 1.8.0_152
- MySQL 5.7.20
相关下载
下载信息: https://www.cloudera.com/downloads/manager/5-13-2.html
所有节点下载文件均放在/data/software
所有机器上 mkdir -p /data/software
- CM安装包(主节点)
http://archive.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.13.2_x86_64.tar.gzhttp://archive.cloudera.com/cdh5/parcels/5.13.2/CDH-5.13.2-1.cdh5.13.2.p0.3-el7.parcelhttp://archive.cloudera.com/cdh5/parcels/5.13.2/CDH-5.13.2-1.cdh5.13.2.p0.3-el7.parcel.sha1http://archive.cloudera.com/cdh5/parcels/5.13.2/manifest.json
- Mysql安装包及JDBC驱动(主节点)
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.21-1.el7.x86_64.rpmhttps://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.21-1.el7.x86_64.rpmhttps://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.21-1.el7.x86_64.rpmhttps://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.21-1.el7.x86_64.rpmhttp://ftp.ntu.edu.tw/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.45.tar.gz
配置环境
1. 网络配置 (所有节点)
- 修改主机名, 切记主机名不能出现下划线
修改主机名(/etc/hostname):
hostnamectl set-hostname cdh-master
hostnamectl set-hostname cdh-slave1
hostnamectl set-hostname cdh-slave2
hostnamectl set-hostname cdh-slave3
修改 /etc/sysconfig/network, 使之生效 source /etc/sysconfig/network:vi /etc/sysconfig/networkNETWORKING=yesHOSTNAME=cdh-xxx
- 修改 /etc/hosts 加入
vi /etc/hosts
10.104.199.179 cdh-master10.104.5.85 cdh-slave110.104.35.19 cdh-slave210.135.69.214 cdh-slave3
- 重启网络
service network restart
2. 打通SSH,设置ssh无密码登陆, 集群内节点能够互相无密码访问 (所有节点)
- 在所有节点上执行
ssh-****** -t rsa 一路回车,生成无密码的**对。将公钥添加到认证文件中:cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys设置authorized_keys的访问权限:chmod 600 ~/.ssh/authorized_keys
- 在所有其他节点加入节点~/.ssh/authorized_keys的内容:
vi ~/.ssh/authorized_keys
- 测试
在任何一个节点上ssh 其他节点都不需要密码就能直接登陆进去了。
3. 安装Oracle的Java(所有节点)
- 卸载自带的OpenJdk
rpm -qa | grep java 查询java相关的包rpm -e java*** --nodeps #根据查找到的软件包信息卸载
- 安装OracleJDK
1) 下载安装包:curl -L "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux- x64.rpm" -H "Cookie: oraclelicense=accept-securebackup-cookie" -H "Connection: keep-alive" -O2) 使用如下命令安装:rpm -ivh jdk-8u161-linux-x64.rpm
- 配置环境变量
vi /etc/profile , 增加如下内容:
JAVA_HOME=/usr/java/jdk1.8.0_161JRE_HOME=/usr/java/jdk1.8.0_161/jrePATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libexport JAVA_HOME JRE_HOME PATH CLASSPATH# source /etc/profile
注意,如果安装路径不是/usr/java下面,后面CDH页面操作的时候会报错找不到JAVA_HOME,所以请按Oracle Java的标准路劲存放JAVA_HOME
4. 安装配置MySql(主节点)
安装步骤:1)此处需要注意的是centos 7 默认安装的是mariadb,如果不卸载直接安装的话会报错,报错信息mariadb-libs is obsoleted by mysql-community-libs-5.7.9-1.el7.x86_64rpm -qa | grep mariadb #查看安装信息rpm -e mariadb-libs* --nodeps #根据查找到的软件包信息卸载2)安装MySQL(必须按以下顺序安装)rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm# 如果出现以下错误,请先安装libnuma[[email protected] data]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpmwarning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: Failed dependencies:libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64[[email protected] data]# yum install libnuma*3)基本设置#启动服务
service mysqld startvim /var/log/mysqld.log #查看初始密码mysql -uroot -p #登录set password = password(‘Root123!!!') #设置密码或者 UPDATE user SET authentication_string=PASSWORD('Root123!!!') where USER='root';#授权用户root使用密码passwd从任意主机连接到mysql服务器GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root123!!!' WITH GRANT OPTION;flush privileges;
4)建数据库(用于后边组件安装)create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
5. 关闭防火墙和SELinux (所有节点)
注意:需要在所有的节点上执行,因为涉及到的端口太多了,临时关闭防火墙是为了安装起来更方便,安装完毕后可以根据需要设置防火墙策略,保证集群安全。
- 关闭防火墙:
systemctl stop firewalld.service; systemctl disable firewalld.servicefirewall-cmd --state
- 关闭SELINUX(实际安装过程中发现没有关闭也是可以的,不知道会不会有问题,还需进一步进行验证):
/usr/sbin/sestatus -vsetenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
6. 配置NTP服务 (所有节点)
集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。 具体思路如下:
master节点作为ntp服务器与外界对时中心同步时间,随后对所有datanode节点提供时间同步服务。所有datanode节点以master节点为基础同步时间。
- 安装NTP (所有节点)
yum install ntp //安装NTPsystemctl start ntpd.service; systemctl enable ntpd.service // 启动NTP, 加入开机启动systemctl status ntpd.service // 查看NTP状态systemctl is-enabled ntpd.service // NTP是否开机启动
使用ntpdate手动同步一下时间, 并检查ntp的状态:# ntpdate -u pool.ntp.org# ntpstatsynchronised to NTP server (108.59.2.24) at stratum 3 time correct to within 1375 ms polling server every 64 s
正式开工
1. 安装Cloudera Manager Server 和Agent
- 解压CM压缩包, 并移到/opt(CM的目录默认位置在/opt)(主节点)
cd /data/software
tar zxvf cloudera-manager-centos7-cm5.13.2_x86_64.tar.gz
mv cloudera cm-5.13.2 /opt
- Mysql驱动放到cm的lib下(主节点)
tar zxvf mysql-connector-java-5.1.45.tar.gz
mkdir -p /usr/share/java/
cp mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar /usr/share/java/mysql-connector-java.jar
cp mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar /opt/cm-5.13.2/share/cmf/lib/
- 初始化CM5的数据库(主节点)
/opt/cm-5.13.2/share/cmf/schema/scm_prepare_database.sh mysql -uroot -p scm scm
查看配置文件,发现信息已写入:/opt/cm-5.13.2/etc/cloudera-scm-server/db.properties
- Agent配置(主节点)
# vim /opt/cm-5.13.2/etc/cloudera-scm-agent/config.ini
server_host=cdh-master
cloudera_mysql_connector_jar=/usr/share/java/mysql-connector-java.jar
scp -r /opt/cm-5.13.2 [email protected]:/opt/
scp -r /opt/cm-5.13.2 [email protected]:/opt/
- 创建cloudera-scm用户(所有节点)
useradd --system --home=/opt/cm-5.13.2/run/cloudera-scm-server/ --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
- 准备Parcels(主节点)
mkdir -p /opt/cloudera/parcel-repo/
cp /data/CDH-5.13.2-1.cdh5.13.2.p0.3-el7.parcel /opt/cloudera/parcel-repo/cp /data/CDH-5.13.2-1.cdh5.13.2.p0.3-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.13.2-1.cdh5.13.2.p0.3-el7.parcel.shacp /data/manifest.json /opt/cloudera/parcel-repo/
- 启动相关脚本
/opt/cm-5.13.2/etc/init.d/cloudera-scm-server start (主节点)/opt/cm-5.13.2/etc/init.d/cloudera-scm-agent start (所有节点)同样可以使用stop, restart
CDH5安装配置
1. 登录http://111.230.110.60:7180/cmf/login, 用户名和密码是 admin/admin
2. 选择需要部署的版本
3. 选择Current Managed Hosts, 包含主从所有节点
4. 选择包名, 出现以下包名,说明本地Parcel包配置无误,直接点继续就可以了
5. 群集安装–安装指定parcel
这里第一个和第二个警告,按页面提示的设置方法设置即可
每个节点上都设置一下:
执行:`echo 10 > /proc/sys/vm/swappiness`
并编辑文件sysctl.conf:`vim /etc/sysctl.conf`,添加或修改vm.swappiness = 0
执行:
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
并编辑文件rc.local :`vim /etc/rc.local`, 把上面两条语句加入到 rc.local
点击 Run Again, 检查都通过后点击 Finish
遇到的坑
1. Unexpected error. Unable to verify database connection 错误, 由于缺少libxslt库
下载安装
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
yum install libxslt-devel.x86_64
yum install libxslt-python.x86_64
2. Hue 的 Load Balancer 报 Critical Issue: This role's process failed to start.
看日志/opt/cm-5.13.2/run/cloudera-scm-agent/process/117-hue-HUE_LOAD_BALANCER/logs/stderr.log
如果是没有 HTTPD 则:
yum install httpd
如果是 mod_ssl.so: cannot open shared object file, 则:
yum install mod_ssl