wxs@ubuntu:~$ sudo tar zxf zookeeper-3.5.2-alpha.tar.gz wxs@ubuntu:~$ sudo mv zookeeper-3.5.2-alpha /usr wxs@ubuntu:~$ cd /usr/zookeeper-3.5.2-alpha wxs@ubuntu:/usr/zookeeper-3.5.2-alpha$ ls bin ivysettings.xml recipes build.xml ivy.xml src CHANGES.txt lib zookeeper-3.5.2-alpha.jar conf LICENSE.txt zookeeper-3.5.2-alpha.jar.asc contrib NOTICE.txt zookeeper-3.5.2-alpha.jar.md5 dist-maven README_packaging.txt zookeeper-3.5.2-alpha.jar.sha1 docs
在 zookper 文件夹下建立 logs 文件夹和 data 文件夹用于存放日志和数据:
1 2
wxs@ubuntu:/usr/zookeeper-3.5.2-alpha$ sudo mkdir data wxs@ubuntu:/usr/zookeeper-3.5.2-alpha$ sudo mkdir logs
进入 conf 目录,复制一份 zoo_sample.cfg 为 zoo.cfg,对其进行修改:
1 2 3
wxs@ubuntu:/usr/zookeeper-3.5.2-alpha$ cd conf/ wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/conf$ cp zoo_sample.cfg zoo.cfg wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/conf$ vim zoo.cfg
wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/bin$ ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/zookeeper-3.5.2-alpha/bin/../conf/zoo.cfg Starting zookeeper ... STARTED wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/bin$ ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/zookeeper-3.5.2-alpha/bin/../conf/zoo.cfg Client port found: 2181. Client address: localhost. Mode: standalone
@GetMapping("/{id}") public TbItem getItemById(@PathVariable Long id){ TbItem item = null; if(id != null) { item = tbItemService.selectById(id); }
return item; } }
五、测试
服务器上分别启动 zookper 和 tomcat:
1 2 3 4 5 6 7 8 9
wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/bin$ ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/zookeeper-3.5.2-alpha/bin/../conf/zoo.cfg Starting zookeeper ... STARTED wxs@ubuntu:/usr/zookeeper-3.5.2-alpha/bin$ ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/zookeeper-3.5.2-alpha/bin/../conf/zoo.cfg Client port found: 2181. Client address: localhost. Mode: standalone
1 2 3 4 5 6 7
wxs@ubuntu:/usr/apache-tomcat-8.5.28/bin$ ./startup.sh Using CATALINA_BASE: /usr/apache-tomcat-8.5.28 Using CATALINA_HOME: /usr/apache-tomcat-8.5.28 Using CATALINA_TMPDIR: /usr/apache-tomcat-8.5.28/temp Using JRE_HOME: /usr/jdk1.8.0_161/jre Using CLASSPATH: /usr/apache-tomcat-8.5.28/bin/bootstrap.jar:/usr/apache-tomcat-8.5.28/bin/tomcat-juli.jar Tomcat started.