1.安裝JDK 目前官網不能直接下載,在網上找到1.8.0版本安裝包下載到本地。 1.1.下載jdk並解壓 1.2.配置java環境變數 在文件中/etc/profile追加配置: 使配置生效 1.3.驗證jdk是否安裝成功 2.安裝zookeeper 2.1.下載 http://zookeeper ...
1.安裝JDK
目前官網不能直接下載,在網上找到1.8.0版本安裝包下載到本地。
1.1.下載jdk並解壓
[root@iz2zei2y693gtrgwlibzlwz java]# ls jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz
1.2.配置java環境變數
在文件中/etc/profile追加配置:
export JAVA_HOME=/usr/local/java/jdk1.8.0_191 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
使配置生效
[root@iz2zei2y693gtrgwlibzlwz java]# source /etc/profile
1.3.驗證jdk是否安裝成功
[root@iz2zei2y693gtrgwlibzlwz java]# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
2.安裝zookeeper
2.1.下載
http://zookeeper.apache.org/releases.html
2.2.解壓
tar –zxvf zookeeper-3.4.10.tar.gz
2.3.複製conf目錄下的zoo_sample.cfg,並命名為zoo.cfg
2.4.修改zoo.cfg配置文件
# 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=/usr/local/zookeeper/zookeeper-3.4.10/data
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.10/logs
# 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,3888 are election port
server.1=39.**.**.**:2888:3888 #改成自己ip
其中,2888埠號是服務之間通信的埠,而3888是;zookeeper與其他應用程式通信的埠.
2.5.創建myid文件
創建dataDir參數指定的目錄(這裡指的是“/usr/local/zookeeper/zookeeper-3.4.10/data”),併在目錄下創建文件,命名為“myid”。
2.6.編輯myid文件
在對應的IP的機器上輸入對應的編號。如在zookeeper上,“myid”文件內容就是1。由於本次只在單點上進行安裝配置,所以只有一個server.1。若還有其他伺服器,比如地址為192.168.1.102,則在zoo.cfg文件中還需加入server.2=192.168.1.102:2888:3888。那麼myid文件在192.168.1.102伺服器上的內容就是2。至此,如果是多伺服器配置,就需要將zookeeper-3.4.3目錄拷貝到其他伺服器,然後按照上述的方法修改myid。
2.7.在/etc/profile文件設置PATH
在profile文件尾追加:
export PATH=$PATH:/usr/local/zookeeper/zookeeper-3.4.10/bin
安裝完畢!
2.8.啟動
zkServer.sh start
輸入jps命令查看進程
1573 QuorumPeerMain 1654 Jps
其中,QuorumPeerMain是zookeeper進程,啟動正常。
查看狀態:zkServer.sh status
- JMX enabled by default Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg Mode: standalone
啟動客戶端腳本:zkCli.sh -server ip:2181
停止zookeeper進程:zkServer.sh stop
3.安裝kafka
下載地址:https://mirrors.cnnic.cn/apache/kafka
3.1.下載kafka
wget https://mirrors.cnnic.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz
解壓
tar -zxvf kafka_2.12-1.1.0.tgz
3.2.配置kafka環境變數
在/etc/profile文件中追加配置:
export KAFKA_HOME=/usr/local/kafka/kafka_2.11-2.1.0 export PATH=$KAFKA_HOME/bin:$PATH
使配置生效
[root@iz2zei2y693gtrgwlibzlwz kafka]# source /etc/profile
3.3.驗證kafka是否安裝成功
[root@iz2zei2y693gtrgwlibzlwz kafka]# echo $KAFKA_HOME /usr/local/kafka/kafka_2.11-2.1.0
3.4.修改kafka配置文件中以下配置
broker.id=0 listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://你的ip:9092 zookeeper.connect=localhost:2181
3.4.啟動kafka服務
[root@iz2zei2y693gtrgwlibzlwz config]# kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
[root@iz2zei2y693gtrgwlibzlwz config]# jps 24177 QuorumPeerMain 899 Kafka 8506 Jps
3.4.關閉服務
先關閉kafka,在關閉zookeeper
kafka-server-stop.sh
zookeeper-server-stop.sh
查看服務是否已關閉
[root@localhost ~]# jps 15462 Jps