spark--环境搭建--5.kafka_292-081集群搭建

Posted _殇j

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spark--环境搭建--5.kafka_292-081集群搭建相关的知识,希望对你有一定的参考价值。

1. scala安装

$ cd /usr/local

$ tar -zxvf scala-2.11.4.tgz

$ mv scala-2.11.4 scala

$ vi ~/.bashrc

export SCALA_HOME=/usr/local/scala/
export PATH=$PATH:$SCALA_HOME/bin/

$ source ~/.bashrc

$ scala -version

$ scp -r scala [email protected]:/usr/local/

$ scp -r scala [email protected]:/usr/local/

$ scp ~/.bashrc [email protected]:~/.bashrc

$ scp ~/.bashrc [email protected]:~/.bashrc

# 2和3分别执行 source ~/.bashrc

2. kafka安装

$ tar -zxvf kafka_2.9.2-0.8.1.tgz

$ mv kafka_2.9.2-0.8.1 kafka

$ vi kafka/config/server.properties

# 修改
broker.id=0  #(2和3机器分别修改为1和2) zookeeper.connect=192.168.2.100:2181,192.168.2.101:2181,192.168.2.102:2181

$ yum install unzip

$ unzip slf4j-1.7.6.zip

$ cp slf4j-1.7.6/slf4j-nop-1.7.6.jar kafka/libs/

$ rm -rf slf4j-1.7.6

$ scp -r kafka [email protected]:/usr/local/

$ scp -r kafka [email protected]:/usr/local/

# 注意修改2和3的server.properties的配置

3. 启动kafka集群

$ cd kafka

$ nohup bin/kafka-server-start.sh config/server.properties &

$ jps

# 若没启动查看

$ cat nohup.out

# 解决kafka Unrecognized VM option ‘UseCompressedOops‘问题(三台机器分别执行)

$ vi bin/kafka-run-class.sh

# 删除红色部分
# JVM performance options if [ -z "$KAFKA_JVM_PERFORMANCE_OPTS" ]; then KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseCompressedOops -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSScavengeBeforeRemark -XX:+DisableExplicitGC -Djava.awt.headless=true" fi

$ nohup bin/kafka-server-start.sh config/server.properties &

4. 测试kafka集群

$ bin/kafka-topics.sh --zookeeper 192.168.2.100:2181,192.168.2.101:2181,192.168.2.102:2181 --topic TestTopic --replication-factor 1 --partitions 1 --create

$ bin/kafka-console-producer.sh --broker-list 192.168.2.100:9092,192.168.2.101:9092,192.168.2.102:9092 --topic TestTopic

$ bin/kafka-console-consumer.sh --zookeeper 192.168.2.100:2181,192.168.2.101:2181,192.168.2.102:2181 --topic TestTopic --from-beginning

 

以上是关于spark--环境搭建--5.kafka_292-081集群搭建的主要内容,如果未能解决你的问题,请参考以下文章

搭建Spark所遇过的坑

Windows10搭建spark环境

01_PC单机Spark开发环境搭建_JDK1.8+Spark2.3.1+Hadoop2.7.1

Kafka:ZK+Kafka+Spark Streaming集群环境搭建安装kafka_2.11-1.1.0

spark 入门及集群环境搭建

spark环境搭建(idea版本)