Linux下安装zookeeper

目录

1.下载zookeeper

2.安装zookeeper 

2.1上传压缩文件并解压

2.2新建zookeeper配置文件

 

  2.3配置环境变量

       2.4启动zookeeper

2.5查看zookeeper的状态


安装zookeeper前需要你安装jdk;你可以查看:
Linux系统下安装JDK,Tomcat和Mysqlhttps://blog.csdn.net/qq_23853743/article/details/84617634

1.下载zookeeper

下载地址:http://mirror.bit.edu.cn/apache/zookeeper/

 

2.安装zookeeper 

2.1上传压缩文件并解压

        这里使用的是CentOS7的操作系统。在root目录下新建一个名为albert的目录,将下载得到的zookeeper-3.4.13.tar.gz文件上传上去。

如图:

    

进入到该目录下,命令是:

       

 cd    /root/albert

执行解压命令:

       

tar -zxvf zookeeper-3.4.13.tar.gz

执行移动命令:

mv zookeeper-3.4.13 /usr/local/zookeeper

2.2新建zookeeper配置文件

         Zookeeper需要一个名为zoo.cfg的配置文件,我们解压后,得到的是官方的示例文件,名为zoo_sample.cfg,这个文件在zookeeper根目录的conf子目录下。如果我们想使用默认配置,直接将该文件复制并且改名即可。

进入zookeeper配置文件目录

[root@yxy albert]# cd /usr/local/zookeeper/conf

复制配置文件:

     

[root@yxy conf]# cp zoo_sample.cfg zoo.cfg

 

      上面的命令生成了zoo.cfg

      如图:

          

       更改配置文件:

vi zoo.cfg

 

  
2.3配置环境变量

          命令:vi  /etc/profile

[root@yxy conf]# vi /etc/profile

修改配置文件并保存:

# /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=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/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 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
# /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=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/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 ] && [ "`id -gn`" = "`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 2>&1
        fi
    fi
done

unset i
unset -f pathmunge
#set java environment
JAVA_HOME=/usr/local/src/java/jdk1.7.0_71
ZK_HOME=/usr/local/zookeeper
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$ZK_HOME/bin:$PATH
export JAVA_HOME ZK_HOME  CLASSPATH PATH

       
2.4启动zookeeper

 

执行zkServer.sh脚本进行启动,命令是:

        zkServer.sh   start

如图:

    

2.5查看zookeeper的状态

   

    执行命令查看zookeeper状态:

        zkServer.sh    status

如图:

    

standalone 是单机模式。
 

已标记关键词 清除标记
## 如题所示,设置以及出现的问题如下,求大神解答,跪求!!!! zoo.cfg如下: tickTime=2000 initLimit=10 syncLimit=5 dataDir=/usr/local/hadoop/zookeeper/data dataLogDir=/usr/local/hadoop/zookeeper/log clientPort=2184 server.1=192.168.59.10:2888:3788 server.2=192.168.59.11:2888:3788 server.3=192.168.59.12:2888:3788 启动时: JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED ![图片说明](https://img-ask.csdn.net/upload/201611/19/1479549351_651524.png) 查看状态: JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Error contacting service. It is probably not running. ![图片说明](https://img-ask.csdn.net/upload/201611/19/1479549409_73529.png) zkookeeper.out 文件如下: 2016-11-19 16:54:33,948 [myid:] - INFO [main:QuorumPeerConfig@101] - Reading configuration from: /usr/local/zookeeper/bin/../conf/zoo.cfg 2016-11-19 16:54:33,956 [myid:] - INFO [main:QuorumPeerConfig@334] - Defaulting to majority quorums 2016-11-19 16:54:33,965 [myid:1] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3 2016-11-19 16:54:33,965 [myid:1] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0 2016-11-19 16:54:33,965 [myid:1] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled. 2016-11-19 16:54:33,984 [myid:1] - INFO [main:QuorumPeerMain@132] - Starting quorum peer 2016-11-19 16:54:33,998 [myid:1] - INFO [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2184 2016-11-19 16:54:34,038 [myid:1] - INFO [main:QuorumPeer@913] - tickTime set to 2000 2016-11-19 16:54:34,038 [myid:1] - INFO [main:QuorumPeer@933] - minSessionTimeout set to -1 2016-11-19 16:54:34,038 [myid:1] - INFO [main:QuorumPeer@944] - maxSessionTimeout set to -1 2016-11-19 16:54:34,038 [myid:1] - INFO [main:QuorumPeer@959] - initLimit set to 10 2016-11-19 16:54:34,071 [myid:1] - INFO [main:QuorumPeer@429] - currentEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation 2016-11-19 16:54:34,075 [myid:1] - INFO [main:QuorumPeer@444] - acceptedEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation 2016-11-19 16:54:34,088 [myid:1] - INFO [Thread-1:QuorumCnxManager$Listener@486] - My election bind port: 0.0.0.0/0.0.0.0:3788 2016-11-19 16:54:34,102 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2184:QuorumPeer@670] - LOOKING 2016-11-19 16:54:34,103 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2184:FastLeaderElection@740] - New election. My id = 1, proposed zxid=0x0 2016-11-19 16:54:34,108 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@542] - Notification: 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEPoch), LOOKING (my state) 2016-11-19 16:54:34,113 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@368] - Cannot open channel to 2 at election address /192.168.59.11:3788 java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:327) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:393) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:365) at java.lang.Thread.run(Thread.java:745) 2016-11-19 16:54:34,117 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@368] - Cannot open channel to 3 at election address /192.168.59.12:3788 java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:327) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:393) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:365) at java.lang.Thread.run(Thread.java:745) 2016-11-19 16:54:34,313 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2184:QuorumCnxManager@368] - Cannot open channel to 2 at election address /192.168.59.11:3788 java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:388) at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:765) at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:716)
©️2020 CSDN 皮肤主题: 博客之星2020 设计师:CY__0809 返回首页