Zookeeper-3.4.9

下载Zookeeper-3.4.9

在/usr/local下创建hadoop文件夹

将下载的文件迁移到该文件夹下,并解压

 tar -zxvf zookeeper-3.4.9.tar.gz

进入conf配置文件夹

 cd zookeeper-3.4.9/conf/

复制zoo_sample.cfg文件并命名为zoo.cfg

 cp zoo_sample.cfg zoo.cfg

打开zoo.cfg,修改内容

#dataDir=/tmp/zookeeper
dataDir=/usr/local/hadoop/zookeeper-3.4.9/data
dataLogDir=/usr/local/hadoop/zookeeper-3.4.9/logs

修改后的完整内容:

# 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=/tmp/zookeeper
dataDir=/usr/local/hadoop/zookeeper-3.4.9/data # 数据持久化路径
dataLogDir=/usr/local/hadoop/zookeeper-3.4.9/logs # 日志保存路径 # 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的环境变量,打开/etc/profile文件,并在末尾添加以下内容:

# idea - zookeeper-3.4.9 config start
export ZOOKEEPER_HOME=/usr/local/hadoop/zookeeper-3.4.9/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
# idea - zookeeper-3.4.9 config start

添加后的完整内容:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
} if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi # Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done unset i
unset -f pathmunge export JAVA_HOME=/usr/local/jdk/jdk1.8.0_121
export JRE_HOME=/usr/local/jdk/jdk1.8.0_121/jre
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin # idea - zookeeper-3.4.9 config start
export ZOOKEEPER_HOME=/usr/local/hadoop/zookeeper-3.4.9/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
# idea - zookeeper-3.4.9 config start

使环境变量生效

 source /etc/profile

启动Zookeeper服务:

[root@localhost ~]#  zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查询Zookeeper状态:

[root@localhost ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone

停止Zookeeper服务:

[root@localhost ~]# zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

重启Zookeeper服务:

[root@localhost ~]# zkServer.sh restart
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /usr/local/hadoop/zookeeper-3.4.9/data # 数据持久化路径/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

设置为开机自启动:(都是网上找的,没有操作!)

方法1:

/etc/rc.d/rc.local

添加:

su -root -c '//usr/local/services/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start'

方法2:

在/etc/rc.d/init.d文件夹下创建zookeeper文件

赋予操作权限

[root@localhost init.d]# touch zookeeper
[root@localhost init.d]# chmod +x zookeeper
[root@localhost init.d]# ls
functions netconsole network README redis_6379 zookeeper
[root@localhost init.d]# ls -a
. .. functions netconsole network README redis_6379 zookeeper
[root@localhost init.d]# ls -all
总用量 40
drwxr-xr-x. 2 root root 99 4月 10 21:24 .
drwxr-xr-x. 10 root root 4096 4月 9 23:08 ..
-rw-r--r--. 1 root root 15131 9月 12 2016 functions
-rwxr-xr-x. 1 root root 2989 9月 12 2016 netconsole
-rwxr-xr-x. 1 root root 6643 9月 12 2016 network
-rw-r--r--. 1 root root 1160 3月 3 11:23 README
-rwxr-xr-x. 1 root root 1702 4月 8 22:52 redis_6379
-rwxr-xr-x. 1 root root 0 4月 10 21:24 zookeeper
[root@localhost init.d]# chkconfig -add zookeeper
-add: 未知的选项
[root@localhost init.d]# chkconfig --add zookeeper

zookeeper文件内容:

#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
start) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh start;;
stop) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh stop;;
status) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh status;;
restart) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac

将zookeeper添加到开机启动里面

chkconfig --add zookeeper

开机启动:

chkconfig zookeeper on

======

Centos7.2安装zookeeper3.5.2-alpha

为了测试Curator3.2.1,重新安装zookeeper-3.5.2-alpha.tar.gz

操作与上面一样,只是换了文件夹名称为zookeeper

[root@localhost conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Error contacting service. It is probably not running.
[root@localhost conf]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START

解决:

查看logs里面的日志:

[root@localhost zookeeper-3.5.]# cd logs
[root@localhost logs]# ls
version- zookeeper-hongdada-server-localhost.localdomain.out
[root@localhost logs]# vi version-
[root@localhost logs]# vi zookeeper-hongdada-server-localhost.localdomain.out

logs:

-- ::, [myid:] - ERROR [main:ZooKeeperServerMain@] - Unable to start AdminServer, exiting abnormally
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port and command URL /commands
at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:)
Caused by: java.net.BindException: 地址已在使用
at sun.nio.ch.Net.bind0(Native Method)

很明显是由于端口占用。我服务器中的tomcat占用了8080端口,而zookeeper最近的版本中有个内嵌的管理控制台是通过jetty启动,也会占用8080 端口。

通过查看zookeeper的官方文档,发现有3种解决途径:

(1).删除jetty。

(2)修改端口。

修改方法的方法有两种,一种是在启动脚本中增加 -Dzookeeper.admin.serverPort=你的端口号.一种是在zoo.cfg中增加admin.serverPort=没有被占用的端口号

(3)停用这个服务,在启动脚本中增加"-Dzookeeper.admin.enableServer=false"

在zoo.cfg中添加配置admin.serverPort=2182

修改后的zoo.cfg

# The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes. #dataDir=/tmp/zookeeper
dataDir=/usr/local/hadoop/zookeeper-3.4./data
dataLogDir=/usr/local/hadoop/zookeeper-3.4./logs # the port at which the clients will connect
clientPort=
admin.serverPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
"zoo.cfg" 33L, 1045C

启动:

[root@localhost hadoop]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process .
[root@localhost hadoop]# zkServer
bash: zkServer: 未找到命令...
[root@localhost hadoop]# zkServer.sh --version
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Usage: /usr/local/hadoop/zookeeper//bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}
[root@localhost hadoop]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Mode: standalone

http://blog.csdn.net/cg_perfect/article/details/53053060

http://www.procedurego.com/article/58182.html

http://www.cnblogs.com/hapday/p/5617730.html

http://m.blog.csdn.net/article/details?id=52313834

http://jingyan.baidu.com/article/fec7a1e5136c571190b4e720.html

http://blog.csdn.net/xiaoyu411502/article/details/51441890

https://www.cnblogs.com/feiye512/p/5923683.html

CentOS7.2 安装zookeeper3.4.9的更多相关文章

  1. 在 CentOS7 上安装 zookeeper-3.4.9 服务

    在 CentOS7 上安装 zookeeper-3.4.9 服务 1.创建 /usr/local/services/zookeeper 文件夹: mkdir -p /usr/local/service ...

  2. Linux CentOS7下安装Zookeeper-3.4.10服务(最新)

    Linux CentOS7下安装Zookeeper-3.4.10服务(最新) 2017年10月27日 01:25:26 极速-蜗牛 阅读数:1933   版权声明:本文为博主原创文章,未经博主允许不得 ...

  3. 在 CentOS7 上安装 zookeeper-3.5.2 服务

    [root@centos-linux src]# pwd /usr/local/src # 1.创建 /usr/local/src/zookeeper 文件夹 [root@centos-linux s ...

  4. 在CentOS7上安装JDK1.8

    在CentOS7上安装JDK1.8 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建目录 to ...

  5. centos7 Linux 安装jdk1.8

    在CentOS7上安装JDK1.8 1 通过 xshell 连接到CentOS7 服务器: 2 进入到目录 /usr/local/ 中(一般装应用环境我们都会在这个目录下装,也可自行选择目录): cd ...

  6. Hive(二)CentOS7.5安装Hive2.3.3

    一 Hive的下载 软件下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hive/  这里下载的版本是:apache-hive-2.3.3-bin.t ...

  7. 在CentOS7上安装和使用ZooKeeper最新版本(V3.4.12)

    0.ZooKeeper文档 http://zookeeper.apache.org/doc/r3.4.11/zookeeperOver.html 1.准备 在CentOS7上安装zookeeper时, ...

  8. 如何在Centos7上安装zookeeper 多实例

    一.如何在Centos7上安装zookeeper 多实例 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...

  9. centos7上安装zookeeper

    centos7上安装zookeeper 1 准备工作 1.准备服务器,本次安装采用 centos7系统.内存2G.存储60G的虚拟机服务器一台: 2.服务器安装java环境: 参考文章<cent ...

随机推荐

  1. Eclipse failed to get the required ADT version number from the sdk

    failed to get the required ADT version number from the sdk 解决方法: eclipse 和 android studio 工具不能同时共用同一 ...

  2. 图片上传转base64

    代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title ...

  3. (分解质因数模板)求 1~r 内与 n 互素的元素个数

    void Solve(LL n){ ///分解质因数保存结果于p p.clear(); ; i*i<=n; i++) ){ p.push_back(i); ) n/=i; } ) p.push_ ...

  4. Rsync匿名访问漏洞

    前言 前两天总结了互联网或者说IT公司内网常见的漏洞,然后决定针对还没学习过不了解的漏洞进行学习了解,所以准备一一针对来研习,今天是第一篇,立一个Flag,争取今年搞定,为啥说的这么艰难,因为平时工作 ...

  5. 第k最短路A*启发式搜索

    Remmarguts' Date Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 21549   Accepted: 5862 ...

  6. Drools规则引擎

    一.简介 Drools is a Business Rules Management System (BRMS) solution. It provides a core Business Rules ...

  7. K-均值聚类(K-means)算法

    https://www.cnblogs.com/ybjourney/p/4714870.html 最近在看<机器学习实战>这本书,因为自己本身很想深入的了解机器学习算法,加之想学pytho ...

  8. yii2框架(一)安装

    手动安装下载yii2basic出现以下错误 2 修改 G:\learn\yii-basic-app-2.0.11\basic\config下web.conf 为cookieValidationKey设 ...

  9. Python并行编程(十二):进程同步

    1.基本概念 多个进程可以协同工作来完成一项任务,通常需要共享数据.所以在多进程之间保持数据的一致性就很重要,需要共享数据协同的进程必须以适当的策略来读写数据.同步原语和线程的库类似. - Lock: ...

  10. WPF自定义代码启动应用程序启动方式

    删除app.xaml 添加App.cs类 第一种方式: class App    {        [STAThread]        static void Main()        {     ...