查詢檔案所在位置
find / -name xsync
zkServer.sh start
zkServer.sh status
vi /etc/profile
#hadoop配置環境
export HADOOP_HOME=/opt/soft/hadoop260
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
#zookeeper配置環境
export ZOOKEEPER_HOME=/opt/soft/zookeeper345
export PATH=$PATH:$ZOOKEEPER_HOME/bin
腳本記錄
一、安裝jdk配置環境 autoinstall.sh
[root@linux02 mysyssh]# vi ./autoinstall.sh
#!/bin/bash
jdk=true
installdir=/opt/soft
if [ ! -d "$installdir" ];then
mkdir $installdir
fi
if [ "$jdk" = true ];then
echo "~~~~~~~~安裝jdk~~~~~~~~~~~"
tar -zxf /opt/install/jdk-8u111-linux-x64.tar.gz -C /opt/soft/
mv /opt/soft/jdk1.8.0_111 /opt/soft/jdk180
echo "#jdk" >> /etc/profile
echo "export JAVA_HOME=/opt/soft/jdk180" >> /etc/profile
echo "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
fi
二、跨系統拷貝 遠程同步 xsync
[root@linux02 mysyssh]# vi ./xsync
#!/bin/bash
#獲取輸入的引數,如果沒有引數,直接退出
argCount=$#
if [ $argCount == 0 ]; then
echo 'no args'
exit 0
fi
#獲取檔案名稱
f=$1
fname=`basename $f`
echo $fname
#獲取檔案絕對路徑
pdir=`cd -P $(dirname $f ); pwd`
echo $pdir
#獲取當前用戶
user=`whoami`
echo $user
yum install -y rsync
2. rsync 遠程同步工具
rsync 主要用于備份和鏡像,具有速度快、避免復制相同內容和支持符號鏈接的優點,
rsync 和 scp 區別:用 rsync 做檔案的復制要比 scp 的速度快,rsync 只對差異檔案做更新,
scp 是把所有檔案都復制過去
從字面意思上,rsync 可以理解為 remote sync(遠程同步),但它不僅可以遠程同步資料(類似于 scp 命令),
還可以本地同步資料(類似于 cp 命令),
不同于 cp 或 scp 的一點是,使用 rsync 命令備份資料時,不會直接覆寫以前的資料(如果資料已經存在),
而是先判斷已經存在的資料和新資料的差異,只有資料不同時才會把不相同的部分覆寫,
#回圈拷貝
for host in linux02 linux03 linux04 linux05
do
echo "---------------------------- $host --------------"
rsync -av $pdir/$fname $user@$host:$pdir
done
三、修改、添加內容
[root@linux02 conf]# vi ./zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
修改內容:
(dataDir=/opt/soft/zookeeper345/datatmp)
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
添加內容:
server.1=192.168.111.133:2888:3888
server.2=192.168.111.134:2888:3888
server.3=192.168.111.135:2888:3888
四、zookeeper開啟、關閉、查看狀態 zkop
[root@linux03 soft]# vi /usr/bin/zkop
#!/bin/bash
for host in linux03 linux04 linux05
do
case $1 in
"start"){
echo "--------$host zookeeper start -----------"
ssh $host "source /etc/profile; zkServer.sh start"
};;
"stop"){
echo "--------$host zookeeper stop -----------"
ssh $host "source /etc/profile; zkServer.sh stop"
};;
"status"){
echo "--------$host zookeeper status -----------"
ssh $host "source /etc/profile; zkServer.sh status"
};;
esac
done
五、輸入數字實作zookeeper開啟、關閉、查看狀態 zkopcustomer
[root@linux03 soft]# vi /usr/bin/zkopcustomer
#!/bin/bash
cat <<EOF
1:啟動集群KAFKA
2:停止集群KAFKA
3:查詢集群服務狀態
EOF
read -p "請輸入要選擇的數字:" num
for host in linux03 linux04 linux05
do
case $num in
"1"){
echo "--------$host zookeeper start -----------"
ssh $host "source /etc/profile; zkServer.sh start"
};;
"2"){
echo "--------$host zookeeper stop -----------"
ssh $host "source /etc/profile; zkServer.sh stop"
};;
"3"){
echo "--------$host zookeeper status -----------"
ssh $host "source /etc/profile; zkServer.sh status"
};;
esac
done
六、集群指令資訊 jqop
#!/bin/bash
for host in linux02 linux03 linux04 linux05
do
echo "-------------$host指令資訊-----------"
echo "$*"
ssh $host "source /etc/profile; $*"
done
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/348298.html
標籤:其他
上一篇:“程式員真的干到35歲就干不動了?”在這個知乎問題下,443個答案為中年碼農指明了三條道路
下一篇:HA historyserver錯誤日志java.lang.RuntimeException: java.io.IOException: Couldn‘t create proxy provid nu
