首页 技术 正文
技术 2022年11月8日
0 收藏 890 点赞 1,188 浏览 5802 个字

********************单节点安装zk*************************
上传zk安装包到服务器/mnt目录下:

[root@chavin ~]$ ll /mnt/zookeeper-3.4.5.tar.gz
-rw-r–r–. 1 root root 16402010 Mar 11 15:33 /mnt/zookeeper-3.4.5.tar.gz

解压安装文件并更改权限:

[root@chavin mnt]$ tar -zxvf zookeeper-3.4.5.tar.gz -C /usr/local/
[root@chavin zookeeper-3.4.5]$ cd /usr/local/
[root@chavin local]$ chown -R hadoop:hadoop zookeeper-3.4.5/

编辑配置文件:
[hadoop@chavin zookeeper-3.4.5]$ mkdir -p data/zkdata
[hadoop@chavin zookeeper-3.4.5]$ cd data/zkdata/
[hadoop@chavin zkdata]$ pwd
/usr/local/zookeeper-3.4.5/data/zkdata
[hadoop@chavin zkdata]$ cd ../../conf/
[hadoop@chavin conf]$ cp zoo_sample.cfg zoo.cfg
[hadoop@chavin conf]$ cat 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目录##################################
dataDir=/usr/local/zookeeper-3.4.5/data/zkdata
###############################################配置dataDir目录##################################
# the port at which the clients will connect
clientPort=2181
#
# 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

启动zkserver:

[hadoop@chavin zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED
[hadoop@chavin zookeeper-3.4.5]$ jps
55039 QuorumPeerMain
55058 Jps

[hadoop@chavin zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: standalone
[hadoop@chavin zookeeper-3.4.5]$ bin/zkCli.sh
Connecting to localhost:2181
… …

至此,单节点zk服务器安装完成.

********************************集群模式安装zk****************************************

上传zk安装包到节点1的/mnt目录下:
[root@db01 ~]# cd /mnt
[root@db01 mnt]# ll zookeeper-3.4.5.tar.gz
-rw-r–r–. 1 root root 16402010 Mar 11 23:35 zookeeper-3.4.5.tar.gz

解压安装文件并更改权限:

[root@chavin mnt]$ tar -zxvf zookeeper-3.4.5.tar.gz -C /usr/local/
[root@chavin zookeeper-3.4.5]$ cd /usr/local/
[root@chavin local]$ chown -R hadoop:hadoop zookeeper-3.4.5/

编辑配置文件:
[hadoop@chavin zookeeper-3.4.5]$ mkdir -p data/zkdata
[hadoop@chavin zookeeper-3.4.5]$ cd data/zkdata/
[hadoop@chavin zkdata]$ pwd
/usr/local/zookeeper-3.4.5/data/zkdata
[hadoop@chavin zkdata]$ cd ../../conf/
[hadoop@chavin conf]$ cp zoo_sample.cfg zoo.cfg
[root@db01 conf]# cat 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.
#######################cluster#########################################
dataDir=/usr/local/zookeeper-3.4.5/data/zkdata
server.1=db01:2888:3888
server.2=db02:2888:3888
server.3=db03:2888:3888
server.4=db04:2888:3888
server.5=db05:2888:3888
#######################cluster#########################################
# the port at which the clients will connect
clientPort=2181
#
# 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
[root@db01 conf]#

编辑myid文件:

[root@db01 zkdata]# pwd
/usr/local/zookeeper-3.4.5/data/zkdata
[root@db01 zkdata]# touch myid
[root@db01 zkdata]# vim myid
[root@db01 zkdata]# cat myid
1

同步安装目录:

[root@db01 local]# scp -r zookeeper-3.4.5/ db02:/usr/local/
[root@db01 local]# scp -r zookeeper-3.4.5/ db03:/usr/local/
[root@db01 local]# scp -r zookeeper-3.4.5/ db04:/usr/local/
[root@db01 local]# scp -r zookeeper-3.4.5/ db05:/usr/local/

修改相应用户所有者权限:

[root@db01 local]# chown -R hadoop:hadoop zookeeper-3.4.5/
[root@db02 local]# chown -R hadoop:hadoop zookeeper-3.4.5/
[root@db03 local]# chown -R hadoop:hadoop zookeeper-3.4.5/
[root@db04 local]# chown -R hadoop:hadoop zookeeper-3.4.5/
[root@db05 local]# chown -R hadoop:hadoop zookeeper-3.4.5/

修改各个服务器的myid文件:

db01      1
db02      2
db03      3
db04      4
db05      5

分别启动zk集群服务器:

[hadoop@db01 zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@db02 zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@db03 zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@db04 zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

[hadoop@db05 zookeeper-3.4.5]$ bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

查看各个节点状态:

[hadoop@db01 zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

[hadoop@db02 zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

[hadoop@db03 zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader

[hadoop@db04 zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

[hadoop@db05 zookeeper-3.4.5]$ bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,965
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,781