zookeeper 可视化界面(zkui)搭建与配置

  • Post author:
  • Post category:其他


准备环境

zookeeper可视化WEB工具 zkui 依赖java环境,因此需要安装JDK,zkui 源码需要maven编译,需要安装Apache-maven。

1、JDK 1.8 :JDK下载地址 ​

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html”>​


​https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html​

​​

或者安装openJDK ,命令如下:

yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

2、maven 3.0.5 :Apache-maven下载地址 ​

https://maven.apache.org/download.cgi”>​


​https://maven.apache.org/download.cgi​

​​

3、centos 7,xshell,xftp

(1)设置环境变量

执行命令 vim /etc/profile 在文件末尾添加如下:

# set for nginx

PATH=$PATH:/usr/local/nginx/sbin

export PAT

#zookeeper-3.4.14 config start

export ZOOKEEPER_HOME=/usr/local/services/zookeeper-3.4.14

export PATH=$ZOOKEEPER_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$ZOOKEEPER_HOME/lib:

export ZOOKEEPER_HOME

export JAVA_HOME

export PATH

export CLASSPATH

export PATH

#zookeeepr-3.4.14 config end

查看版本号:

[root@localhost services]# java -version

openjdk version “1.8.0_262”

OpenJDK Runtime Environment (build 1.8.0_262-b10)

OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

[root@localhost services]# mvn -v

Apache Maven 3.0.5 (Red Hat 3.0.5-17)

Maven home: /usr/share/maven

Java version: 1.8.0_262, vendor: Oracle Corporation

Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre

Default locale: zh_CN, platform encoding: UTF-8

OS name: “linux”, version: “3.10.0-1127.el7.x86_64”, arch: “amd64”, family: “unix”

[root@localhost services]#

搭建zkui

1、下载zkui

git clone https://github.com/DeemOpen/zkui.git

[root@localhost zkui]# ll

总用量 100

-rw-r–r–. 1 root root 2364 8月 12 10:53 config.cfg

drwxr-xr-x. 2 root root 61 8月 12 10:28 docker

drwxr-xr-x. 2 root root 114 8月 12 10:28 images

-rw-r–r–. 1 root root 11358 8月 12 10:28 LICENSE-2.0.txt

-rw-r–r–. 1 root root 416 8月 12 10:28 Makefile

-rw-r–r–. 1 root root 1746 8月 12 10:28 nbactions.xml

-rw——-. 1 root root 2103 8月 15 08:00 nohup.out

-rw-r–r–. 1 root root 5294 8月 12 10:28 pom.xml

-rw-r–r–. 1 root root 6216 8月 12 10:28 README.md

-rw-r–r–. 1 root root 43 8月 12 10:28 run.sh

drwxr-xr-x. 4 root root 30 8月 12 10:28 src

drwxr-xr-x. 9 root root 264 8月 12 11:10 target

-rw-r–r–. 1 root root 43008 8月 15 08:00 zkui.h2.db

-rw-r–r–. 1 root root 5008 8月 15 08:01 zkui-out.log

[root@localhost zkui]#

2、编译zkui,生成jar包

[root@localhost services]# cd zkui/

[root@localhost zkui]# mvn clean install

……………………………编译过程省略……………………………………

[INFO] — maven-install-plugin:2.4:install (default-install) @ zkui —

[INFO] Installing /App/zkui/target/zkui-2.0-SNAPSHOT.jar to /root/.m2/repository/com/deem/zkui/2.0-SNAPSHOT/zkui-2.0-SNAPSHOT.jar

[INFO] Installing /App/zkui/pom.xml to /root/.m2/repository/com/deem/zkui/2.0-SNAPSHOT/zkui-2.0-SNAPSHOT.pom

[INFO] Installing /App/zkui/target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar to /root/.m2/repository/com/deem/zkui/2.0-SNAPSHOT/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar

[INFO] ————————————————————————

[INFO] BUILD SUCCESS

[INFO] ————————————————————————

[INFO] Total time: 17.670 s

[INFO] Finished at: 2019-04-15T09:57:44+08:00

[INFO] ————————————————————————

编译成功后,会生成两个jar包,zkui-2.0-SNAPSHOT.jar 和zkui-2.0-SNAPSHOT-jar-with-dependencies.jar。使用的是第二个jar包。


[root@localhost zkui]# cd target

[root@localhost target]# ll

总用量 8420

drwxr-xr-x. 2 root root 6 8月 12 10:57 archive-tmp

drwxr-xr-x. 5 root root 101 8月 12 10:57 classes

drwxr-xr-x. 4 root root 49 8月 12 10:57 generated-sources

drwxr-xr-x. 2 root root 28 8月 12 10:57 maven-archiver

-rw——-. 1 root root 355 8月 12 11:14 nohup.out

drwxr-xr-x. 2 root root 6 8月 12 10:57 surefire

drwxr-xr-x. 2 root root 89 8月 12 10:57 surefire-reports

drwxr-xr-x. 3 root root 17 8月 12 10:57 test-classes

-rw-r–r–. 1 root root 277164 8月 12 10:57 zkui-2.0-SNAPSHOT.jar

-rw-r–r–. 1 root root 8336868 8月 12 10:57 zkui-2.0-SNAPSHOT-jar-with-dependencies.jar

-rw-r–r–. 1 root root 0 8月 12 11:09 zkui-out.log

[root@localhost target]#

3、修改配置文件

修改zkui的配置文件 config.cfg ,config.cfg 文件中配置了 zkui 需要连接的 zookeeper 集群的 IP 地址和端口,访问 zkui 的用户名和密码,以及 zkui 监听的端口号。


#Server Port

serverPort=9090

#Comma seperated list of all the zookeeper servers

zkServer=192.168.198.x:2181,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”:”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=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

注意:

  • 如果zookeeper和zkui安装在同一台机器上,不需要修改config.cfg 配置文件也可启动。
  • 默认用户信息:

    账号 root,密码 manager (Admin权限,支持CRUD操作)

    账号 appconfig ,密码 appconfig (Readonly权限,支持读取操作)
  • LDAP的配置

    如果想使用 LDAP 身份验证,则提供 LDAP url。

    这将优先于 roleSet property 文件认证。

    ldapUrl=ldap://<ldap_host>:<ldap_port>/dc=mycom,dc=com

    如果不提供此功能,则将使用默认 roleSet 文件认证。

4、启动zkui


[root@localhost zkui]# nohup java -jar target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &

[2] 1948

[root@localhost zkui]# nohup: 忽略输入并把输出追加到”nohup.out”

nohup: ignoring input and appending output to ‘nohup.out’

-bash: nohup:: 未找到命令

[root@localhost zkui]# netstat -tunpl |grep :9090

tcp6 0 0 :::9090 :::* LISTEN 1694/java

[root@localhost zkui]#

浏览器访问 http://192.168.198.128:9090/login 账号admin,密码manager 即可看到zkui的管理界面。

(注意开放端口9090,访问之前注意关闭防火墙)