A:本脚本运行的机器,Linux RHEL6
B,C,D,...:待安装zookeeper cluster的机器, Linux RHEL6
首先在脚本运行的机器A上确定可以ssh无密码登录到待安装zk的机器B,C,D,...上,然后就可以在A上运行本脚本:
复制代码 代码如下:
$ ./install_zookeeper
前提:
B, C, D机器必须配置好repo,本脚本使用的是cdh5的repo, 下面的内容保存到:/etc/yum.repos.d/cloudera-cdh5.repo:
复制代码 代码如下:
[cloudera-cdh5]
# Packages for Cloudera's Distribution for Hadoop, Version 5, on RedHat or CentOS 6 x86_64
name=Cloudera's Distribution for Hadoop, Version 5
baseurl=http://archive.cloudera.com/cdh5/redhat/6/x86_64/cdh/5/
gpgkey = http://archive.cloudera.com/cdh5/redhat/6/x86_64/cdh/RPM-GPG-KEY-cloudera
gpgcheck = 1
enabled = 1
自动安装脚本将自动在B,C,D机器上安装好zookeeper, 配置好相关配置文件。但没有启动它们。支持1,3,5,7个服务器。
复制代码 代码如下:
#!/bin/bash
#
# @file
# install_zookeeper.sh
#
# @date
# 2014-12-21
#
# @author
# cheungmine@hgdb.net
#
# @version
# 0.0.1pre
#
# @usage
# ./install_zookeeper.sh
################################################################################
#***********************************************************
# split_to_array
# split string into array
#***********************************************************
function split_to_array() {
OLD_IFS="$IFS"
IFS="$2"
array=($1)
IFS="$OLD_IFS"
}
#***********************************************************
# install_zookeeper
# install zookeeper on 1, 3 or 5 servers
#
# Parameters:
# clientPort - the port at which the clients will connect to
# servers - varying arguments: 1, 3, 5, up to 7
# "zkServer:serverPort:appPort"
# zkServer - ipaddr of zookeeper server
# serverPort - communication port for zookeeper servers
# appPort - communication port between zookeeper with other applications
#
# Example:
# 1) install_zookeeper 2181 zk1 zk2 zk3
# 2) install_zookeeper 2181 192.168.122.201 192.168.122.202 192.168.122.203
# 3) install_zookeeper "2181" "192.168.122.201:2888:3888" "192.168.122.202:2888:3888" "192.168.122.203:2888:3888"
# 4) install_zookeeper "2181:/var/lib/zookeeper" "192.168.122.201:2888:3888" "192.168.122.202:2888:3888" "192.168.122.203:2888:3888"
#***********************************************************
ERR_INVALID_ZK_SERVERS=1001
function install_zookeeper() {
echo -e "<INFO> install zookeeper on cluster ..."
#chk_root
local ret clientPort dataDir len i ZOO_CFG server serverPort appPort destip destlogin
serverPort=2888
appPort=3888
# parse the first argument
split_to_array $1 ":"
# the port at which the clients will connect
clientPort=${array[0]}
# the directory where the snapshot is stored
dataDir="/var/lib/zookeeper"
if [ ${#array[*]} -eq 2 ]; then
dataDir=${array[1]}
fi
echo -e "<INFO> clientPort: $clientPort"
echo -e "<INFO> dataDir: $dataDir"
# zookeeper configure file
ZOO_CFG="/usr/lib/zookeeper/conf/zoo.cfg"
# get list of servers: args
shift
local argc=$#
if [ $argc -eq 1 -o $argc -eq 3 -o $argc -eq 5 -o $argc -eq 7 ]; then
echo -e "<INFO> zookeeper servers in cluster: [$argc]"
else
echo -e "<ERROR> invalid zookeeper servers: [$argc]"
exit $ERR_INVALID_ZK_SERVERS;
fi
local argv="$@"
OLD_IFS="$IFS"
IFS=" "
local args=($argv)
IFS="$OLD_IFS"
# array variable
local ipaddrs=()
local servers=()
local sid=0
for a in ${args[@]}
do
let sid++
# check if server format is either of:
# serverIP
# or:
# serverIP:serverPort:appPort
split_to_array $a ":"
serverIP=${array[0]}
if [ ${#array[*]} -ne 3 ]; then
a="$serverIP:$serverPort:$appPort";
fi
local server="server.$sid=$a"
servers[sid-1]=$server
echo $server
ipaddrs[sid-1]=$serverIP
done
# output array to one line string: echo ${servers[@]}
# get length of array
len=${#servers[*]}
i=0
while [ $i -lt $len ]
do
let sid=i+1
destip=${ipaddrs[$i]}
destlogin=root@$destip
echo -e "<INFO> configuring server.$sid: $destip ...\c"
ret=`ssh $destlogin "yum install -y zookeeper zookeeper-server && service zookeeper-server init --myid=$sid"`
ret=`ssh $destlogin "echo '#!{{install_zookeeper@hgdb.net==>' $ZOO_CFG"`
for s in ${servers[*]}
do
ret=`ssh $destlogin "echo '$s' $ZOO_CFG"`
done
ret=`ssh $destlogin "echo '#!<==install_zookeeper@hgdb.net}}' $ZOO_CFG"`
echo -e "OK."
let i++
done
echo "<INFO> zookeeper cluster installation completed successfully!"
}
#=======================================================================
install_zookeeper "2181" "192.168.122.201" "192.168.122.202" "192.168.122.203"
根据配置修改最后一行:
复制代码 代码如下:
install_zookeeper "2181" "192.168.122.201" "192.168.122.202" "192.168.122.203"
注意:需要把zk-cluster的每台机器上的防火墙停掉,再启动zookeeper:
复制代码 代码如下:
$ /usr/lib/zookeeper/bin/zkServer.sh start-foreground
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]