注意: php
1:版本目錄作了軟連接,如 ln -s hbase-0.94.6 hbase node
2: 要根據實際狀況,將/usr/local/修改成hbase所在的目錄 算法
#!/bin/bash # copy a new release of HBase from the masternode to all slave nodes # 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..."; 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."
注意: shell
1:版本目錄作了軟連接,如 ln -s hbase-0.94.6 hbase bash
2: 要根據實際狀況,將/usr/local/修改成hbase所在的目錄 ssh
#!/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..."; 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."
Rsync(remote synchronize)是一個遠程數據同步工具,可經過LAN/WAN快速同步多臺主機間的文件。Rsync使用所謂的「Rsync算法」來使本地和遠 程兩個主機之間的文件達到同步,這個算法只傳送兩個文件的不一樣部分,而不是每次都整份傳送,所以速度至關快。 工具
rsync [OPTION]... SRC DEST rsync [OPTION]... SRC [USER@]HOST:DEST rsync [OPTION]... [USER@]HOST:SRC DEST rsync [OPTION]... [USER@]HOST::SRC DEST rsync [OPTION]... SRC [USER@]HOST::DEST rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
-v, --verbose 詳細模式輸出 oop
-a, --archive 歸檔模式,表示以遞歸方式傳輸文件,並保持全部文件屬性,等於-rlptgoD spa
-z, --compress 對備份的文件在傳輸時進行壓縮處理 code
--delete 刪除那些DST中SRC沒有的文
--exclude=PATTERN 指定排除不須要傳輸的文件模式