目录
1.下载zookeeper
2.安装zookeeper 
2.1上传压缩文件并解压
2.2新建zookeeper配置文件
 2.3配置环境变量
 2.4启动zookeeper
2.5查看zookeeper的状态
安装zookeeper前需要你安装jdk;你可以查看:
Linux系统下安装JDK,Tomcat和Mysql:
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/zookeeper2.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 PATH2.4启动zookeeper
执行zkServer.sh脚本进行启动,命令是:
zkServer.sh start
如图:
    
2.5查看zookeeper的状态
执行命令查看zookeeper状态:
zkServer.sh status
如图:
    
standalone 是单机模式。










