zookeeper安装教程

前言:
zookeeper依赖于Java环境
准备工作
zookeeper包,Java的jdk
安装步骤
一、java安装
Ubuntu 16.04下Java环境安装与配置

1、下载jdk8
登录网址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
选择对应jdk版本下载

2、解压
tar -zxvf jdk-8u144-linux-x64.tar.gz

3、然后将文件夹jdk1.8.0_144移动到目录/opt下
sudo mv jdk1.8.0_144 /opt/

4、修改环境变量
sudo vi ~/.bashrc
在最末尾添加如下配置:

#set Java environment
export JAVA_HOME=/opt/jdk1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
注意:不能空行

5、保存并退出,使用source命令使之生效

source ~/.bashrc

6、查看安装情况
java -version

配置环境变量
https://blog.csdn.net/gaoanchen/article/details/77692451
二、zookeeper
环境搭建
Ubuntu 14.04.5 LTS
zookeeper-3.4.6
jdk1.7.0_76
安装
下载zookeeper包,由于apache官方网络慢,我们选择从华科大的镜像地址进行下载
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
1
解压zookeeper到/usr/local
tar -xzvf zookeeper-3.4.6.tar.gz -C /usr/local
cd /usr/local/zookeeper-3.4.6
1
2
拷贝一份zookeeper的配置文件,zoo_sample.cfg => zoo.cfg
cd conf
cp zoo_sample.cfg zoo.cfg
1
2
变更zoo.cfg配置
vi zoo.cfg
1
主要更改zookeeper的数据存放地址和日志地址

dataDir=/HD/logs/zookeeper
dataLogDir=/HD/logs/zookeeper
1
2

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=/HD/logs/zookeeper
dataLogDir=/HD/logs/zookeeper

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

启动zookeeper
cd ../bin

sh zkServer.sh start //启动
sh zkServer.sh status //检查状态
sh zkServer.sh stop //停止

检查zookeeper启动状态
ps -ef|grep zookeeper
1
遇到的问题
root@127.0.0.1:/usr/local/zookeeper-3.4.6# sh bin/zkServer.sh start
JMX enabled by default
bin/zkServer.sh: 95: /usr/local/zookeeper-3.4.6/bin/zkEnv.sh: Syntax error: “(“ unexpected (expecting “fi”)

百度得到的答案是Ubuntu的默认shell有问题,把dash改成bash就可以了

root@127.0.0.1:~# cd /bin/
root@127.0.0.1:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec 23 22:30 /bin/sh -> dash(默认)
root@127.0.0.1:/bin# ln -sf bash /bin/sh
root@127.0.0.1:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec 23 22:37 /bin/sh -> bash

重启解决

三、root权限更新

一、Ubuntu的
默认root密码是随机的,即每次开机都有一个新的root密码。我们可以在终端输入命令 sudo passwd,然后输入当前用户的密码,enter,

二、终端会提示我们输入新的密码并确认,此时的密码就是root新密码。修改成功后,输入命令 su root,再输入新的密码就ok了

三 、分析没有默认的,因为你还没给root设置密码,第一个 user 是在 admin 组 ,所以他可以给 root 设置密码 , so
sudo passwd root
[sudo] password for you :—> 输入你的密码,不会显示

Enter new UNIX password:

— > 设置root 密码
Retype new UNIX password:

–> 重复

用安装时建立的用户登陆后在Shell执行
sudo passwd root回车Password:

后输入刚建立的用户密码回车
Enter new UNIX password:

这时输入要设置的root密码两次就会看到

password updated successfully了!

安装后可以到用户和组里面去改,随便改的。要在登录时用root的话,可以在“登录界面”里改,让管理员登录系统的选项就可以了

来源: https://blog.csdn.net/zrxx01/article/details/80521256

https://www.cnblogs.com/freescience/p/7272070.html

http://rayfuxk.iteye.com/blog/2279596

http://www.mamicode.com/info-detail-2243059.html

https://blog.csdn.net/u011404265/article/details/72869920
https://blog.csdn.net/sunxiaoju/article/details/51994559
https://www.linuxidc.com/Linux/2017-02/140908.htm
https://www.linuxidc.com/Linux/2017-02/140138.htm
http://www.mamicode.com/info-detail-2243059.html
https://blog.csdn.net/wangyonglin1123/article/details/44959585


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以邮件至 chaofa_vip@126.com

文章标题:zookeeper安装教程

文章字数:976

本文作者:Hechaofa

发布时间:2018-09-13, 10:13:47

最后更新:2020-09-17, 20:59:58

原始链接:https://chaofavip.github.io/2018/09/13/tool/zookeeper/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏