Contents
  1. 1. 前言
  2. 2. 卸载OpenJDK
  3. 3. 安装JDK
  4. 4. 安装MySQL(主节点)
  5. 5. 初始化MySQL(主节点)
  6. 6. hive
  7. 7. Activity Monitor使用
  8. 8. Navigator Audit Server使用
  9. 9. Navigator Metadata Server
  10. 10. this user scm is for cloudera manager
  11. 11. 部署/启动CM Server(主节点)
  12. 12. 停止iptables
  13. 13. 通过浏览器访问验证
  14. 14. 部署/启动CM Agent(从节点)
  15. 15. 停止集群步骤

摘要:管理、部署Hadoop集群需要工具,Cloudera Manager便是其一。本文先是简要对比了当前的类似工具,而后详细记录了以离线方式部署CDH集群的步骤。

前言

以Apache Hadoop为主导的大数据技术的出现,使得中小型公司对于大数据的存储与处理也拥有了武器。目前Hadoop有不少发行版:华为发行版 收费、Intel发行版 收费、Cloudera发行版(Cloudera’s Distribution Including Apache Hadoop,简称 CDH)免费、Hortonworks发行版(Hortonworks Data Platform,简称 HDP)免费 等,所有这些发行版均是基于Apache Hadoop社区版衍生出来的。

部署、管理拥有数十数百甚至更多节点的Hadoop集群,也需要先进武器。Hortonworks公司的Apache Ambari项目的目的就是通过软件来配置、监控和管理Hadoop(HDP)集群,以使Hadoop的管理更加简单。Ambari提供了一个基于它自身RESTful的api实现的直观的、简单易用的web界面。Cloudera公司也提供了类似的工具:Cloudera Manager(简称 CM)来配置、监控和管理CDH集群。

需特别注意的是Cloudera Manager与操作系统的版本关系 Cloudera Manager 5.5.3版本开始支持RHEL/CentOS/Oracle 7,按照官方文档的要求来,否则安装会有问题。

注意用户。
本文是基于操作系统CentOS 6.3, 64-bit;Cloudera Manager 5.3.9;JDK 1.7 版本进行部署的。

相关包的下载地址

Cloudera Manager下载地址:

http://www.cloudera.com/downloads/manager/5-3-9.html
或
http://archive.cloudera.com/cm5/cm/5/
选择文件下载
cloudera-manager-el6-cm5.3.9_x86_64.tar.gz,

CDH安装包地址:

http://archive.cloudera.com/cdh5/parcels/latest/

由于笔者的操作系统为CentOS 6.3,需要下载以下文件:

CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel
CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel.sha1
manifest.json
把下载的CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel.sha1
重命名为CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel.sha不然会重新下载

注意:与CDH4的不同,原来安装CDH4的时候还需要下载IMPALA、Cloudera Search(SOLR),CDH5中将他们包含在一起了,所以只需要下载一个CDH5的包就可以了。
准备工作:系统环境搭建

部署步骤
网络配置(所有节点)

[root@cdh-server ~]# vi /etc/sysconfig/network #修改hostname:
NETWORKING=yes
HOSTNAME=cdh-server

[root@cdh-server ~]# vi /etc/hosts #修改ip与主机名的对应关系:
192.168.180.185 cdh-server
192.168.180.186 node186
192.168.180.187 node187
[root@cdh-server ~]# service network restart #重启网络服务生效

安装JDK(所有节点)

卸载OpenJDK

[root@cdh-server ~]# rpm -qa | grep java
java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
[root@cdh-server ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64

安装JDK

[root@cdh-server ~]# rpm -ivh jdk-7u79-linux-x64.rpm 
[root@cdh-server ~]# echo "JAVA_HOME=/usr/java/jdk1.7.0_79/" >> /etc/profile
[root@cdh-server ~]# . /etc/profile
[root@cdh-server ~]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

安装MySQL(主节点)

mysql用户

[mysql@cdh-server ~]$ cd /home/mysql
[mysql@cdh-server ~]$ tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
[mysql@cdh-server ~]$ mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql
[mysql@cdh-server ~]$ vi /etc/my.cnf 

[mysqld]
character_set_client= utf8
character_set_filesystem= binary
character_set_server=utf8
binlog_format = row
basedir=/home/mysql/mysql/
datadir=/home/mysql/data/

[mysqld__safe]
log-error=/home/mysql/mysql/mysqld.log
pid-file=/home/mysql/mysql/mysqld.pid

初始化MySQL(主节点)

[mysql@cdh-server ~]$ ./mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/home/mysql/mysql --datadir=/home/mysql/data --user=mysql

配置mysql服务
root用户

[root@cdh-server mysql]# cp support-files/mysql.server /etc/init.d/mysql

修改文件性性

[root@cdh-server mysql]# chown mysql.mysql /etc/init.d/mysql 
[root@cdh-server mysql]# exit
exit

修改datadir、basedir路径

[mysql@cdh-server mysql]$ vi /etc/init.d/mysql 

[mysql@cdh-server ~]$ vi .bash_profile #加入环境变量
PATH=$PATH:$HOME/bin:/home/mysql/mysql/bin
export PATH

启动mysql

[mysql@cdh-server ~]$ service mysql start
Starting MySQL.                                            [  OK  ]
[mysql@cdh-server ~]$ mysql -uroot -p
Enter password: #直接回车
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

修改密码

mysql> set password=password('root');
Query OK, 0 rows affected (0.00 sec)

hive

mysql> create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

Activity Monitor使用

mysql> create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.01 sec)
mysql> create database audit DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.01 sec)
mysql> create database metadata DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'cdh-server' identified by 'root'     with grant option;
Query OK, 0 rows affected (0.00 sec)

this user scm is for cloudera manager

mysql> grant all privileges on *.* to 'scm'@'localhost' identified by 'scm' with     grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'scm'@'cdh-server' identified by 'scm'        with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

部署/启动CM Server(主节点)

[mysql@cdh-server ~]$ tar -xvf cloudera-manager-el6-cm5.3.9_x86_64.tar.gz 
[mysql@cdh-server ~]$ cp mysql-connector-java-5.1.38-bin.jar cm-5.3.9/share/cmf/lib/

[mysql@cdh-server ~]$ su - 
[root@cdh-server ~]# cd /home/mysql/

[root@cdh-server mysql]# cp -rf cloudera /opt
[mysql@cdh-server ~]$ mv CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel /opt/cloudera/parcel-repo/
[mysql@cdh-server ~]$ mv CDH-5.3.9-1.cdh5.3.9.p0.8-el6.parcel.sha1 /opt/cloudera/parcel-repo/
[mysql@cdh-server ~]$ mv manifest.json /opt/cloudera/parcel-repo/
[root@cdh-server mysql]# ./cm-5.3.9/share/cmf/schema/scm_prepare_database.sh mysql cm -hlocalhost:3306 -uroot -proot --scm-host localhost scm scm scm
[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-server start
Starting cloudera-scm-server:                              [  OK  ]
[root@cdh-server mysql]# tail -f ./cm-5.3.9/log/cloudera-scm-server/cloudera-scm-server.log

关闭防火墙(所有节点)

停止iptables

[root@cdh-server mysql]# service iptables stop

通过浏览器访问验证

http://192.168.180.185:7180/

部署/启动CM Agent(从节点)

[root@cdh-server mysql]# tar -zxvf cloudera-manager-el6-cm5.3.9_x86_64.tar.gz 
[root@cdh-server mysql]# vi cm-5.3.9/etc/cloudera-scm-agent/config.ini
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#Hostname of the CM server.
#server_host=localhost
server_host=cdh-server
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@cdh-server mysql]# useradd -G sys --home=/home/mysql/cm-5.3.9/run/cloudera-scm-server --no-create-home  --comment "Cloudera SCM User" cloudera-scm
[root@cdh-server mysql]# useradd --comment "Cloudera SCM User" cloudera-scm #若上一步执行正确,则此步省略

[root@cdh-server mysql]# echo 0 > /proc/sys/vm/swappiness

[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-agent start
Starting cloudera-scm-agent:                               [  OK  ]
[root@cdh-server mysql]# tail -f ./cm-5.3.9/log/cloudera-scm-agent/cloudera-scm-agent.log

配置CDH
登陆Cloudera Manager

http://192.168.180.185:7180/
并新建集群Cluster_mysql,进行各服务的配置启动。

#安装配置hive出错时,在hiveServer上:

[root@hive-server mysql]# cp mysql-connector-java-5.1.33-bin.jar /opt/cloudera/parcels/CDH-5.3.6-1.cdh5.3.6.p0.11/lib/hive/lib/

#同理:use this jar for Navigator Audit Server and Navigator Metadata Server or Activity Server
[root@cdh-server mysql]# cp mysql-connector-java-5.1.33-bin.jar /usr/share/java/mysql-connector-java.jar

停止集群步骤


停止Cloudera Management Service和Cluster_mysql
从节点停止Agent

[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-agent stop

主节点停止Server

[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-server stop

启动集群步骤
主节点启动MySQL

[mysql@cdh-server ~ ]$ service mysql start
[mysql@cdh-server ~ ]$ ps -a | grep mysql

从节点启动Agent

[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-agent start
Starting cloudera-scm-agent:                               [  OK  ]
[root@cdh-server mysql]# tail -f ./cm-5.3.9/log/cloudera-scm-agent/cloudera-scm-agent.log

主节点启动Server

[root@cdh-server mysql]# ./cm-5.3.9/etc/init.d/cloudera-scm-server start
Starting cloudera-scm-server:                              [  OK  ]
[root@cdh-server mysql]# tail -f ./cm-5.3.9/log/cloudera-scm-server/cloudera-scm-server.log

启动各服务
登陆Cloudera Manager

http://192.168.180.173:7180/
进行各服务的检查启动。
Contents
  1. 1. 前言
  2. 2. 卸载OpenJDK
  3. 3. 安装JDK
  4. 4. 安装MySQL(主节点)
  5. 5. 初始化MySQL(主节点)
  6. 6. hive
  7. 7. Activity Monitor使用
  8. 8. Navigator Audit Server使用
  9. 9. Navigator Metadata Server
  10. 10. this user scm is for cloudera manager
  11. 11. 部署/启动CM Server(主节点)
  12. 12. 停止iptables
  13. 13. 通过浏览器访问验证
  14. 14. 部署/启动CM Agent(从节点)
  15. 15. 停止集群步骤