[root@ip-172-31-6-148~]# service cloudera-scm-serverrestart
Stopping cloudera-scm-server: [ OK ]
Starting cloudera-scm-server: [ OK ]
[root@ip-172-31-6-148 ~]#
[root@ip-172-31-6-148html]# cd /var/www/html/
[root@ip-172-31-6-148 html]# mkdir kafka2.1.1.18
[root@ip-172-31-6-148 html]# cd kafka2.1.1.18/
[root@ip-172-31-6-148 kafka2.1.1.18]# ll
total 66536
-rw-r--r-- 1 rootroot 68116503 Mar 27 17:39 KAFKA-2.1.1-1.2.1.1.p0.18-el6.parcel
-rw-r--r-- 1 rootroot 41 Mar 27 17:39KAFKA-2.1.1-1.2.1.1.p0.18-el6.parcel.sha1
-rw-r--r-- 1 rootroot 5252 Mar 27 17:40 manifest.json
[root@ip-172-31-6-148 kafka2.1.1.18]#
3.验证是否部署成功
4.3安装Kafka服务
1.通过CM配置Kafka的Parcel包地址并保存
2.点击下载、分配并激活
3.回到CM主页,添加Kafka服务
4.选择Kafka服务,点击“继续”
5.为Kafka选择一组依赖关系,点击“继续”
6.选择Kafka Broker和Gateway,点击“继续”
7.根据集群环境修改Kafka配置,点击“继续”
8.Kafka安装完成
9.修改Kafka Broker的heap大小,默认为50M,可能会导致Kafka启动失败
保存配置,重新部署客户端并重启相应服务。 5.服务验证 5.1Kudu验证
建表语句如下:
CREATE TABLE my_first_table(
id BIGINT,
name STRING,
PRIMARY KEY(id)
)
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU;
通过Impala-shell创建Kudu表
[impala@ip-172-31-6-148root]$ impala-shell -iip-172-31-10-118.fayson.com
...
[ip-172-31-10-118.fayson.com:21000] > show tables;
Query: show tables
+------------+
| name |
+------------+
| test |
| test_table |
+------------+
Fetched 2 row(s) in 0.06s
[ip-172-31-10-118.fayson.com:21000] > CREATE TABLEmy_first_table(
> id BIGINT,
> name STRING,
> PRIMARY KEY(id)
> )
>PARTITION BY HASH PARTITIONS 16
> STORED AS KUDU;
Query: create TABLE my_first_table(
id BIGINT,
name STRING,
PRIMARY KEY(id)
)
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU
Fetched 0 row(s) in 2.43s
[ip-172-31-10-118.fayson.com:21000] >
插入数据并查询
[ip-172-31-10-118.fayson.com:21000]> insert into my_first_table values(1,'fayson');
Query: insert into my_first_table values(1,'fayson')
...
Modified 1 row(s), 0 row error(s) in 3.92s
[ip-172-31-10-118.fayson.com:21000] >select * from my_first_table;
...
+----+--------+
| id | name |
+----+--------+
| 1 | fayson |
+----+--------+
Fetched 1 row(s) in 1.02s
[ip-172-31-10-118.fayson.com:21000] >
通过Kudu Master Web UI查看
5.2Spark2验证
[root@ip-172-31-6-148~]# spark2-shell
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). ForSparkR, use setLogLevel(newLevel).
17/09/11 09:46:22 WARN spark.SparkContext: Support for Java 7 is deprecated as of Spark 2.0.0
Spark context Web UI available at http://172.31.6.148:4040
Spark context available as 'sc' (master = yarn, app id =application_1505121236974_0001).
Spark session available as 'spark'.
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/__/ '_/
/___/ .__/\_,_/_//_/\_\ version 2.1.0.cloudera1
/_/
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_67)
Type in expressions tohave them evaluated.
Type :help for more information.
scala> var textFile=sc.textFile("/fayson/test/a.txt")
textFile: org.apache.spark.rdd.RDD[String] =/fayson/test/a.txt MapPartitionsRDD[1] at textFile at :24
scala> textFile.count()
res0: Long = 3
scala>
5.3Kafka验证
1.创建一个test的topic
[root@ip-172-31-6-148hive]# kafka-topics --create--zookeeper ip-172-31-6-148.fayson.com:2181 --replication-factor 3 --partitions1 --topic test
2.向topic发送消息
[root@ip-172-31-6-148hive]# kafka-console-producer--broker-list ip-172-31-10-118.fayson.com:9092 --topic test
3.消费topic的消息
[root@ip-172-31-6-148hive]# kafka-console-consumer --zookeeperip-172-31-6-148.fayson.com:2181 --topic test --from-beginning
4.查看topic描述信息
[root@ip-172-31-6-148hive]# kafka-topics --describe--zookeeper ip-172-31-6-148.fayson.com:2181 --topic test