zookeeper 安装
环境机器三台,系统centos6.5最小安装, 最好先关闭iptables,等部署好以后在安装需求打开.
10.221.8.220
10.221.8.221
10.221.8.222
第一步 准备需要的安装包
zookeeper: http://apache.fayea.com/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
linux 系统使用wget下载jdk,是个很操蛋的事情. .... 最后google到了一个解决办法.
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"
第二步安装
1:安装jdk (解压配置好环境变量即可)
export JAVA_HOME=/usr/share/jdk1.6.0_35
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
2:安装zookeeper (解压即可, 我把它移动到 /usr/local/下面)
第一步:修改zookeeper的配置文件 (三台机器的配置都一样)
vi /usr/local/zookeeper-3.3.6/conf/zoo.cfg
# 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.
dataDir=/tmp/zookeeper #存放数据的目录
dataLogDir=/usr/local/zookeeper-3.3.6/logs
# the port at which the clients will connect
clientPort=2181
server.1=Redis1:2888:3888 #server.1 决定了后面这个主机(Redis1)里面的zookeeper的myid文件里面的内容
server.2=Redis2:2888:3888
server.3=Redis3:2888:3888
第二步: 创建目录与文件 (处了myid 文件里面的内容不样,其他都一样.)
mkdir /usr/local/zookeeper-3.3.6/logs
mkdir /tmp/zookeeper
touch /tmp/zookeeper/myid
echo 1 > /tmp/zookeeper/myid # 各个机器上的zookeeper的myid文件里面的内容是由配置文件里面这一行( server.1=Redis1:2888:3888 )配置来决定的. 我的这个机器的hostname 是 Redis1 所以使用server.1的这个1
3 启动zookeeper
/usr/local/zookeeper-3.3.6/bin/zkServer.sh start
/usr/local/zookeeper-3.3.6/bin/zkServer.sh status #查看状态正常情况如下
JMX enabled by default
Using config: /usr/local/zookeeper-3.3.6/bin/../conf/zoo.cfg
Mode: leader #也可能是其他角色