2018-10-07 08:38:30 -04:00
|
|
|
#!/bin/bash
|
2023-11-08 12:32:59 -05:00
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
2018-10-07 08:38:30 -04:00
|
|
|
export PATH
|
|
|
|
|
|
2023-10-01 09:12:00 -04:00
|
|
|
# 手动主从设置
|
|
|
|
|
# https://www.cnblogs.com/whiteY/p/17331882.html
|
|
|
|
|
|
2025-09-11 03:07:55 -04:00
|
|
|
# cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 5.5
|
2024-05-14 16:06:15 -04:00
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py try_slave_sync_bugfix {}
|
2024-05-16 04:33:19 -04:00
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py do_full_sync {"db":"xxx","sign":"","begin":1}
|
|
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py sync_database_repair {"db":"xxx","sign":""}
|
|
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py init_slave_status
|
2024-05-19 03:09:25 -04:00
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py install_pre_inspection
|
2025-06-25 04:32:59 -04:00
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py set_slave_status {"close":"change"}
|
2025-07-27 04:07:50 -04:00
|
|
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py set_root_pwd {"password":"root","force":"2"}
|
2018-12-09 21:44:54 -05:00
|
|
|
curPath=`pwd`
|
|
|
|
|
rootPath=$(dirname "$curPath")
|
|
|
|
|
rootPath=$(dirname "$rootPath")
|
|
|
|
|
serverPath=$(dirname "$rootPath")
|
2025-04-14 04:22:51 -04:00
|
|
|
|
|
|
|
|
if [ -f ${rootPath}/bin/activate ];then
|
|
|
|
|
source ${rootPath}/bin/activate
|
|
|
|
|
fi
|
2018-12-09 21:44:54 -05:00
|
|
|
|
2018-10-07 08:38:30 -04:00
|
|
|
action=$1
|
2018-12-09 21:44:54 -05:00
|
|
|
type=$2
|
|
|
|
|
|
2024-06-15 08:28:11 -04:00
|
|
|
if id mysql &> /dev/null ;then
|
|
|
|
|
echo "mysql UID is `id -u mysql`"
|
|
|
|
|
echo "mysql Shell is `grep "^mysql:" /etc/passwd |cut -d':' -f7 `"
|
|
|
|
|
else
|
|
|
|
|
groupadd mysql
|
|
|
|
|
useradd -g mysql -s /usr/sbin/nologin mysql
|
|
|
|
|
fi
|
|
|
|
|
|
2018-12-09 21:44:54 -05:00
|
|
|
if [ "${2}" == "" ];then
|
2024-11-30 08:44:09 -05:00
|
|
|
echo '缺少安装脚本...'
|
2018-12-09 21:44:54 -05:00
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -d $curPath/versions/$2 ];then
|
2024-11-30 08:44:09 -05:00
|
|
|
echo '缺少安装脚本2...'
|
2018-12-09 21:44:54 -05:00
|
|
|
exit 0
|
2018-10-07 08:38:30 -04:00
|
|
|
fi
|
2018-12-09 21:44:54 -05:00
|
|
|
|
2022-11-18 11:46:08 -05:00
|
|
|
if [ -d $serverPath/mysql ];then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2022-06-29 05:07:23 -04:00
|
|
|
if [ "${action}" == "uninstall" ];then
|
|
|
|
|
|
2022-07-11 11:23:55 -04:00
|
|
|
if [ -f /usr/lib/systemd/system/mysql.service ] || [ -f /lib/systemd/system/mysql.service ];then
|
2022-06-29 05:07:23 -04:00
|
|
|
systemctl stop mysql
|
|
|
|
|
systemctl disable mysql
|
2022-07-03 10:22:03 -04:00
|
|
|
rm -rf /usr/lib/systemd/system/mysql.service
|
2022-07-11 11:23:55 -04:00
|
|
|
rm -rf /lib/systemd/system/mysql.service
|
2022-06-29 05:07:23 -04:00
|
|
|
systemctl daemon-reload
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2018-12-09 21:44:54 -05:00
|
|
|
sh -x $curPath/versions/$2/install.sh $1
|
2022-06-29 05:07:23 -04:00
|
|
|
|
2022-06-30 00:23:12 -04:00
|
|
|
if [ "${action}" == "install" ] && [ -d $serverPath/mysql ];then
|
2022-06-29 05:07:23 -04:00
|
|
|
#初始化
|
|
|
|
|
cd ${rootPath} && python3 ${rootPath}/plugins/mysql/index.py start ${type}
|
2022-06-29 05:07:45 -04:00
|
|
|
cd ${rootPath} && python3 ${rootPath}/plugins/mysql/index.py initd_install ${type}
|
2022-06-29 05:07:23 -04:00
|
|
|
fi
|