2017-11-10 80 views
0

我正在嘗試使用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 

我不確定可能會導致此問題。有什麼建議嗎?

回答

0

也許你正在使用錯誤的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來安裝它們。