[root@master ~]# cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
log_bin=mysql-bin
server_id=20
[root@master ~]# systemctl restart mariadb.service
[root@slave ~]# cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
log_bin=mysql-bin
server_id=30
[root@slave ~]# systemctl restart mariadb.service
6、进入数据库配置主从
master:
[root@master ~]# mysql -uroot -p1
MariaDB [(none)]> grant replication slave on *.* to 'user'@'slave' identified by '1';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by "redhat";
Query OK, 0 rows affected (0.000 sec)
slave:
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by "1";
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> change master to master_host='master',master_user='user',master_password='1';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.004 sec)
MariaDB [(none)]> show slave status\G;
Slave_IO_Running: Connecting
Slave_SQL_Running: Ye