记一下zookeeper集群搭建

1.分别在node1、node2、node3的根目录下新建data文件夹,然后在其下新建zookeeper文件夹并在其下新建data文件夹和dataLog文件夹,创建myid文件
cd /
mkdir data
cd /data
mkdir zookeeper
cd zookeeper
mkdir data
mkdir dataLog
cd /data/zookeeper/data
在node1上执行echo 1 > myid
在node2上执行echo 2 > myid
在node3上执行echo 3 > myid

3.将zookeeper安装包,以apache-zookeeper-3.8.0-bin.tar.gz为例分别上传至node1、node2、node3的/opt/soft路径下并解压
cd /opt/soft
tar -zxvf apache-zookeeper-3.8.0-bin.tar.gz

4.在三台服务器上配置zookeeper配置文件
/opt/soft/apache-zookeeper-3.8.0-bin/conf/
cp zoo_sample.cfg zoo.cfg
vi 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=/data/zookeeper/data
dataLogDir=/data/zookeeper/dataLog
# 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
server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888

5.分别在分别在三台服务器上进入zookeeper安装包bin目录,启动zookeeper
cd /opt/soft/apache-zookeeper-3.8.0-bin/bin/
./zkServer.sh start

6.分别在三台服务器上查看集群状态
./zkServer.sh status
如果有一个是leader,另外两个是follower,那就对了

7.在node1上安装zkui,用于查看zookeeper集群
1.在 /opt/soft文件夹下建zkui文件夹
cd /opt/soft
mkdir zkui
cd zkui
2.将下载好的zkui-2.0-SNAPSHOT-jar-with-dependencies.jar上传到zkui中
3.新建配置文件config.cfg
内容为:
#Server Port
serverPort=9090
#Comma seperated list of all the zookeeper servers
zkServer=localhost:2181
#Http path of the repository. Ignore if you dont intent to upload files from repository.
scmRepo=http://myserver.com/@rev1=
#Path appended to the repo url. Ignore if you dont intent to upload files from repository.
scmRepoPath=//appconfig.txt
#if set to true then userSet is used for authentication, else ldap authentication is used.
ldapAuth=false
ldapDomain=mycompany,mydomain
#ldap authentication url. Ignore if using file based authentication.
ldapUrl=ldap://<ldap_host>:<ldap_port>/dc=mycom,dc=com
#Specific roles for ldap authenticated users. Ignore if using file based authentication.
ldapRoleSet={"users": [{ "username":"domain\\user1" , "role": "ADMIN" }]}
userSet = {"users": [{ "username":"admin" , "password":"admin","role": "ADMIN" },{ "username":"appconfig" , "password":"appconfig","role": "USER" }]}
#Set to prod in production and dev in local. Setting to dev will clear history each time.
env=prod
jdbcClass=org.h2.Driver
jdbcUrl=jdbc:h2:zkui
jdbcUser=root
jdbcPwd=manager
#If you want to use mysql db to store history then comment the h2 db section.
#jdbcClass=com.mysql.jdbc.Driver
#jdbcUrl=jdbc:mysql://localhost:3306/zkui
#jdbcUser=root
#jdbcPwd=manager
loginMessage=Please login using admin/manager or appconfig/appconfig.
#session timeout 5 mins/300 secs.
sessionTimeout=300
#Default 5 seconds to keep short lived zk sessions. If you have large data then the read will take more than 30 seconds so increase this accordingly. 
#A bigger zkSessionTimeout means the connection will be held longer and resource consumption will be high.
zkSessionTimeout=5
#Block PWD exposure over rest call.
blockPwdOverRest=false
#ignore rest of the props below if https=false.
https=false
keystoreFile=/home/user/keystore.jks
keystorePwd=password
keystoreManagerPwd=password
# The default ACL to use for all creation of nodes. If left blank, then all nodes will be universally accessible
# Permissions are based on single character flags: c (Create), r (read), w (write), d (delete), a (admin), * (all)
# For example defaultAcl={"acls": [{"scheme":"ip", "id":"192.168.1.192", "perms":"*"}, {"scheme":"ip", id":"192.168.1.0/24", "perms":"r"}]
defaultAcl=
# Set X-Forwarded-For to true if zkui is behind a proxy
X-Forwarded-For=false

4.启动zkui jar包
nohup java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &
5.可访node1:9090 用户名密码为admin/admin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值