CentOS6.5安装CDH5.12.0和Kudu1.4

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;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,362评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,330评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,247评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,560评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,580评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,569评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,929评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,587评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,840评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,596评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,678评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,366评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,945评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,929评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,165评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,271评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,403评论 2 342

推荐阅读更多精彩内容