1. zookeeper集群搭建
-
将zookeeper-3.4.5.tar.gz上传至/usr/local
#cd /usr/local #tar -zxvf zookeeper-3.4.5.tar.gz #mv zookeeper-3.4.5 zk
-
配置zookeeper相关的环境变量
#vi ~/.bashrc export ZOOKEEPER_HOME=/usr/local/zk export PATH=$ZOOKEEPER_HOME/bin #source ~/.bashrc
-
配置
#cd /usr/local/zk/conf #cp zoo_sample.cfg zoo.cfg #vi zoo.cfg 修改:dataDir=/usr/local/zk/data 新增: server.0=eshop-cache01:2888:3888 server.1=eshop-cache02:2888:3888 server.2=eshop-cache03:2888:3888 #增加data #cd /usr/local/zk #mkdir data #cd data # vi myid # 0(其它机器分别为1,2)
-
加入开机自启动
#vim /etc/rc.d/rc.local #/usr/local/zk/bin/zkServer.sh start #chmod +x /etc/rc.d/rc.local
-
使用
# zkServer.sh start JMX enabled by default Using config: /usr/local/zk/bin/../conf/zoo.cfg Starting zookeeper ... STARTED # zkServer.sh status JMX enabled by default Using config: /usr/local/zk/bin/../conf/zoo.cfg Mode: follower # jps 4594 QuorumPeerMain 4653 Jps
2.scala搭建
-
将scala-2.11.4.tgz上传至/usr/local
#cd /usr/local #tar -zxvf scala-2.11.4.tgz #mv scala-2.11.4 scala
-
scala相关的环境变量
#vi ~/.bashrc export SCALA_HOME=/usr/local/scala export PATH=$SCALA_HOME/bin #source ~/.bashrc
-
查看scala是否安装成功
# scala -version Scala code runner version 2.11.4 -- Copyright 2002-2013, LAMP/EPFL
3.Kafka集群搭建
-
将kafka_2.9.2-0.8.1.tgz上传至/usr/local
#cd /usr/local #tar -zxvf kafka_2.9.2-0.8.1.tgz #mv kafka_2.9.2-0.8.1 kafka
-
配置kafka
#vi /usr/local/kafka/config/server.properties broker.id:依次增长的整数,0、1、2,集群中Broker的唯一id zookeeper.connect=192.168.135.135:2181,192.168.135.132:2181,192.168.135.136:2181
-
安装slf4j
将slf4j-1.7.6.zip上传到/usr/local目录下# cd /usr/local # unzip slf4j-1.7.6.zip # cp /usr/local/slf4j-1.7.6/slf4j-nop-1.7.6.jar /usr/local/kafka/libs
-
解决kafka Unrecognized VM option 'UseCompressedOops’问题
# vi /usr/local/kafka/bin/kafka-run-class.sh 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 去掉-XX:+UseCompressedOops即可
-
加入开机自启动
#vim /etc/rc.d/rc.local #nohup /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties & #chmod +x /etc/rc.d/rc.local
-
使用
--启动 # nohup /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties & --使用jps检查启动是否成功 # jps -- 检查kafka是否搭建成功 # /usr/local/kafka/bin/kafka-topics.sh --zookeeper 192.168.135.126:2181,192.168.135.129:2181,192.168.135.130:2181 --topic test --replication-factor 1 --partitions 1 --create # /usr/local/kafka/bin/kafka-console-producer.sh --broker-list 192.168.135.126:9092,192.168.135.129:9092,192.168.135.130:9092 --topic test # /usr/local/kafka/bin/kafka-console-consumer.sh --zookeeper 192.168.135.126:2181,192.168.135.129:2181,192.168.135.130:2181 --topic test --from-beginning