This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
galaxy-deployment-ansible-d…/MariaDB/10.5.3/mariadb/role/templates/keepalived/check_mariadb.sh.j2
2024-01-18 15:35:34 +08:00

16 lines
533 B
Django/Jinja
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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