MySQL启动脚本(start-mysql)
cd /usr/local/bin
sudo vi start-mysql
脚本内容如下:
#!/bin/bash
echo "start MySQL-------------------------------------------------"
for i in bigdata-node3
do
ssh $i "source /etc/profile;service mysql start"
done
sleep 5s
echo "MySQL status------------------------------------------------"
for i in bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;service mysql status"
done
exit 0
设置脚本执行权限:
sudo chmod +x start-mysql
sudo chown vagrant:vagrant start-mysql
MySQL停止脚本(stop-mysql)
cd /usr/local/bin
sudo vi stop-mysql
脚本内容如下:
#!/bin/bash
echo "stop MySQL-------------------------------------------------"
for i in bigdata-node3
do
ssh $i "source /etc/profile;service mysql stop"
done
sleep 5s
echo "MySQL status------------------------------------------------"
for i in bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;service mysql status"
done
exit 0
设置脚本执行权限:
sudo chmod +x stop-mysql
sudo chown vagrant:vagrant stop-mysql
MySQL状态查看脚本(status-mysql)
cd /usr/local/bin
sudo vi status-mysql
脚本内容如下:
#!/bin/bash
echo "MySQL status------------------------------------------------"
for i in bigdata-node3
do
echo "${i}------------------------------------"
ssh $i "source /etc/profile;service mysql status"
done
exit 0
设置脚本执行权限:
sudo chmod +x status-mysql
sudo chown vagrant:vagrant status-mysql
分发(选做):
# 使用root账户分发至其他节点
sudo scp -r /usr/local/bin/*-mysql root@bigdata-node2:/usr/local/bin/
sudo scp -r /usr/local/bin/*-mysql root@bigdata-node3:/usr/local/bin/