【发布时间】:2017-11-10 22:39:56
【问题描述】:
我正在尝试使用 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 问题。请问有什么建议吗?
【问题讨论】:
标签: python mysql mariadb fedora salt-stack