脚踏实地、勇往直前!
全部博文(1005)
分类: HADOOP
2014-10-28 13:45:39
linux下安装zookeeper
环境:
OS:Rad Hat Linux As5
zookeeper-3.4.6
1.安装步骤
下载安装介质,下载地址为:
根据情况选择下载的版本,我这里下载的版本是zookeeper-3.4.6.tar.gz
使用hadoop登陆
[hadoop1@node1 ~]$ echo $HADOOP_HOME
/usr1/hadoop
将安装介质拷贝到如下的目录
[root@node1 hbase]# cp zookeeper-3.4.6.tar.gz /usr1
解压
[root@node1 usr1]# tar -zxvf zookeeper-3.4.6.tar.gz
目录改名
[root@node1 usr1]# ls
hadoop hbase hbase-0.99.1-bin.tar.gz hive zookeeper-3.4.6 zookeeper-3.4.6.tar.gz
[root@node1 usr1]# mv zookeeper-3.4.6 zookeeper
将zookeeper目录权限赋予hadoop用户
[root@node1 usr1]# chown -R hadoop1:hadoop1 ./ zookeeper
ZOOKEEPER_HOME= /usr1/zookeeper
修改后的红色标识
[hadoop1@node1 ~]$ more .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export JAVA_HOME=/usr/java/jdk1.8.0_05
export JRE_HOME=/usr/java/jdk1.8.0_05/jre
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export HADOOP_HOME=/usr1/hadoop
HIVE_HOME=/usr1/hive
ZOOKEEPER_HOME=/usr1/zookeeper
export PATH=$HADOOP_HOME/bin:$HIVE_HOME/bin:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
PATH=$PATH:$HOME/bin
export PATH
在其他所有的节点上做同样的配置
将zookeeper-3.4.3/conf目录下的zoo_sample.cfg文件拷贝一份,命名为为zoo.cfg
[hadoop1@node1 conf]$ cp zoo_sample.cfg zoo.cfg
编辑该文件,在最后面添加如下参数
server.1=192.168.56.101:2888:3888
server.2=192.168.56.102:2888:3888
server.3=192.168.56.103:2888:3888
server.4=192.168.56.104:2888:3888
dataDir=/home/hadoop1/zookeeperdir/zookeeper-data
dataLogDir=/home/hadoop1/zookeeperdir/logs
在zoo.cfg文件中定义的server机器上都创建dataDir和dataLogDir定义的目录,目录属主是hadoop,同时在dataDi目录下创建myid文件,该文件的内容根据server定义的不同而不同,如server.1 该文件的内容是1,server.2 该文件内容是 2,以此类推.
创建目录:
mkdir -p /home/hadoop1/zookeeperdir/zookeeper-data
mkdir -p /home/hadoop1/zookeeperdir/logs
节点1
echo "1">myid
节点2
echo "2">myid
节点3
echo "3">myid
节点4
echo "4">myid
主节点将zookeeper压缩
[hadoop1@node1 usr1]$ tar -cvf zookeeper.tar ./zookeeper
上传到其他的节点
scp zookeeper.tar root@192.168.56.102:/usr1
scp zookeeper.tar root@192.168.56.103:/usr1
scp zookeeper.tar root@192.168.56.104:/usr1
分别到其他节点上做加压缩,并修改权限
[root@node2 usr1]# tar -xvf zookeeper.tar
[root@node2 usr1]# chown -R hadoop1:hadoop1 ./zookeeper
在每个节点上执行(hadoop用户下执行)
进入/usr1/zookeeper/bin目录
$cd /usr1/zookeeper/bin
启动
[hadoop1@node1 bin]$ ./zkServer.sh start
JMX enabled by default
Using config: /usr1/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop1@node4 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /usr1/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[hadoop1@node1 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /usr1/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[hadoop1@node2 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /usr1/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[hadoop1@node3 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /usr1/zookeeper/bin/../conf/zoo.cfg
Mode: follower
-- The End --