Hadoop cluster configuration Zookeeper

Unzip and install

Unzip the zookeeper compressed package to the specified directory

tar -zxvf zookeeper-3.5.7.tar.gz -C /opt/module/

Configure server number

1) Create zkData in the /opt/module/zookeeper-3.5.7/ directory

# 如果是存在之前的zkData,注意要删除zkData中的所有文件
 mkdir -p zkData

2) Create a myid file in the /opt/module/zookeeper-3.5.7/zkData directory

 touch myid

3) Edit the myid file and add the number corresponding to the server in the file


vi myid

#将其设置为2,分发时需要修改编号
2

vi myid

Configure zoo.cfg

1) Rename the zoo_sample.cfg in the directory /opt/module/zookeeper-3.5.7/conf to zoo.cfg
2) Modify the zoo.cfg file configuration

vim zoo.cfg

#修改数据存储路径配置
dataDir=/opt/module/zookeeper-3.5.7/zkData
#添加,2888是Follower与leader通信端口,3888是选举leader的端口
server.2=192.168.1.102:2888:3888
server.3=192.168.1.103:2888:3888
server.4=192.168.1.104:2888:3888

Placement script

Create a new script zkcluster in the bin directory, instead of opening the zookeeper service one by one server

#!/bin/bash
if [ $# -ne 1 ]
	then
		echo "input error"
		exit
fi


for host in hadoop102 hadoop103 hadoop104
do
	
  echo "===========================$host==========================="
	
	case $1 in 
	
	"start")	
		ssh $host zkServer.sh $1
		;;
	
	"stop")
		ssh $host zkServer.sh $1
		;;
		
	"status")
		ssh $host zkServer.sh $1
		;;
		
	*)
        	echo "args info is error!!!"
        	;;
			
  esac
	
done


Guess you like

Origin blog.csdn.net/qq_38705144/article/details/111587799