在多數集群中,節點的配置必須保持一致,一旦管理節點修改了配置,就需要把配置同步到其他節點,通常情況下是下面這樣的,它的缺點是每次都需要寫全路徑。
scp -r /path/conf node1:/path/conf
scp -r /path/conf node2:/path/conf
scp -r /path/conf node3:/path/conf
使用 rsync 命令同步,同時自動獲取到檔案的絕對路徑,指令碼如下
#!/bin/bash
[ $# -lt 1 ] &&
# nodes must can login without password
nodes=
(node1 node2 node3)
echo -n "action executing on hosts: $, [yes/no] "
read input
["$input"
=="yes"]||
exit 1
for host in
"$"do
echo
====
====
====
====
====
sync to $host
====
====
====
====
====
forfile
in$@
doif
[ -e $file];
then
pdir=
$(cd -p $(dirname $file)
; pwd)
fname=
$(basename $file)
ssh$host
"mkdir -p $pdir"
rsync -apz $pdir/$fname
$host
:$pdir
else
echo
$file does not exists!
fidone
done
#!/bin/bash
[ $# -lt 1 ] &&
# nodes must can login without password
nodes=
(node1 node2 node3)
echo -n "action executing on hosts: $, [yes/no] "
read input
["$input"
=="yes"]||
exit 1
for host in
"$"do
echo
====
====
====
====
==== removing on $host
====
====
====
====
====
forfile
in$@
do pdir=
$(cd -p $(dirname $file)
; pwd)
fname=
$(basename $file)
fpath=
"$pdir/$fname"
ssh$host
"[ -e $fpath ] && rm -rf $fpath || echo $file does not exists!"
done
done
#!/bin/bash
[ $# -lt 1 ] &&
# nodes must can login without password
nodes=
(node1 node2 node3)
echo -n "action executing on hosts: $, [yes/no] "
read input
["$input"
=="yes"]||
exit 1
for host in
"$"do
echo
====
====
====
====
==== removing on $host
====
====
====
====
====
forfile
in$@
do cdir=
"$(pwd)"
ssh$host
"cd $cdir; $@"
done
done
# 同步 /etc/profile
sudo xsync /etc/profile
# 同步當前目錄的tmpfile
xsync tmpfile
# 刪除所有的 /tmp/tmpfile
xremove /tmp/tmpfile
配置集群時間同步
時間同步需要安裝網路時間協議ntp network time protocol 1 檢視系統中是否已安裝ntp rpm qa grep ntp 2 安裝ntp yum y install ntp 3 修改 etc ntp.conf 按下圖所示刪除和新增注釋 最後加上下圖所示語句 3 修改 etc s...
集群時間同步配置
集群時間同步配置 1.配置時間伺服器 1.1檢查ntp是否安裝 tpsky master hadoop 2.5.2 sudo rpm qa grep ntp ntp 4.2.6p5 10.el6.centos.2.x86 64 fontpackages filesystem 1.41 1.1.el6...
Hadoop集群配置時區同步
查詢是否安裝時區同步服務 輸入 rpm q ntp 安裝ntp時區同步服務 yum install y ntp 修改ntp配置 輸入 vi etc ntp.conf 實際輸入自己的ip位址 restrict 192.168.184.35 nomodify notrap nopeer noquery ...