1 概述
本文档描述CENTOS6.5操作系统部署CDH企业版的过程。Cloudera企业级数据中心的安装主要分为4个步骤:
1.集群服务器配置,包括安装操作系统、关闭防火墙、同步服务器时钟等;
2.外部数据库安装
3.安装Cloudera管理器;
4.安装CDH集群;
这篇文档将着重介绍Cloudera管理器与CDH的安装,并基于以下假设:
1.操作系统版本:CENTOS6.5
2.MySQL数据库版本为5.1.73
3.CM版本:CM 5.12.0
4.CDH版本:CDH 5.12.0
5.Kudu版本:1.4
6.采用root对集群进行部署
7.您已经下载CDH和CM的安装包
2 前期准备
1.集群中各个节点之间能互相通信使用静态IP地址。IP地址和主机名通过/etc/hosts配置,主机名/etc/HOSTNAME进行配置。
以cm节点为例:
/etc/hosts文件如下:
172.31.8.113 cdh1
172.31.14.96 cdh2
172.31.9.234 cdh3
172.31.2.34 cdh4
2.配置ntp时间同步,将172.31.8.113机器作为本地ntp服务器,其他3台机器与其保持同步,配置片段:
172.31.8.113:
$> sudo vim
/etc/ntp.conf
server 127.127.1.0 # local clock (LCL)
fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
其他机器:
$> sudo vim
/etc/ntp.conf
# server
127.127.1.0
# local clock (LCL)
# fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
server 172.31.8.113 iburst
重启所有机器的ntp服务:
service ntpd restart
验证始终同步:ntpq -p
3.关闭防火墙:
在每台机器上运行下列命令
service iptables stop
chkconfig iptables off
vim /etc/selinux/config改为SELINUX=disabled
检查所有机器:以cdh1示例
安装httpd服务:
[root@cdh1 ~]# yum -y install httpd
4.安装mysql。
[root@cdh1
~]# yum -y install mysql
[root@cdh1 ~]# yum -y install mysql-server
启动mysql并配置mysql
[root@cdh1 ~]# service mysqld start
[root@cdh1 ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.This is intended only for testing, and to make the installation
go a bit smoother.You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'.This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access.This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done!If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
建立CM和Hive需要的表
[root@cdh1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 8
create database metastore default character set utf8;
CREATE USER 'hive'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON metastore. * TO 'hive'@'%';
FLUSH
PRIVILEGES;
create database cm default character set utf8;
CREATE USER 'cm'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON cm. * TO 'cm'@'%';
FLUSH PRIVILEGES;
create database am default character set utf8;
CREATE USER 'am'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON am. * TO 'am'@'%';
FLUSH PRIVILEGES;
create database rm default character set utf8;
CREATE USER 'rm'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON rm. * TO 'rm'@'%';
FLUSH
PRIVILEGES;
安装jdbc驱动:
[root@cdh1 ~]# mv mysql-connector-java-5.1.34.jar /usr/share/java/
[root@cdh1 ~]# ln -s mysql-connector-java-5.1.34.jar mysql-connector-java.jar
dctest01:/usr/share/java # ll
总用量944
-rwxr-xr-x 1 root root 9603723月16 15:58 mysql-connector-java-5.1.34.jar
lrwxrwxrwx 1 root root313月16 16:15 mysql-connector-java.jar -> mysql-connector-java-5.1.34.jar
3 cloudera manager 安装
配置本地repo源,将Cloudera Manager安装需要的7个rpm包下载到本地,放在同一目录,执行createrepo命令生成rpm元数据:
[root@cdh1 cm5.12.0]# ll
total 958396
-rw-r--r-- 1 root root9674128 Jul7 04:35 cloudera-manager-agent-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
-rw-r--r-- 1 root root 726564488 Jul7 04:35 cloudera-manager-daemons-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
-rw-r--r-- 1 root root8704 Jul7 04:35 cloudera-manager-server-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
-rw-r--r-- 1 root root10608 Jul7 04:36 cloudera-manager-server-db-2-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
-rw-r--r-- 1 root root31880440 Jul7 04:36 enterprise-debuginfo-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
-rw-r--r-- 1 root root71204325 Jul7 04:36 jdk-6u31-linux-amd64.rpm
-rw-r--r-- 1 root root 142039186 Jul7 04:35 oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm
[root@cdh1 cm5.12.0]# createrepo .
Spawning worker 0 with 7 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
配置Web服务器,比如apache2、nginx等,将上述目录移动到Web服务器数据目录,这里为/var/www/html,使得用户可以通过HTTP访问这些rpm包。
验证安装JDK
yum -y install oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm
通过yum安装Cloudera Manager Server
yum -y install cloudera-manager-server-5.12.0-1.cm5120.p0.120.el6.x86_64.rpm
初始化数据库
sudo /usr/share/cmf/schema/scm_prepare_database.sh mysql cm cm password
JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:/usr/java/jdk1.7.0_67-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[main] DbCommandExecutorINFOSuccessfully connected to database.
All done, your SCM database is configured correctly!
启动Cloudera Manager Server
[root@cdh1 init.d]# service cloudera-scm-server start
这个服务启动比较慢,稍微等几分钟,等可以看到7180端口,就可以了
[root@cdh1 cm5.12]# netstat -lnpt | grep 7180
tcp00 0.0.0.0:71800.0.0.0:*LISTEN1524/java
通过http://54.169.251.123:7180/cmf/login访问CM
4 CDH安装
1.admin/admin登录到CM。
2.点击继续
3.输入主机ip或者名称,点击搜索找到主机后点击继续
4.点击“更多选项”
5.点击“-”删除其他所有地址,输入http://54.169.251.123/cdh5.12/和http://54.169.251.123/kudu1.4/点击确定
6.输入cm的http地址
7.安装jdk
8.输入root密码
9.开始安装cloudera manager相关到各台节点
10.开始安装cdh和Kudu到各台节点
11.主机检查,点击继续
12.选择需要安装的服务
13.分配角色
14.测试数据库连接,点击继续
15.设置目录
16.等待各个服务启动
17.安装成功
5 Kudu配置
在CM界面添加服务,选择Kudu
分配主机角色
配置相应的目录
点击继续启动Kudu服务
添加Kudu服务成功,安装完毕
6 快速组件服务验证
1.MapReduce验证
#增加用户组
[root]$ groupadd cloudera-dev
#增加用户
[root]$ useradd -g cloudera-dev cloudera-dev
#查看用户组cloudera-dev中的所有用户
[root]$ id -g cloudera-dev
#查看用户cloudera-dev所属的所有组
[root]$ id cloudera-dev
# Hadoop创建相应的用户
[root]$ sudo -u hdfs hadoop fs -mkdir /user/cloudera-dev
[root]$ sudo -u hdfs hadoop fs -chown cloudera-dev:cloudera-dev /user/cloudera-dev
#运行Hadoop wordcount示例程序
[root]$ sudo su cloudera-dev
[cloudera-dev]$ echo "Hello World Bye World" > file0
[cloudera-dev]$ echo "Hello Hadoop Goodbye Hadoop" > file1
[cloudera-dev]$ hadoop fs -mkdir -p /user/cloudera-dev/wordcount/input
[cloudera-dev]$ hadoop fs -put file* /user/cloudera-dev/wordcount/input
[cloudera-dev]$ hadoop jar /opt/cloudera/parcels/CDH/jars/hadoop-examples.jar wordcount wordcount/input wordcount/output
[cloudera-dev]$ hadoop fs -getmerge wordcount/output output.txt
[cloudera-dev]$ cat output.txt
2.Hive验证
[root]$ sudo su cloudera-dev
[cloudera-dev]$ echo "Alex,Cloudera" > file2
[cloudera-dev]$ hadoop fs -mkdir -p hive/input
[cloudera-dev]$ hadoop fs -put file2 hive/input
[cloudera-dev]$ cat > test.hql
create external table test (
name string,
company string
)
row format delimited
fields terminated by ','
location '/user/cloudera-dev/hive/input'
[cloudera-dev]$ hive -f test.hql
[cloudera-dev]$ hive -e "select * from test" 2> /dev/null
[cloudera-dev]$ hive -e "select count(*) from test" 2> /dev/null
[cloudera-dev]$ hive -e "drop table test"
[cloudera-dev]$ exit
3.HBase验证
[cloudera-dev]$ cat > test.hbase
create 'record', {NAME => 'user'}
put 'record', 'Alex', 'user:company', 'Cloudera'
get 'record', 'Alex'
exit
[cloudera-dev]$ hbase shell test.hbase
[cloudera-dev]$ hbase shell
hbase(main):001:0> disable 'record'
0 row(s) in 2.6130 seconds
hbase(main):002:0> drop 'record'
0 row(s) in 1.2880 seconds
#运行Hive Over HBase测试(Read & Write)
[cloudera-dev]$ cat test.hbase
create 'record', {NAME => 'user'}
put 'record', 'Alex', 'user:company', 'Cloudera'
get 'record', 'Alex'
exit
[cloudera-dev]$ hbase shell test.hbase
[cloudera-dev]$ cat readHiveOverHbase.hql
create external table test (name string, company string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping" = ":key,user:company")
tblproperties ("hbase.table.name" = "record");
[cloudera-dev]$ hive -f readHiveOverHbase.hql
[cloudera-dev]$ hive -e "select * from test" 2> /dev/null
[cloudera-dev]$ hive -e "select count(*) from test" 2> /dev/null
[cloudera-dev]$ cat writeHiveOverHbase.hql
create table test1 (name string, firm string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping" = ":key,user:firm")
tblproperties ("hbase.table.name" = "record1");
[cloudera-dev]$ hive -f writeHiveOverHbase.hql
[cloudera-dev]$ hive -e "insert overwrite table test1 select name, company from test"
[cloudera-dev]$ hbase shell
hbase(main):001:0> list
TABLE
record
record1
2 row(s) in 0.2400 seconds
=> ["record", "record1"]
hbase(main):002:0> scan 'record1'
ROWCOLUMN+CELL
Alexcolumn=user:firm, timestamp=1500707374796, value=Cloudera
1 row(s) in 0.1360 seconds
4. Kudu验证
先在Impala的高级配置中配置Kudu Master地址:
--kudu_master_hosts=cdh1:7051
[root@cdh1 ~]# impala-shell -i cdh4
[cdh4:21000] > CREATE TABLE my_first_table
> (
> id BIGINT,
> name STRING,
> PRIMARY KEY(id)
> )
> PARTITION BY HASH PARTITIONS 16
> STORED AS KUDU;
[cdh4:21000] > INSERT INTO my_first_table VALUES (99,"sarah");
[cdh4:21000] > INSERT INTO my_first_table VALUES (1,"john"),(2,"jane"),(3,"jim");
[cdh4:21000] > select * from my_first_table;
[cdh4:21000] > delete from my_first_table where id =99;
[cdh4:21000] > select * from my_first_table;
[cdh4:21000] > INSERT INTO my_first_table VALUES (99,"sarah");
[cdh4:21000] > update my_first_table set name='lilei' where id=99;
[cdh4:21000] > select * from my_first_table;
[cdh4:21000] > upsertinto my_first_table values(1, "john"), (4, "tom"), (99, "lilei1");
[cdh4:21000] > select * from my_first_table;