deploy.sh工具的目的是,將乙個檔案,傳送到其他伺服器上面去。
runremotecmd.sh工具的目的是,將乙個命令,在多台伺服器上執行。
depoly.conf是上面兩個工具的配置檔案。
deploy.sh的原始碼:
#!/bin/bash#set -x
if [ $# -lt 3 ]
then
echo "usage: ./deply.sh srcfile(or dir) descfile(or dir) machinetag"
echo "usage: ./deply.sh srcfile(or dir) descfile(or dir) machinetag conffile"
exit
fisrc=$1
dest=$2
tag=$3
if [ 'a'$4'a' == 'aa' ]
then
conffile=/home/hadoop/tools/deploy.conf
else
conffile=$4
fiif [ -f $conffile ]
then
if [ -f $src ]
then
for server in `cat $conffile|grep -v '^#'|grep ','$tag','|awk -f',' ''`
doscp $src $server":"$
done
elif [ -d $src ]
then
for server in `cat $conffile|grep -v '^#'|grep ','$tag','|awk -f',' ''`
doscp -r $src $server":"$
done
else
echo "error: no source file exist"
fielse
echo "error: please assign config file or run deploy.sh command with deploy.conf in same directory"
fi
runremotecmd.sh的原始碼
#!/bin/bash#set -x
if [ $# -lt 2 ]
then
echo "usage: ./runremotecmd.sh command machinetag"
echo "usage: ./runremotecmd.sh command machinetag conffile"
exit
ficmd=$1
tag=$2
if [ 'a'$3'a' == 'aa' ]
then
conffile=/home/hadoop/tools/deploy.conf
else
conffile=$3
fiif [ -f $conffile ]
then
for server in `cat $conffile|grep -v '^#'|grep ','$tag','|awk -f',' ''`
doecho "*******************$server***************************"
ssh $server "source /etc/profile; $cmd"
done
else
echo "error: please assign config file or run deploy.sh command with deploy.conf in same directory"
fi
depoly.conf檔案
#第一列是linux的hostname,後面的列是該伺服器支援的功能。namenode1,all,namenode,resourcemanager,
namenode2,all,namenode,resourcemanager,
datanode1,all,datanode,zookeeper,journalnode,resourcemanager,
datanode2,all,datanode,zookeeper,journalnode,resourcemanager,
datanode3,all,datanode,zookeeper,journalnode,resourcemanager,
[hadoop@namenode2 conf]$ type cd deploy.sh
cd is a shell builtin
deploy.sh is /home/hadoop/tools/deploy.sh
具體例子
快速啟動各個元件:(下面的元件首先都要配置環境變數,不然路徑就要完整)
首先新增環境變數,同時增加兩個工具,deploy.sh 和runremotecmd.sh
將.bashrc檔案傳送到所有伺服器的當前目錄:
[hadoop@datanode1 ~]$ deploy.sh .bashrc ~ all
分發執行工具,前提是要先做ssh免密:
啟動datanode1,datanode2,datanode3三颱伺服器上的zookeeper:
[hadoop@namenode1 ~]$ runremotecmd.sh "zkserver.sh start" zookeeper
啟動hdfs:
[hadoop@namenode1 ~]$ start-dfs.sh
啟動後檢視狀態:
[hadoop@namenode2 ~]$ hdfs haadmin -getservicestate nn1
[hadoop@namenode2 ~]$ hdfs dfsadmin -safemode get
啟動hbase:
[hadoop@namenode1 ~]$ start-hbase.sh
[hadoop@datanode1 tmp]$ runremotecmd.sh "zkserver.sh start" zookeeper
*******************datanode1***************************
zookeeper jmx enabled by default
using config: /home/hadoop/zookeeper-3.4.12/bin/../conf/zoo.cfg
starting zookeeper ... started
*******************datanode2***************************
zookeeper jmx enabled by default
using config: /home/hadoop/zookeeper-3.4.12/bin/../conf/zoo.cfg
starting zookeeper ... started
*******************datanode3***************************
zookeeper jmx enabled by default
using config: /home/hadoop/zookeeper-3.4.12/bin/../conf/zoo.cfg
starting zookeeper ... started
[hadoop@datanode1 tmp]$
安裝虛擬機器 Linux命令學習
出現的問題 我將軟體移到了警告中的位址c program files oracle virtualbox中,重新進行安裝。3.安裝後在開啟軟體時彈出獲取virtualbox com物件失敗的提示 為c windows system32 oleaut32.dll後成功將軟體開啟。經過 建立虛擬機器 安...
Linux虛擬機器中的Shell命令
linux虛擬機器中的shell命令 1.關機命令 halt reboot poweroff 2.檢視匹配網絡卡 ifconfig 3.清屏 clear 保留之前得資訊 reset 清空 4.當前使用者 who 檢視登陸資訊 who l 檢視登陸資訊和登陸終端的程序pid 5.幫助手冊 man 6....
Xshell工具無法連線虛擬機器Linux系統
軟體環境軟體描述 centos 7.0 linux環境 openssh ssh服務 1 關閉防火牆 由於centos 7.0預設使用的是firewall作為防火牆,因此我們以下步驟 檢視防火牆狀態 firewall cmd state 關閉防火牆 systemctl stop firewalld.s...