一、配置JDK
1、解压缩。创建软连接。
tar -zxvf jdk1.8.0_51.tar.gz
ln -s jdk1.8.0_51 jdk
2、配置环境变量。
vi ~/.bashrc
export JAVA_HOME=/home/hadoop/app/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib
3、使环境变量生效。
source ~/.bashrc
4、检查JDK是否安装成功。
5、hadoop02和hadoop03节点重复1-4步操作,即可完成整个集群的JDK安装配置。
二、ZooKeeper集群的安装部署
1、解压缩。创建软连接。
tar -zxvf zookeeper-3.4.6.tar.gz
ln -s zookeeper-3.4.6 zookeeper
2、创建一个配置文件zoo.cfg,并保存在conf目录中。
# The number of milliseconds of each tick #这个时间是作为Zookeeper服务器之间或客户端与服务器之间维持心跳的时间间隔 tickTime=2000 # The number of ticks that the initial # synchronization phase can take #配置 Zookeeper 接受客户端初始化连接时最长能忍受多少个心跳时间间隔数。 initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement #Leader 与 Follower 之间发送消息,请求和应答时间长度 syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. #数据目录需要提前创建 dataDir=/home/hadoop/data/zookeeper/zkdata #日志目录需要提前创建 dataLogDir=/home/hadoop/data/zookeeper/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.每个节点服务编号=服务器ip地址:集群通信端口:选举端口 server.1=hadoop01:2888:3888 server.2=hadoop02:2888:3888 server.3=hadoop03:2888:3888
3、创建数据目录和日志目录(hadoop01、hadoop02、hadoop03三个节点都需要操作)。
mkdir -p /home/hadoop/data/zookeeper/zkdata
mkdir -p /home/hadoop/data/zookeeper/zkdatalog
4、为ZooKeeper集群各个节点创建服务编号。
[root@hadoop01 zkdata] echo 1 > myid
[root@hadoop02 zkdata] echo 2 > myid
[root@hadoop03 zkdata] echo 3 > myid
5、启动ZooKeeper集群。Mode:leaer(领导者)。Mode:follower(跟随者)。
6、进入Zookeeper命令行。
bin/zkCli.sh -server localhost:2181
7、节点操作。
创建新的znode
create /test jiangzhihao
获取znode值
get /test
重新设置zk的值
set /test hello
删除znode节点
delete /test