[root@master ~]$vim /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 innodb_file_per_table log_bin server-id=1
MariaDB [(none)]> grant replication slave on *.* to repluser@'192.168.27.%' identified by 'centos'; Query OK, 0 rows affected (0.00 sec) 从服务器192.168.27.17服务配置:
从服务器上的配置: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. innodb_file_per_table server_id=2
注意:默认的server_id是0; MariaDB [(none)]> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 0 | +---------------+-------+ 1 row in set (0.01 sec)
查看帮助: MariaDB [(none)]> help change master to; CHANGE MASTER TO MASTER_HOST='master2.mycompany.com', MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_PORT=3306, MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4, MASTER_CONNECT_RETRY=10;