一、CDH架构

Cloudera Manger 架构

CDH 6.2.0 组件版本

完整参考:https://docs.cloudera.com/documentation/enterprise/6/release-notes/topics/rg_cdh_62_packaging.html#cdh_packaging_60x

演示集群系统软件版本

 操作系统:centos 7 64位
 CDH:6.2.0
 JDK:1.8

二、虚拟机设置

Step1: 安装虚拟机

建议:安装设置好一台后通过导入导出功能复制其他两台

Step2: 设置网络

Step3:设置hosts(后续操作均以root用户执行)

#1.确定各节点hostname 正确设置:
vi /etc/hostname
master[/slave1/slave2]

#2.设置hosts:
vi /etc/hosts:

10.211.55.10 master
10.211.55.9 slave1
10.211.55.8 slave2

#3. 设置network,增加HOSTNAME
vi /etc/sysconfig/network

HOSTNAME=master[/slave1/slave2]

 Step4:关闭SELinux及防火墙

#1. 关闭SELinux:  
vi /etc/selinux/config ,修改如下: 
SELINUX=disabled

#2. 关闭防火墙:
systemctl stop firewalld
systemctl disable firewalld

#3. iptables
service iptables stop
chkconfig iptables off
chkconfig iptables --list

#4. 检查下防火墙关闭情况;
iptables -L

#避免以后网络出现问题,需要设置enforce;

#在每台虚拟机中都进行如下操作:


getenforce;

setenforce 0;

getenforce;

Step5: 设置ssh免密登录

#1.生成密钥:
ssh-keygen -t rsa(默认位于 ~/.ssh/)
#2. 拷贝公钥到所有机器:
ssh-copy-id root@master
ssh-copy-id root@slave1
ssh-copy-id root@slave2
#3.测试免密登录:
ssh master
ssh slave01
ssh slave02

Step6: 设置yum源为阿里云的源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.rep

yum clean all

yum makecache

Step7: 设置ntp时间同步服务

#1.安装 ntp
yum –y install ntp 

#2.启动并设置NTP服务开机启动
systemctl start ntpd
systemctl status ntpd
systemctl enable ntpd
systemctl list-unit-files|grep ntpd

Step8: 设置ntp时间同步服务

将master设置为主服务器(在master节点操作):
1. vi /etc/ntp.conf,内容如下:

driftfile /var/lib/ntp/ntp.drift #草稿文件
# 允许内网其他机器同步时间(10.211.55.0 修改为自己的ip掩码)
restrict 10.211.55.0 mask 255.255.255.0 nomodify notrap
 
# Use public servers from the pool.ntp.org project.
# 中国这边最活跃的时间服务器 : [http://www.pool.ntp.org/zone/cn](http://www.pool.ntp.org/zone/cn)
server 210.72.145.44 perfer   # 中国国家受时中心
server 202.112.10.36             # 1.cn.pool.ntp.org
server 59.124.196.83             # 0.asia.pool.ntp.org
 
# allow update time by the upper server 
# 允许上层时间服务器主动修改本机时间
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery
 
# 外部时间服务器不可用时,以本地时间作为时间服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

2. 重启服务: service ntpd restart
3. 查看同步状态: netstat -tlunp | grep ntp

Step9: 设置ntp时间同步服务

设置slave到master 的同步(在slave节点操作):
1. vi /etc/ntp.conf,内容如下:

driftfile /var/lib/ntp/ntp.drift # 草稿文件

statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# 让NTP Server为内网的ntp服务器( 10.211.55.10修改为master节点ip)
server 10.211.55.10
fudge 10.211.55.10 stratum 5

# 不允许来自公网上ipv4和ipv6客户端的访问
restrict -4 default kod notrap nomodify nopeer noquery 
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

2. 重启服务: service ntpd restart
3. 手动、自动同步:

ntpdate -u 10.211.55.10

# 设置每天同步一次
crontab -e

#*****:五个*代表
00 00 * * * ntpdate -u  master

4. 同一时区:

timedatectl --help

# 查看时区
timedatectl list-timezones | grep Shanghai

#设置时区
timedatectl set-timezone Asia/Shanghai

 三、重启虚机

Step10: 上传安装文件

Step11: 检查文件是否正确

确保cloudera-manager.repo文件放入/etc/yum.repos.d/目录

确保parcel目录下文件完整

Step12: 安装jdk&CM

# 1. 验证repo文件是否起效
yum list | grep cloudera
#如果列出的不是待安装的版本,执行下面命令重试
yum clean allyum list | grep cloudera

#2. 切换到jdk&cm目录下,执行
yum -y install *.rpm

#3. 设置java路径:
vi /etc/profile

# 在该文件末尾添加以下行
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera/
export PATH=$JAVA_HOME/bin:$PATH

#4. 检查安装:
java -version

#
# 创建Parcel目录

#创建parcel目录,这些目录是server和agent用来接收和发送数据的目录,server端的parcel-repo这个目录会把所有
#的安装文件全部下载到此目录,而agent也需要安装包,parcels就是用来存储指定的安装包的,当然需要有权限能操作
#这些目录;
#Server节点

 – mkdir -p /opt/cloudera/parcel-repo

– chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo

#Agent节点

– mkdir -p /opt/cloudera/parcels

– chown cloudera-scm:cloudera-scm /opt/cloudera/parcels

Step13: 安装数据库(mysql) -1

参考:https://docs.cloudera.com/documentation/enterprise/6/6.2/topics/cm_ig_mysql.html#cmig_topic_5_5

需要用到数据库的组件:
Cloudera Manager Server
Cloudera Management Service roles:
Activity Monitor 
Reports Manager
Cloudera Navigator Audit Server
Cloudera Navigator Metadata Server
Hue
Each Hive metastore
Oozie


Step13: 安装数据库(mysql) - 2

1. 安装mysql数据库服务器(master)
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum update
sudo yum -y install mysql-server
sudo systemctl start mysqld
2. 数据库设置:
停止服务:sudo systemctl stop mysqld
修改配置:sudo vi /etc/my.cnf
	To prevent deadlocks, set the isolation level to READ-COMMITTED.
	Configure the InnoDB engine
设置自动启动:sudo systemctl enable mysqld
启动服务:sudo systemctl start mysqld
设置启动密码:sudo /usr/bin/mysql_secure_installation
3. 安装JDBC驱动(所有节点):
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
tar zxvf mysql-connector-java-5.1.46.tar.gz
sudo mkdir -p /usr/share/java/
cd mysql-connector-java-5.1.46
sudo cp mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar

Step13: 安装数据库(mysql) - 3

# 根据下表组件中的信息运行如下语句为组件创建用户

CREATE DATABASE  scm CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'scm';

CREATE DATABASE  amon CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'amon';

CREATE DATABASE  rman CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'rman';

CREATE DATABASE  hue CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'hue';

CREATE DATABASE  metastore CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'hive';

CREATE DATABASE  sentry CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'sentry';

CREATE DATABASE  nav CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'nav';

CREATE DATABASE  navms CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'navms';

CREATE DATABASE  oozie CHARACTER SET utf8  COLLATE utf8_general_ci;	
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'oozie';

Step13: 安装数据库(mysql) - 4

# 运行如下脚本配置scm server数据库:
sudo /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm

Step14: 安装CDH(只在master节点)

14.1.  cloudera-scm-server设置(master)

1.启动scm server:
sudo systemctl start cloudera-scm-server

2. 查看日志,检查是否启动完成:
sudo tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
--查看到【WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server.】日志表示启动完成

3. 登录主页(账号/密码:admin/admin):
http://master:7180

4. 初始化CDH,建立Cluster

14.2.  cloudera-scm-agent设置(master和slave)

1.设置并启动scm agent:
vi  /etc/cloudera-scm-agent/config.ini

server_host=master
use_tls=0


sudo systemctl start cloudera-scm-agent


2. 查看日志,检查是否正常:
tail -300f /var/log/cloudera-scm-agent/cloudera-scm-agent.log

Step15: HDFS副本设置

在CM console中将副本设为2:dfs.replication=2

命令行执行: hadoop fs -setrep -w 2 /

CDH启动与关闭

# CM Portal 地址: 
http://master:7180/cmf/home


关闭步骤:
# 在CM portal上关闭 cluster
# 在所有节点关闭CM agent: 
sudo systemctl stop cloudera-scm-agent

# 在master节点关闭CM server: 
sudo systemctl stop cloudera-scm-server



启动步骤:
#在所有节点启动CM agent: 
sudo systemctl start cloudera-scm-agent

#查看启动日志
tail -f -n 300 /var/log/cloudera-scm-agent/cloudera-scm-agent.log 

#在master节点启动CM server: 
sudo systemctl start cloudera-scm-server

#查看启动日志
tail -f -n 300 /var/log/cloudera-scm-server/cloudera-scm-server.log


CM agent
tail -f -n 300 /var/log/cloudera-scm-agent/cloudera-scm-agent.log 

仔细,认真,严格按照步骤
 常见问题:网络,防火墙等主机设置
 由于资源与网络问题,CDH安装和运行过程可能会不稳定,组件安装不成功或页面有些告警,可以先通过重试看是否能解决
 碰到问题:
查看日志:
cloudera manager server
cloudera manager agent
官网&百度
官方参考: https://docs.cloudera.com/documentation/enterprise/6/6.2/topics/installation.html

安装异常

1.

 This may occur if the host has an NFS or other remote filesystem that is not responding to requests in a timely fashion

参考:adding host agent to cluster fails - Cloudera Community - 87435

2.

 Unable to retrieve non-local non-loopback IP address. Seeing address: localhost/127.0.0.1.

解决:

vi /etc/hosts

去掉 127.0.0.1 后面的master,并注释 # ::1

3. 

MainThread agent ERROR Heartbeating to centos7-hadoop-m0.shared:7182 failed.

解决:

cat /etc/cloudera-scm-agent/config.ini

查看到

vi  /etc/cloudera-scm-agent/config.ini

3.1. 修改 server_host=master

3.2. 修改 use_tls=0,不使用安全证书验证连接CM server

4.

 Cloudera 建议将 /proc/sys/vm/swappiness 设置为最大值 10。当前设置为 30。使用 sysctl 命令在运行时更改该设置并编辑 /etc/sysctl.conf,以在重启后保存该设置。您可以继续进行安装,但 Cloudera Manager 可能会报告您的主机由于交换而运行状况不良。以下主机将受到影响

解决方法:

临时修改:

sysctl vm.swappiness=10
cat /proc/sys/vm/swappiness

这里我们的修改已经生效,但是如果我们重启了系统,又会变成60.

永久修改:

/etc/sysctl.conf 文件里添加如下参数:

vm.swappiness=10

或者:

echo 'vm.swappiness=10'>> /etc/sysctl.conf

已启用透明大页面压缩,可能会导致重大性能问题。请运行“echo never > /sys/kernel/mm/transparent_hugepage/defrag”和“echo never > /sys/kernel/mm/transparent_hugepage/enabled”以禁用此设置,然后将同一命令添加到 /etc/rc.local 等初始化脚本中,以便在系统重启时予以设置。以下主机将受到影响:

临时生效:

echo never > /sys/kernel/mm/transparent_hugepage/defrag

echo never > /sys/kernel/mm/transparent_hugepage/enabled
  • 永久生效:
echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.local

 或

echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local

5.

com.cloudera.cmon.MgmtServiceLocatorException: Could not find a HOST_MONITORING nozzle from SCM.

在主节点上,修改/opt/cm-5.15.1/etc/cloudera-scm-agent/config.ini文件:
//查看文件句柄数,显示1024,显然太小
# ulimit -n 
1024
//修改限制
#vi /etc/security/limits.conf 
//在文件后加入下面内容:
* soft nofile 100000
* hard nofile 100000
此步骤需要重启机器生效,可以设置完后再重启。
 
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐