参考
- Cloudera Enterprise 5.16.x
- Installing Cloudera Manager, CDH, and Managed Services
- Installation Path B - Manual Installation Using Cloudera Manager Packages
一. 环境
1.1 系统节点信息
Hostname | IP | CPU(cores) | Memory(GB) | OS | Service | Remark |
---|---|---|---|---|---|---|
master | 172.30.200.75 | 2 | 4 | centos 7.5 | jdk, cloudera-scm-server, mysql | 实际部署后,master节点也需要部署cloudera-scm-agent 服务,或采用4个slave节点 |
slave01 | 172.30.200.76 | 2 | 4 | centos 7.5 | jdk, cloudera-scm-agent | |
slave02 | 172.30.200.77 | 2 | 4 | centos 7.5 | jdk, cloudera-scm-agent | |
slave03 | 172.30.200.78 | 2 | 4 | centos 7.5 | jdk, cloudera-scm-agent |
1.2 软件版本
相关软件放置在/usr/local/src/
目录。
Soft | Version | Download | Remark |
---|---|---|---|
CM(Cloudera Manager) | cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz |
bin包,根据版本下载 | |
CDH parcel | CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel |
根据版本下载 | 软件安装包 |
CDH parcel.sha | CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1 |
根据版本下载 | 软件包hash码 |
CDH manifest.json | manifest.json |
根据版本下载 | 版本说明文件 |
JDK | jdk-8u181-linux-x64.tar.gz |
bin包,根据版本下载 | |
MySQL | mysql-5.7.24-el7-x86_64.tar.gz |
bin包,根据版本下载 | 存放Cloudera Manager配置文件 |
MySQL-connector-Java | mysql-connector-java-8.0.13.jar |
jar包,根据版本下载 | JDBC |
二. 准备工作
2.1 部分预配置
所有节点执行以下操作:
- 永久关闭防火墙(
firewalld
或iptables
); - 永久关闭
selinux
; - 设置
ntp
。
2.2 设置hosts
- 所有节点设置/etc/hosts
cat << EOF >> /etc/hosts # hadoop nodes 172.30.200.75 master 172.30.200.76 slave01 172.30.200.77 slave02 172.30.200.78 slave03 EOF
2.3 免密访问设置
-
在所有节点生成秘钥
ssh-keygen -t rsa
-
在master节点生成
authorized_keys
文件cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
-
在master节点执行,将集群每个节点的公钥
id_rsa.pub
放入master节点的authorized_keys
文件中for i in {1..3}; do ssh root@slave0$i cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys; done
-
在master节点执行,将master节点的
authorized_keys
文件放置到集群每个节点的/root/.ssh/
目录,依然命名位authorized_keys
- 最终的效果是集群中所有节点两两相互免密访问;
- 注意:首次登陆时有
公钥检查
,可通过在/etc/ssh/ssh_config
文件中设置StrictHostKeyChecking no
绕过,或使用-o
参数跳过。
for i in {1..3}; do scp /root/.ssh/authorized_keys root@slave0$i:/root/.ssh/authorized_keys; done
2.4 安装JDK
所有节点都需要安装JDK。
-
安装JDK
cd /usr/local/src tar -zxvf jdk-8u181-linux-x64.tar.gz mkdir -p /usr/java mv jdk1.8.0_181/ /usr/java/ # 设置软链接,方便升级替换 ln -s /usr/java/jdk1.8.0_181/ /usr/java/current
-
设置变量
cat << EOF >> /etc/profile # JDK export JAVA_HOME=/usr/java/current export JRE_HOME=/usr/java/current/jre export PATH=$PATH:/usr/java/current/bin export CLASSPATH=./:/usr/java/current/lib:/usr/java/current/jre/lib EOF
-
验证
# 加载变量 source /etc/profile # 验证 java -version
2.5 安装MySQL
只有master节点需要安装MySQL。
-
卸载系统自带的相关数据库
rpm -qa | grep mysql rpm -qa | grep mariadb # --nodeps:不检查依赖 rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
-
部署MySQL
# 采用bin包部署,解压后直接使用 cd /usr/local/src tar -zxvf mysql-5.7.24-el7-x86_64.tar.gz -C /usr/local/ mv /usr/local/mysql-5.7.24-el7-x86_64/ /usr/local/mysql
-
账号与权限
# 添加账号 groupadd mysql useradd -g mysql -s /sbin/nologin mysql # 创建"data"目录 mkdir /data # 赋权 chown -R mysql:mysql /usr/local/mysql/ chown -R mysql:mysql /data/
-
初始化MySQL
- 获取
root@localhost
账号的初始密码Hqe6x<Re4jhK
cd /usr/local/mysql/ bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data
- 获取
-
设置变量
cat << EOF >> /etc/profile # MySQL export PATH=$PATH:/usr/local/mysql/bin EOF # 加载变量 source /etc/profile # 软链接 ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql
-
设置开机启动
# 复制开机启动脚本到系统服务 cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chown mysql:mysql /etc/rc.d/init.d/mysqld # 修改默认的"basedir"与"datadir" vim /etc/rc.d/init.d/mysqld basedir=/usr/local/mysql datadir=/data # 添加开机启动脚本 chkconfig --add mysqld chkconfig --level 35 mysqld on
-
文件路径:log && pid && socket
# 日志路径 mkdir -p /var/log/mysqld touch /var/log/mysqld/mysqld.log chown -R mysql:mysql /var/log/mysqld/ # pid路径 mkdir -p /var/run/mysqld chown -R mysql:mysql /var/run/mysqld/ # socker路径 mkdir -p /var/lib/mysqld chown -R mysql:mysql /var/lib/mysqld/ ln -s /var/lib/mysqld/mysql.sock /tmp/mysql.sock
-
设置my.cnf文件
# 注意"log-error","pid-file"与"socket"的路径 mkdir -p /usr/local/mysql/etc cat << EOF >> /usr/local/mysql/etc/my.cnf [mysqld] character-set-server=utf8 max_connections = 3000 log-error=/var/log/mysqld/mysqld.log pid-file=/var/run/mysqld/mysqld.pid socket=/var/lib/mysqld/mysql.sock sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set=utf8 EOF # 软链接 ln -s /usr/local/mysql/etc/my.cnf /etc/my.cnf # 赋权 chown -R mysql:mysql /usr/local/mysql/etc/
-
启动MySQL服务
# 启动服务 service mysqld start # 验证 service mysqld status
-
设置MySQL账号密码与登陆权限
# 使用初始化密码登陆 mysql -uroot -p # 修改密码,注意不能使用"$"等特殊符号 set password=password(\'cdh12#hadoop\'); flush privileges; # 远程登陆权限 grant all privileges on *.* to \'root\'@\'%\' identified by \'cdh12#hadoop\' with grant option; flush privileges; # 查看账号 select user, host, authentication_string from mysql.user;
三. Cloudera Manager安装
3.1 部署CM Server & Agent
-
在所有节点创建CM目录
/opt/cloudera-manager
mkdir /opt/cloudera-manager
-
在master节点向其余节点分发
cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz
for i in {1..3}; do scp /usr/local/src/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz root@slave0$i:/usr/local/src/ ; done
-
在所有节点解压
cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz
到/opt/cloudera-manager/
目录tar -zxvf /usr/local/src/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz -C /opt/cloudera-manager/
-
在所有slave节点修改
/opt/cloudera-manager/cm-5.16.1/etc/cloudera-scm-agent/config.ini
的server_host
参数为master节点ip或主机名sed -i "s/server_host=localhost/server_host=master/g" /opt/cloudera-manager/cm-5.16.1/etc/cloudera-scm-agent/config.ini
3.2 账号 && 权限
- 在所有节点创建
cloudera-scm
账号,这是CM相关服务使用的默认账号# 禁止使用"cloudera-scm"账号登陆 useradd --system --home=/opt/cloudera-manager/cm-5.16.1/run/cloudera-scm-server/ --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
- 在所有节点为
/opt/cloudera-manager
目录赋权chown -R cloudera-scm:cloudera-scm /opt/cloudera-manager
3.3 设置开机启动
- 在master节点设置系统服务
# 设置使用"cloudera-scm-server"为系统启动服务 cp /opt/cloudera-manager/cm-5.16.1/etc/init.d/cloudera-scm-server /etc/rc.d/init.d/ chown cloudera-scm:cloudera-scm /etc/rc.d/init.d/cloudera-scm-server # 修改"CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}"的路径 vim /etc/rc.d/init.d/cloudera-scm-server CMF_DEFAULTS=/opt/cloudera-manager/cm-5.16.1/etc/default # 添加系统启动服务 chkconfig --add cloudera-scm-server chkconfig --level 35 cloudera-scm-server on checkconfig --list
- 在所有slave节点设置系统服务
# 设置使用"cloudera-scm-agent"为系统启动服务 cp /opt/cloudera-manager/cm-5.16.1/etc/init.d/cloudera-scm-agent /etc/rc.d/init.d/ chown cloudera-scm:cloudera-scm /etc/rc.d/init.d/cloudera-scm-agent # 修改"CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}"的路径"-/etc/default" vim /etc/rc.d/init.d/cloudera-scm-agent CMF_DEFAULTS=${CMF_DEFAULTS:/opt/cloudera-manager/cm-5.16.1/etc/default} # 添加系统启动服务 chkconfig --add cloudera-scm-agent chkconfig --level 35 cloudera-scm-agent on checkconfig --list
3.4 初始化数据库
-
在所有节点设置MySQL驱动(JDBC);
-
注意:部署JDBC在任意节点,则后续"CDH安装配置"阶段
Reports Manager
被分配在任意节点都可以cp /usr/local/src/mysql-connector-java-8.0.13.jar /opt/cloudera-manager/cm-5.16.1/share/cmf/lib/ chown cloudera-scm:cloudera-scm /opt/cloudera-manager/cm-5.16.1/share/cmf/lib/mysql-connector-java-8.0.13.jar
-
在master节点重启MySQL服务
service mysqld restart
-
在任意节点初始化CM
-
注意:Cloudera服务需要的相关
database
如下:- 表中给出的是CM相关服务配置文件中默认的
database
与user
,但不是必须使用; database
在数据库中可直接创建,但CM初始化时如果没有database
,则自动创建。
Service Database User Cloudera Manager Server scm scm Activity Monitor amon amon Reports Manager rman rman Hue hue hue Hive Metastore Server metastore metastore Sentry Server sentry sentry Cloudera Navigator Audit Server nav nav Cloudera Navigator Metadata Server navms navms Oozie oozie oozie # 格式:scm_prepare_database.sh [options] (postgresql|mysql|oracle) database username [password] # scm_prepare_database.sh:创建与配置CMS需要的数据库脚本,默认在"/opt/cloudera-manager/cm-5.16.1/share/cmf/schema/"目录; # postgresql|mysql|oracle:必选项,数据库类型; # database:必选项,针对postgresql|mysql,创建SCM数据库;针对oracle,填写sid; # username:必选项,SCM数据库的账号; # password:选填项,SCM数据库的账号密码,如果不指定,会提示输入; # options: # -h:数据库主机ip或hostname,默认是"localhost"; # -u:数据库账号,需要具备增删改查的权限,默认是"root"; # -p:账号密码,默认无密码; # --scm-host:SCM server主机名,默认是"localhost" /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % scm scm scm_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % amon amon amon_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % rman rman rman_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % hue hue hue_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % metastore metastore metastore_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % sentry sentry sentry_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % nav nav nav_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % navms navms navms_pass /opt/cloudera-manager/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql -h master -uroot -pcdh12#hadoop --scm-host % oozie oozie oozie_pass
返回如下信息,表示配置成功
[main] INFO com.cloudera.enterprise.dbutil.DbCommandExecutor - Successfully connected to database. All done, your SCM database is configured correctly!
- 表中给出的是CM相关服务配置文件中默认的
3.5 创建本地parcel源
-
在master节点制作本地parcel源
# 创建本地parcel源目录 mkdir -p /opt/cloudera/parcel-repo # 将parcel相关安装包放置到"/opt/cloudera/parcel-repo"目录; # 说明:"/opt/cloudera/parcel-repo"目录可放置多套parcel安装包; # 将"CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1"重命名为"CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha",否则会重新下载"CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel"安装包 mv /usr/local/src/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel /opt/cloudera/parcel-repo/ mv /usr/local/src/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha mv /usr/local/src/manifest.json /opt/cloudera/parcel-repo/ # 赋权 chown -R cloudera-scm:cloudera-scm /opt/cloudera/
-
在所有salve节点创建软件安装目录
mkdir -p /opt/cloudera/parcels # 赋权 chown -R cloudera-scm:cloudera-scm /opt/cloudera/
3.6 启动CM服务
- 在master节点启动
cloudera-scm-server
服务# "cloudera-scm-server"启动需要连接数据库,监听端口启动会延迟 service cloudera-scm-server restart service cloudera-scm-server status -l # 通过启动后的状态查看,脚本需要执行"pstree"命令,需要安装依赖包 yum install psmisc -y
- 在所有salve节点启动
cloudera-scm-agent
服务yum install psmisc -y service cloudera-scm-agent restart service cloudera-scm-agent status -l
四. 安装CDH
4.1 CDH安装配置
- 浏览器访问CM:http://172.30.200.75:7180
- 默认账号/密码:
admin/admin
- 最终用户许可条款与条件
- 部署版本,选择
Cloudera Enterprise 试用版
- 版本与服务说明
cloudera-scm-agent
正常启动后,可发现相应的节点,指定集群服务的安装节点
- 选择CDH版本
- 集群安装,如果本地
parcel
源配置正确,则"下载"阶段瞬间完成,其余阶段视节点数与内部网络情况决定
- 检查主机正确性(需要一些时间),针对slave节点有两个优化建议:
- 1.建议将
/proc/sys/vm/swappiness
设置为最大值10
。swappiness
值控制操作系统尝试交换内存的积极;swappiness=0
:表示最大限度使用物理内存,之后才是swap空间;swappiness=100
:表示积极使用swap分区,并且把内存上的数据及时搬迁到swap空间;- 如果是混合服务器,不建议完全禁用swap,可以尝试降低
swappiness
。 - 临时调整:
sysctl vm.swappiness=10
- 永久调整:
cat << EOF >> /etc/sysctl.conf # Adjust swappiness value vm.swappiness=10 EOF
- 2.已启用透明大页面压缩,可能会导致重大性能问题,建议禁用此设置。
- 临时调整:
echo never > /sys/kernel/mm/transparent_hugepage/defrag echo never > /sys/kernel/mm/transparent_hugepage/enabled
- 永久调整:
cat << EOF >> /etc/rc.d/rc.local # Disable transparent_hugepage echo never > /sys/kernel/mm/transparent_hugepage/defrag echo never > /sys/kernel/mm/transparent_hugepage/enabled EOF # centos7.x系统,需要为"/etc/rc.d/rc.local"文件赋予执行权限 chmod +x /etc/rc.d/rc.local
- 临时调整:
- 1.建议将
- 集群设置,选择服务进行安装,这里选择
自定义服务
的HDFS
服务
- 集群设置,自定义角色分配,默认即可
- 集群设置,
Reports Manager
数据库名称rman
,用户名rman
- 集群设置,审核更改,默认即可
- 集群设置,首次运行
- 集群设置,服务安装完成
- Cloudera Manager 主页
- Cloudera Manager HDFS 服务汇总