您的位置:首页 > 大数据

Cloudera Manager CDH 5.12 大数据处理平台部署指南

2017-08-11 18:55 731 查看
Cloudera Manager CDH 5.12 部署指南

官方共给出了3中安装方式。第一种方法必须要求所有机器都能连网,由于各种网络超时错误,基本没法用。第二种方法使用CM的在线yum源,在线下载很多包,同样是超时严重。第三种方法是全离线方式,实际情况是也只能用这个。

1、Cloudera Manager的部署条件
CDH不支持在容器中部署。
支持Oracle JDK7,目前可使用的最新版本为1.7u80,C5.3.x及以上版本也支持使用oracle JDK8,同一个CDH集群中的所有节点使用的JDK版本必须一致。
使用Python2.4及以上,不支持Python3
仅支持IPv4,且IPv6必须要disabled
基于tar压缩包的离线安装方式,会在6.0.0中停止支持该方式。
支持selinux,但如果不熟悉使用方法,建议关闭。
管理端口为7180,此外还有很多基础应用使用的端口,可以运行iptables,需要确认有恰当的授权控制,例如至少要对同网段的访问放开全部端口。

2、Cloudera Manager部署的几个阶段和可选择的方式
Cloudera Installation Phases
Phase   
Phase 1: Install JDK

Install the JDK required by Cloudera Manager Server, Management Service, and CDH.
安装JDK

There are two options:
Use the Cloudera Manager Installer to install a supported version of the Oracle JDK in /usr/java and on all hosts in
the cluster.
Use the command line to manually install supported versions of the Oracle JDK and set the JAVA_HOME environment variable
to the install directory on all hosts.
Phase 2: Set up Databases

Install, configure, and start the databases that are required by the Cloudera Manager Server, Cloudera Management Service, and that are optional for some CDH services.
安装数据库

There are two options:
Use the Cloudera Manager Installer to install, configure, and start an embedded PostgresSQL database.
Use command-line package installation tools like yum to install, configure, and install the database
 Path APath BPath C
Phase 3: Install Cloudera Manager Server

Install and start Cloudera Manager Server on one host.
安装CM Server

Use the Cloudera Manager Installer to install its packages and the server. Requires Internet access and sudo privileges on the host.Use Linux package install commands (like yum) to install Cloudera Manager Server.
Update database properties.
Use service commands to start Cloudera Manager Server.
Use Linux commands to unpack tarballs and service commands to start the server.
Phase 4: Install Cloudera Manager Agents

Install and start the Cloudera Manager Agent on all hosts.
安装CM Agent

Use the Cloudera Manager Installation wizard to install the Agents on all hosts.There are two options:
Use Linux package install commands (like yum) to install Cloudera Manager Agents on all hosts.
Use the Cloudera Manager Installation wizard to install the Agents on all hosts.
Use Linux commands to unpack tarballs and service commands to start the agents on all hosts.
Phase 5: Install CDH and Managed Service software

Install, configure, and start CDH and managed services on all hosts.
安装CDH软件包

Use the Cloudera Manager Installation wizard to install CDH and other managed services.There are two options:
Use the Cloudera Manager Installation wizard to install CDH and other managed services.
Use Linux package install commands (like yum) to install CDH and other managed services on all hosts.
Use Linux commands to unpack tarballs and service commands to start CDH and managed services on all hosts.
Phase 6: Create, Configure and Start CDH and Managed Services

Configure and start CDH and managed services.
配置和启动CDH及各种需要使用的应用

Use the Cloudera Manager Installation wizard to install CDH and other managed services, assign roles to hosts, and configure the cluster. Many configurations are automated.Use the Cloudera Manager Installation wizard to install CDH and other managed services, assign roles to hosts, and configure the cluster. Many configurations are automated.Use the Cloudera Manager Installation wizard to install CDH and other managed services, assign roles to hosts, and configure the cluster. Many configurations are automated.
You can also use the Cloudera Manager API to manage a cluster, which can be useful for scripting preconfigured deployments.
注:因为Cloudera Manager的官方yum源位于国外,受网速影响而无法正常使用。所以上述部署方式中,一般是使用PATH C,或者在预先下载好相关RPM包的条件下参照PATH B方式。

3、主机节点信息和基础配置
(1)主机信息
本次部署使用以下主机,前两个作为NameNode使用。后四个主机,分别额外挂载一块1TB的磁盘到本地的/dfs/dn目录下。
注1:用于大数据平台的数据磁盘不要配置RAID,直接祼盘即可。如果有RAID控制器,则直接对每块盘设置一个单独的RAID0,仍然当作单盘使用。
注2:在有第二块数据盘的情况下,继续挂载到/dfs/dn2,更多的数据盘则按命名规则和挂盘规则扩展即可。
注3:对于生产环境而言,NameNode所在的节点一般不要同时做数据节点使用。而且NameNode所在主机的磁盘需要配置适当的RAID保护级别,以提高可靠性。
注4:对于DataNode所在的主机节点,建议系统盘和数据盘完全隔离开,然后系统盘使用两磁盘配置为RAID1以提高可靠性。虽然数据节点是冗余的,挂一个也不影响CDH平台运行,但修起来还是很麻烦啊。

172.17.10.70    cluster-70
172.17.10.71    cluster-71
172.17.10.72    cluster-72
172.17.10.73    cluster-73
172.17.10.74    cluster-74
172.17.10.75    cluster-75

操作系统全部使用CentOS 6.9 Minimal安装。
将全部主机的主机名设置好,并将以上映射关系写到每个主机的/etc/hosts文件中。

(2)免密登录
在cluster-70节点上制作ssh密钥:ssh-keygen
将该密钥分发至其它各节点,以实现免密钥登录,如:ssh-copy-id  cluster-71

(3)selinux和iptables
所有节点配置为关闭selinux。
所有节点的iptables设置为对同网段地址放开全部端口的访问权限。

(4)系统性能参数调整
CDH服务为发挥更好的性能,需对以下参数做些调整。直接将下面脚本刷到系统中即可。
cat << EOF >> /etc/sysctl.conf
vm.swappiness = 0
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv4.ip_local_port_range = 1024 65000
EOF
sysctl -p
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
cat << EOF >> /etc/rc.loca
1162b
l
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
EOF


4、安装JDK
下载并分发Oracle JDK安装包至所有节点,执行安装和配置命令。

rpm -ivh jdk-7u80-linux-x64.rpm
直接刷下面脚本完成配置:
cat << EOF >> /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_80
PATH=\$JAVA_HOME/bin:\$PATH:.
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
EOF
source /etc/profile


以上JDK配置,需要在每个节点上都处理。

5、安装和配置数据库
主要有以下业务会使用到数据库服务:
Cloudera Manager,存放各种服务、配置数据,空间大约100MB,很重要,应经常备份 ;
Oozie Server - Contains Oozie workflow, coordinator, and bundle data. Can grow very large.
Sqoop Server - Contains entities such as the connector, driver, links and jobs. Relatively small.
Activity Monitor - Contains information about past activities. In large clusters, this database can grow large. Configuring an Activity Monitor database is only necessary if a MapReduce service is deployed.
Reports Manager - Tracks disk utilization and processing activities over time. Medium-sized.
Hive Metastore Server - Contains Hive metadata. Relatively small.
Hue Server - Contains user account information, job submissions, and Hive queries. Relatively small.
Sentry Server - Contains authorization metadata. Relatively small.
Cloudera Navigator Audit Server - Contains auditing information. In large clusters, this database can grow large.
Cloudera Navigator Metadata Server - Contains authorization, policies, and audit report metadata. Relatively small.

(1)因为准备使用cluster-70作为NameNode Master,所以把mysql数据库安装在cluster-71上面,以分散下风险。
登录cluster-71,然后使用任一种自己熟悉的方式把mysql数据库安装好即可:
yum install mysql-server mysql
chkconfig mysqld on
service mysqld start
完成数据库初始化:
/usr/bin/mysql_secure_installation

(2)优化数据库配置
service mysqld stop
将旧的InnoDB log文件移走:
 /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile1 out of /var/lib/mysql/

参照下面调整my.cnf参数,以更适合CDH服务使用:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
transaction-isolation = READ-COMMITTED
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
#binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit  = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 2G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_ALL_TABLES

启动mysql,如果有报错,可根据日志信息排查。

(3)创建需要使用的几个库
RoleDatabaseUserPassword
Activity Monitoramonamonamon_password
Reports Managerrmanrmanrman_password
Hive Metastore Servermetastorehivehive_password
Sentry Serversentrysentrysentry_password
Cloudera Navigator Audit Servernavnavnav_password
Cloudera Navigator Metadata Servernavmsnavmsnavms_password
Oozieoozieoozieoozie_password
huehuehuehue_password
create database database DEFAULT CHARACTER SET utf8;
grant all on database.* TO 'user'@'%' IDENTIFIED BY 'password';
注:在部署中发现hive,oozie使用的库需要使用latin字符集,否则在启动服务时日志中会报错创建索引时超长度限制。

(4)安装程序驱动包mysql jdbc driver
总计有以下角色所在的主机需要安装这个驱动包。如果你把以下角色都部署在一个主机节点上,那就只需要安装一个节点的驱动,否则就需要各节点都部署一下。
Cloudera Manager Server host
Activity Monitor, Reports Manager, Hive Metastore Server, Hue Server, Sentry Server, Cloudera Navigator Audit Server, and Cloudera Navigator Metadata Server

从以下网址下载需要使用的驱动包:
http://www.mysql.com/downloads/connector/j/5.1.html
tar -zxvf mysql-connector-java-5.1.43.tar.gz
mkdir -p /usr/share/java/
cp mysql-connector-java-5.1.43/mysql-connector-java-5.1.43-bin.jar /usr/share/java/mysql-connector-java.jar

6、配置NTP时间同步服务
在所有节点上安装和启用。如果是内网环境,也需要另想办法保证所有节点的系统时间严格同步。
yum -y install ntp
service ntpd restart
chkconfig ntpd on

7、安装Cloudera Manager Server 软件
我们选择把Cloudera Manager Server部署在cluster-70节点上。

(1)下载和分发安装资源
cloudera manager下载地址: https://archive.cloudera.com/cm5/cm/5/ cdh parcels 下载地址: http://archive.cloudera.com/cdh5/parcels/
wget -c https://archive.cloudera.com/cm5/cm/5/cloudera-manager-el6-cm5.12.0_x86_64.tar.gz
wget -c http://archive.cloudera.com/cdh5/parcels/5.12/CDH-5.12.0-1.cdh5.12.0.p0.29-el6.parcel wget -c http://archive.cloudera.com/cdh5/parcels/5.12/CDH-5.12.0-1.cdh5.12.0.p0.29-el6.parcel.sha1
wget -c http://archive.cloudera.com/cdh5/parcels/5.12/manifest.json
注:需要同时下载sha文件,而且在下载到本地后需要手动把文件后缀从sha1变更为sha,否则上传到系统中后,CDH平台反而会说找不到sha文件。

将cloudera-manager-el6-cm5.12.0_x86_64.tar.gz 文件放到所有节点的/opt/cloudera-manager 目录下。

mkdir /opt/cloudera-manager
cd /opt
tar zxvf cloudera-manager-el6-cm5.12.0_x86_64.tar.gz

(2)创建CM Server系统用户账号
useradd --system --home=/opt/cloudera-manager/cm-5.12.0/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm

(3)创建CM Server的本地数据存储目录
登录cluster-70:
mkdir -p /var/lib/cloudera-scm-server
chown cloudera-scm:cloudera-scm /var/lib/cloudera-scm-server

(4)配置所有节点上的Cloudera Manager Agents
sed -i 's/server_host=localhost/server_host=cluster-70/' /opt/cloudera-manager/cm-5.12.0/etc/cloudera-scm-agent/config.ini

(5)创建和初始化CM Server数据库
我们的mysql数据库是安装在cluster-71上面,登录cluster-71:
部署一个JDBC驱动包:
cp  mysql-connector-java-5.1.43-bin.jar  /opt/cloudera-manager/cm-5.12.0/share/cmf/lib

初始化脚本语法如下:
scm_prepare_database.sh database-type [options] database-name username password

#/opt/cloudera-manager/cm-5.12.0/share/cmf/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -pHstest2017 scm scm scm
JAVA_HOME=/usr/java/jdk1.7.0_80
Verifying that we can write to /opt/cloudera-manager/cm-5.12.0/etc/cloudera-scm-server
Creating SCM configuration file in /opt/cloudera-manager/cm-5.12.0/etc/cloudera-scm-server
Executing:  /usr/java/jdk1.7.0_80/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/opt/cloudera-manager/cm-5.12.0/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /opt/cloudera-manager/cm-5.12.0/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor              INFO  Successfully connected to database.
All done, your SCM database is configured correctly!


登录mysql,增加一条对CM Server主机的访问授权:
grant all on scm.* TO 'scm'@'cluster-70' IDENTIFIED BY 'scm';

登录cluster-70节点配置CM Server的数据库配置文件:
/opt/cloudera-manager/cm-5.12.0/etc/cloudera-scm-server/db.properties
需要根据实际情况更新以下参数。
com.cloudera.cmf.db.host=cluster-71
com.cloudera.cmf.db.name=scm
com.cloudera.cmf.db.user=scm
com.cloudera.cmf.db.password=scm
com.cloudera.cmf.db.setupType=EXTERNAL


(6)创建CDH Parcel资源目录
在cluster-70节点上:
mkdir -p /opt/cloudera/parcel-repo

将以下已经准备好的parcel资源文件放入该目录:
CDH-5.12.0-1.cdh5.12.0.p0.29-el6.parcel
CDH-5.12.0-1.cdh5.12.0.p0.29-el6.parcel.sha1
manifest.json

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

在其它所有节点上:
mkdir -p /opt/cloudera/parcels
chown cloudera-scm:cloudera-scm /opt/cloudera/parcels

(7)启动cloudera manager server and agents
直接使用root运行启动脚本即可,脚本中已经默认设定为会切换到cloudera-scm用户运行进程。
在所有节点上,先调整下文件属主权限:
chown -R cloudera-scm:cloudera-scm /opt/cloudera-manager

在cluster-70节点上启动CM Server:
/opt/cloudera-manager/cm-5.12.0/etc/init.d/cloudera-scm-server  start
在所有节点上启动CM agent:
/opt/cloudera-manager/cm-5.12.0/etc/init.d/cloudera-scm-agent  start

注:在启动上面的服务时,注意检查进程是否运行,是否因报错退出。可以检查../../log/下面的日志文件,分析错误原因。

8、登录Cloudera Manager管理控制台并配置CDH服务
访问以下地址: http://172.17.10.70:7180/cmf 初始管理账号信息为:admin/admin

(1)登录后按提示操作,先是选择license许可,如果没采购企业许可,就选免费版,继续。
(2)选择要加入CDH集群的主机,因为我们已经配置好6台主机的访问关系了,这6个主机会被自动识别出来,选中然后下一步。
(3)安装CDH服务的方式,选择使用Parcels,因为之前已经把离线安装资源放到系统默认的路径下了,这里会自动识别到,点击下一步将开始在CDH集群各节点中分发所有需要使用的应用的parcels安装资源。
(4)经过一个主机正确性检查的步骤,点击完成按钮。如果系统提示有参数配置上的优化建议,遵照处理后重新做检验检查即可。
(5)选择一种集群服务组合,如果不确定哪个组合更合适,选择“全部服务”也可以。
(6)进入集群角色分配环节,这一步比较关键,注意要把NameNode分配到我们设计的cluster-70节点,SecondaryNameNode分配到cluster-71节点上。注意调整HDFS的DataNode角色,自定义分配到cluster-72到cluster-75这4个节点上。注意有多个服务的角色是还没有分配的,请将这些角色统一都分配到cluster-71节点上即可,这样做是因为简化数据节点的角色和职责,便于维护,且cluster-70节点已经被默认分配了很多的角色了,也不适合再继续增加。
(7)下一步,进入数据库设置。按实际配置信息填写,然后下一步。
(8)进入审核更改环节,检查下DataNode数据目录,设置为/dfs/dn;NameNode的数据目录设置为/dfs/nn。这里要特别注意,如果给数据节点准备了多块数据磁盘,要在这里定义更多的“DataNode数据目录 ”,即按照/dfs/dn2, /dfs/dn3这样的规则继续增加即可。前文已经说过,在数据节点有多块数据磁盘时,按这样的规则挂载到系统中的。
(9)在进入下一步之前有一个细节非常重要,因为我们是使用的独立的数据磁盘,挂载到系统的/dfs/dn这样的路径下的。这个路径是我们手动创建的,而非CDH服务自行生成,所以这个目录存在属主权限问题,会直接造成下一步骤中的HDFS启动失败。请在所有的主机节点上面执行:chown -R hdfs.hadoop /dfs/dn
(10)点击下一步,即完成了所有配置任务,并进入了首次运行服务启动命令的环节。

9、启动服务并解决各种问题

hive和solr服务在启动前,都需要先在cloudera manager管理平台上菜单中点击库表数据初始化。
在启动后发现hbase master角色无法启动,日志中报错“Permission denied: user=hbase, access=WRITE, inode="/":hdfs:supergroup:drwxr-xr-x” 。解决办法为,在管理平台上进入HDFS的参数配置界面,找到dfs.permissions,设置为false 。详细说明参见下面链接:https://community.cloudera.com/t5/CDH-Manual-Installation/Permission-denied-user-root-access-WRITE-inode-quot-user-quot/td-p/4943
其它多个服务在启动过程中也或多或少遇到一些问题,但都不难解决,指导思想就是先看CDH管理平台上的报错信息、报错日志,再到系统的/var/log下查看下服务日志,基本上都能定位到问题的原因。大多数问题,都能在网上找到处理类似问题的帮助资料。有几类常见问题:

权限类问题,目录或文件属主设置不对;
服务之间的访问权限,这些问题一般都可以通过直接在CDH管理平台上微调少量的服务配置参数解决;

10、怎么增加更多的应用服务
比如要增加KAFKA服务。
先下载parcel资源文件: https://archive.cloudera.com/kafka/parcels/latest/KAFKA-2.2.0-1.2.2.0.p0.68-el6.parcel.sha1 https://archive.cloudera.com/kafka/parcels/latest/KAFKA-2.2.0-1.2.2.0.p0.68-el6.parcel
然后把以上两个文件放到cluster-70节点的/opt/cloudera/parcel-repo路径下。注意设置下文件属主,重命名下sha文件的后缀。
最终登录CDH管理平台,从主机菜单中选择pacel菜单项,点击检查新parcel资源。按提示操作,完成新parcel资源的分发和激活即可使用了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息