kafka单机部署

1.java部署

2.zookeeper部署


3.kafka部署:


# tar -xzvf jdk-8u192-linux-x64.tar.gz  -C /usr/local/

# cat /etc/profile.d/java.sh 
export JAVA_HOME=/usr/local/jdk1.8.0_192
export PATH=$JAVA_HOME/bin:$PATH

# vim /etc/profile.d/java.sh
[root@tidb jdk1.8.0_192]# source  /etc/profile.d/java.sh 
[root@tidb jdk1.8.0_192]# java -version
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


 tar -xzvf zookeeper-3.4.12.tar.gz  -C /usr/local/
  mv zookeeper-3.4.12/ zookeeper
  [root@tidb conf]# vim /etc/profile.d/zookeeper.sh
[root@tidb conf]# source /etc/profile.d/zookeeper.sh 
# cat /etc/profile.d/zookeeper.sh       
export ZOOKEEPER=/usr/local/zookeeper
export PATH=$PATH:$ZOOKEEPER/bin

  # cp zoo_sample.cfg zoo.fg
  # mkdir -p /data/zookeeper/{data,log}
  
配置文件:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/data/zookeeper/data
logDir=/data/zookeeper/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1

  
  说明:其中:
2888端口号是zookeeper服务之间通信的端口。
3888是zookeeper与其他应用程序通信的端口。
[root@tidb conf]# touch /data/zookeeper/data/myid
[root@tidb conf]# echo 1 > /data/zookeeper/data/myid 

--启动zookeeper
# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@tidb conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: standalone
[root@tidb conf]# jps
21905 Jps
21850 QuorumPeerMain
--编写自启动的zookeeper程序:
# vim /etc/init.d/zookeeper.sh
chkconfig zookeeper on  
chkconfig --add zookeeper
  
 tar -xzvf kafka_2.12-1.1.1.tgz  -C /usr/local/
 mv kafka_2.12-1.1.1/ kafka
 
 # cat /etc/profile.d/kafka.sh 
export KAFKA_HOME=/usr/local/kafka
export PATH=$PATH:$KAFKA_HOME/bin


/usr/local/kafka/config
 vim server.properties
 log.dirs=/data/kafka/kafka-logs
 zookeeper.connect=172.17.14.19:2181


--启动:
 --启动:
 # kafka-server-start.sh /usr/local/kafka/config/server.properties  &
 # jps
22617 Jps
21850 QuorumPeerMain
22285 Kafka

--后台启动:
nohup bin/kafka-server-start.sh config/server.properties > kafka-run.log 2>&1 &


4.kafka验证:
--创建主题:
创建kafka主题:
kafka-topics.sh --create --zookeeper 172.17.14.19:2181 --replication-factor 1 --partitions 1 --topic top
查询kafka的主题:
kafka-topics.sh -list -zookeeper 172.17.14.19:2181
创建kafka生产者:
kafka-console-producer.sh --broker-list 172.17.14.19:9092 --topic top
>Java
>python
>quit
 

创建kafka消费者:
# kafka-console-consumer.sh --zookeeper 172.17.14.19:2181 --topic top --from-beginning
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
Java
python
quit

 

你可能感兴趣的:(Kafka)