提交各组件部署Ansible剧本初版

This commit is contained in:
qidaijie
2024-01-18 15:35:33 +08:00
parent f0bd05d565
commit 0cc392df5c
262 changed files with 15927 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#!/bin/bash
PORT_CHECK=$(netstat -anlp | grep 3306 | grep LISTEN | grep mysqld | grep -v grep | wc -l)
if [[ $PORT_CHECK -eq 0 ]];then
echo "`date "+%Y-%m-%d %H:%M:%S"` - Mariadb 端口未监听,服务异常" >> /etc/keepalived/keepalived_check.log
exit 1
fi
SQL_CHECK=`mysql -h{{inventory_hostname}} -utsg_query -p{{mariadb_query_pin}} -e "SELECT 'ok' AS OK;"`
if [[ $? -ne '0' ]];then
echo "`date "+%Y-%m-%d %H:%M:%S"` - Mariadb SQL执行失败服务状态异常" >> /etc/keepalived/keepalived_check.log
exit 1
fi