node1 | 192.168.47.20 | Master |
---|---|---|
node2 | 192.168.47.30 | slave |
[student@server ansible]$ cat inventory
[mysql]
node1
node2
[mysql_master]
node1
[mysql_slave]
node2
//手动定义角色
[student@server roles]$ ansible-galaxy init mysql
**定义数据库主从复制优先级**
```sql
[student@server mysql]$ cat templates/slave.cnf.j2
[mysqld]
log_bin=mysql-bin
server_id=10 ——数值越小的优先级越高
[student@server mysql]$ cat templates