zookeeper安装
复制hadoop脚本文件,
删除ips中的s2 和s3
#分发zookeeper
[hadoop@nn1 zookeeper_base_op]$ sh scp_all.sh /tmp/upload/zookeeper-3.4.8.tar.gz /tmp/
#解压
[hadoop@nn1 zookeeper_base_op]$ sh ssh_root.sh tar -zxf /tmp/zookeeper-3.4.8.tar.gz -C /usr/local/
#权限
[hadoop@nn1 zookeeper_base_op]$ sh ssh_root.sh chown -R hadoop:hadoop /usr/local/zookeeper-3.4.8/
#配置软连接
[hadoop@nn1 zookeeper_base_op]$ sh ssh_root.sh ln -s /usr/local/zookeeper-3.4.8/ /usr/local/zookeeper
#权限
[hadoop@nn1 zookeeper_base_op]$ sh ssh_root.sh chown -h hadoop:hadoop /usr/local/zookeeper
[hadoop@nn1 zookeeper_base_op]$ sh ssh_root.sh chmod 770 /usr/local/zookeeper-3.4.8/
配置文件
[hadoop@nn1 zookeeper_base_op]$ cd /usr/local/zookeeper/conf/
[hadoop@nn1 conf]$ sh ~/zookeeper_base_op/ssh_all.sh rm -rf /usr/local/zookeeper/conf/zoo_sample.cfg
[hadoop@nn1 conf]$ sh ~/zookeeper_base_op/scp_all.sh /tmp/upload/zoo.cfg /usr/local/zookeeper/conf/
zookeeper配置文件信息
# 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/
# 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.1=nn1.hadoop:2888:3888
server.2=nn2.hadoop:2888:3888
server.3=s1.hadoop:2888:3888
#创建data目录 zookeeper配置的data目录(输出日志文件夹)
[hadoop@nn1 hadoop_base_op]$ sh ssh_root.sh mkdir /data
[hadoop@nn1 hadoop_base_op]$ sh ssh_root.sh chown -R hadoop:hadoop /data
#修改输出日志配置文件所在目录
[hadoop@nn1 hadoop_base_op]$ vim /usr/local/zookeeper/bin/zkEnv.sh
ZOO_LOG_DIR=/data #配置日志输出目录
---------------------------------------------------------------------------------------
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script should be sourced into other zookeeper
# scripts to setup the env variables
# We use ZOOCFGDIR if defined,
# otherwise we use /etc/zookeeper
# or the conf directory that is
# a sibling of this script's directory
ZOOBINDIR="${ZOOBINDIR:-/usr/bin}"
ZOOKEEPER_PREFIX="${ZOOBINDIR}/.."
ZOO_LOG_DIR=/data
if [ "x$ZOOCFGDIR" = "x" ]
then
if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then
ZOOCFGDIR="$ZOOBINDIR/../conf"
else
ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper"
fi
fi
if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
. "${ZOOCFGDIR}/zookeeper-env.sh"
fi
if [ "x$ZOOCFG" = "x" ]
then
-----------------------------------*-----------------------------------------------------
#分发 日志文件
[hadoop@nn1 zookeeper_base_op]$ sh ssh_all.sh /usr/local/zookeeper/bin/zkEnv.sh /usr/local/zookeeper/bin/
#创建myid文件
[hadoop@nn1 data]$ touch myid && echo 1 > myid && cat myid
1
[hadoop@nn1 data]$ ssh nn2.hadoop
[hadoop@nn2 ~]$ cd /data
[hadoop@nn2 data]$ touch myid && echo 2 > myid && cat myid
2
[hadoop@nn2 data]$ ssh s1.hadoop
[hadoop@s1 ~]$ touch myid && echo 3 > myid && cat myid
3
配置环境变量
#切换root用户,root才可以配置环境变量
[hadoop@nn1 ~]$ su root
[root@nn1 hadoop]# vim /etc/profile
#set Hadoop Path
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_COMMON_HOME=${HADOOP_HOME}
export HADOOP_HDFS_HOME=${HADOOP_HOME}
export HADOOP_MAPRED_HOME=${HADOOP_HOME}
export HADOOP_YARN_HOME=${HADOOP_HOME}
export HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
export HDFS_CONF_DIR=${HADOOP_HOME}/etc/hadoop
export YARN_CONF_DIR=${HADOOP_HOME}/etc/hadoop
export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native:/usr/lib64
export HBASE_HOME=/usr/local/hbase
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:$HIVE_HOME/bin:/usr/local/zookeeper/bin
#拷贝
[hadoop@nn1 etc]$ cp ./profile /tmp
[hadoop@nn1 etc]$ cd ~/hadoop_base_op/
[hadoop@nn1 hadoop_base_op]$ sh scp_all.sh /tmp/profile /tmp
[hadoop@nn1 hadoop_base_op]$ sh ssh_root.sh cp /tmp/profile /etc/
[hadoop@nn1 hadoop_base_op]$ sh ssh_all.sh source /etc/profile
开启zookeeper
[hadoop@nn1 zookeeper_base_op]$ sh ssh_all.sh /usr/local/zookeeper/bin/zkServer.sh start
查看zookeeper运行状态(一个leader,两个follower)
[hadoop@nn1 zookeeper]$ sh ssh_all.sh /usr/local/zookeeper/bin/zkServer.sh status
重启
[hadoop@nn1 zookeeper]$ sh ssh_all.sh /usr/local/zookeeper/bin/zkServer.sh restart