gpt4 book ai didi

python - 使用 salt 进行 MariaDB 复制 - 未找到状态

转载 作者:行者123 更新时间:2023-11-29 18:13:18 25 4
gpt4 key购买 nike

我正在尝试使用 salt 设置正在运行的 MariaDB 实例的副本。这是我的代码:

{% if pillar.get('REPLICATION_SOURCE_IP') and pillar.get('REPLICATION_SOURCE_PORT') %}

replication-set-gtid:
mysql_query.run:
- database: mysql
- query: |
set @MY_GTID_EXEC = @@GLOBAL.GTID_EXECUTED;
RESET MASTER;
set GLOBAL GTID_PURGED = @MY_GTID_EXEC;

replication-connect-to-master:
mysql_query.run:
- database: mysql
- query: |
CHANGE MASTER TO MASTER_HOST='{{pillar['REPLICATION_SOURCE_IP']}}',
MASTER_PORT={{pillar['REPLICATION_SOURCE_PORT']}},
MASTER_USER='{{pillar['REPLICATION_REPLICA_USERNAME']}}',
MASTER_PASSWORD='{{pillar['REPLICATION_REPLICA_PASSWORD']}}',
MASTER_AUTO_POSITION=1,
MASTER_CONNECT_RETRY=15

replication-start-replica:
mysql_query.run:
- database: mysql
- query: "START SLAVE"

wait-for-slave:
cmd.run:
- name: until [[ $(mysql -P {{pillar['PORT']}} -e "show global status like 'slave_running'" mysql | grep 'Slave_running' | cut -f 2) == 'ON' ]]; do sleep 1; done

{% endif %}

我从 salt minion 日志中收到以下错误:

[ERROR   ] State 'mysql_query.run' was not found in SLS 'mariadb-10_1_00-replication-prepare-replica'
Reason: 'mysql_query' __virtual__ returned False

我正在使用的 MariaDB 镜像包含以下依赖项:

sudo yum install MariaDB-client -y
sudo yum install python-devel mysql-devel -y
sudo yum -y install gcc gcc-c++ kernel-devel
sudo yum -y install python-devel libxslt-devel libffi-devel openssl-devel
sudo pip install MySQL-python

我不确定是什么原因导致了这个 salt 问题。请问有什么建议吗?

最佳答案

也许您使用了错误的 pip 包。在我的系统上,我没有 MySQL-python,我只有(您可能只需要其中之一):

mysqlclient==1.3.7
PyMySQL==0.7.2

在 Ubuntu 16.04 上,它们是从以下软件包安装的:

ii  python-mysqldb                     1.3.7-1build2                                            
ii python-pymysql 0.7.2-1ubuntu1

我认为您也可以在 Fedora 中找到类似的软件包,而无需通过 pip 安装它们

关于python - 使用 salt 进行 MariaDB 复制 - 未找到状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47232218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com