Hbase配置文件从Master到Slave同步
对于其中使用的rsync ,参见:rsync 的基本使用
#!/bin/bash # Rsyncs HBase files across all slaves. Must run on master. Assumes # all files are located in /usr/local if [ "$#" != "2" ]; then echo "usage: $(basename $0) <dir-name> <ln-name>" echo " example: $(basename $0) hbase-0.1 hbase" exit 1 fi SRC_PATH="/usr/local/$1/conf/regionservers" for srv in $(cat $SRC_PATH); do echo "Sending command to $srv..."; # –v 表示复杂的输出信息 ; -a 表示权限保存模式,相当于 -rlptgoD 参数.很快速的保存几乎所有的权限设定,除了硬式连接 ;-z 表示压缩
# 指定排除一个不需要传输的文件匹配模式
rsync -vaz --exclude='logs/*' /usr/local/$1 $srv:/usr/local/ ssh $srv "rm -fR /usr/local/$2 ; ln -s /usr/local/$1 /usr/local/$2" done echo "done."
同样的功能,下面的简单些
#!/bin/bash # Rsync's HBase config files across all region servers. Must run on master. for srv in $(cat /usr/local/hbase/conf/regionservers); do echo "Sending command to $srv...";
# ––delete 删除那些接收端还有而发送端已经不存在的文件 rsync -vaz --delete --exclude='logs/*' /usr/local/hadoop/ $srv:/usr/local/hadoop/ rsync -vaz --delete --exclude='logs/*' /usr/local/hbase/ $srv:/usr/local/hbase/ done echo "done."