centos-试试zookeeper集群部署
zookeeper简介
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。
实验环境介绍
Linux:centos6
192.168.122.90 server1
192.168.122.91 server2
192.168.122.92 server3
安装jdk
解压jdk压缩包到/opt/jdk
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
tar zxvf jdk-8u111-linux-x64.tar.gz
mv jdk1.8.0_111 /opt/jdk
## 创建普通用户运行zookeeper
useradd zk
修改文件句柄和进程限制,并修改hosts
echo '192.168.122.90 server1' >> /etc/hosts
echo '192.168.122.91 server2' >> /etc/hosts
echo '192.168.122.92 server3' >> /etc/hosts
echo 'zk soft nproc 65535 ' >> /etc/security/limits.conf
echo 'zk hard nproc 65535 ' >> /etc/security/limits.conf
echo 'zk soft nofile 65535 ' >> /etc/security/limits.conf
echo 'zk hard nofile 65535 ' >> /etc/security/limits.conf
修改环境变量
su - zk
echo 'export JAVA_HOME=/opt/jdk' >> /home/zk/.bash_profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /home/zk/.bash_profile
. /home/zk/.bash_profile
下载zookeeper并解压安装
下载地址:http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
tar zxvf zookeeper-3.4.9.tar.gz
mv zookeeper-3.4.9 /opt/
cd /opt
ln -s zookeeper-3.4.9 zookeeper
修改配置文件
cd /opt/zookeeper/conf
cp zoo_sample.cfg zoo.cfg
vim 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeperData
dataLogDir=/data/zkdatalog
# 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
# server.A=B:C:D
# A是一个数字,表示这个是第几号服务器;
# B是这个服务器的IP地址(或者是与IP地址做了映射的主机名);
# C第一个端口用来集群成员的信息交换,表示这个服务器与集群中的Leader服务器交换信息的端口;
# D是在leader挂掉时专门用来进行选举leader所用的端口。
server.1=server1:12888:13888
server.2=server2:12888:13888
server.3=server3:12888:13888
创建目录并修改权限
su - root
mkdir -p /data/zookeeperData
mkdir -p /data/zkdatalog
chown zk.zk /data/zookeeperData /data/zkdatalog -R
设置ID
echo 1 >> /data/zookeepereData/myid
启动zookeeper
su - zk
/opt/zookeeper/bin/zkServer.sh start
请先 后发表评论~