目录
一、通过源码部署zkui
1、环境准备
zkui源码需要从git获取源码,zkui源码要Maven编译,同时zk运行依赖java环境,所以需要先准备好相关环境。
2、部署zkui
#下载zkui 程序包
# git clone https://github.com/DeemOpen/zkui.git
#编译zkui,生成jar包,zkui源码需要Maven编译
# cd zkui/
# mvn clean install
# ll target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
3、修改配置
主要配置介绍:
- serverPort zkui的监听端口
- zkServer 管理zk,zk集群可以用逗号隔开
- userSet zkui的用户设置,role可以设置为ADMIN、USER,ADMIN有增删改的权限,USER只可以查看
# vim zkui/config.cfg
#Server Port
serverPort=9090
#Comma seperated list of all the zookeeper servers
#zkServer=10.121.31.85:2181
zkServer=192.168.1.100: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":"manager","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=3000
#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=500
#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
nohup java -jar zkui/target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &
二、通过docker启动zkui
1、拉取镜像
docker pull qnib/zkui
2、启动zkui
- ZKUI_ZK_SERVER 管理zk,zk集群可以用逗号隔开
- ZKUI_ADMIN_PW 修改默认管理员的密码
- ZKUI_USER_PW 修改默认普通用户的密码
$ docker run -d --restart=always --name zkui -p 9090:9090 -e ZKUI_ZK_SERVER=<external_DNS/IP>:2181 qnib/zkui
三、登录zkui
1、URL
http://IP:9090
2、账号密码
默认账号/密码,管理员admin/manager
,普通用户appconfig/appconfig
四、管理zk
1、手动管理zk
Add Node
增加节点
Add Property
增加zk的键值对
Delete
删除节点或者键值对
2、导入导出zk
Import
导入zk数据
#数据格式
/appconfig/path=property=value
#删除数据
-/path/property
Export
到出zk数据