使用salt-state的MariaDB复制未找到
问题描述:
我正在尝试使用salt设置正在运行的MariaDB实例的副本。这里是我的代码:使用salt-state的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 %}
我越来越从盐仆从记录以下错误:
[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
我不确定可能会导致此问题。有什么建议吗?
答
也许你正在使用错误的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来安装它们。