标签:mysql
[root@localhost ~]# yum -y install mariadb-server
[root@localhost ~]# vim /etc/my.cnf 在[mysqld]段的最后添加以下内容 skip_name_resolve = ON innodb_file_per_table = ON server-id = 1 (id号不能跟从服务器相同) log-bin = master-log (自定义主服务器的二进制日志文件名) relay-log = slave-log (自定义从服务器的二进制日志文件名) auto_increment_offset = 1 auto_increment_increment = 2
MariaDB [(none)]> show master status\G *************************** 1. row *************************** File: master-log.000003 Position: 422 Binlog_Do_DB: Binlog_Ignore_DB:
[root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# mysql MariaDB [(none)]> grant replication slave,replication client on *.* to ‘repluser‘@‘10.1.51.%‘ identified by ‘replpasswd‘; MariaDB [(none)]> change master to master_host=‘10.1.51.50‘,master_user=‘repluser‘,master_password=‘replpasswd‘,master_log_file=‘master-log.000003‘,master_log_pos=422; MariaDB [(none)]> start slave; MariaDB [(none)]> SHOW SLAVE STATUS\G (仅是部分内容) Master_Host: 10.1.51.50 Master_User: repluser Master_Port: 3306 Connect_Retry: 60 Master_Log_File: master-log.000003 Read_Master_Log_Pos: 422 Relay_Log_File: slave-log.000002 Relay_Log_Pos: 530 Relay_Master_Log_File: master-log.000003 Slave_IO_Running: Yes Slave_SQL_Running: Yes Master_Server_Id: 2
[root@localhost ~]# yum -y install mariadb-server
[root@localhost ~]# vim /etc/my.cnf skip_name_resolve = ON innodb_file_per_table = ON server-id = 2 relay-log = slave-log lob-bin = master-log auto_increment_offset = 2 auto_increment_increment = 2
MariaDB [(none)]> show master status\G *************************** 1. row *************************** File: master-log.000003 Position: 245 Binlog_Do_DB: Binlog_Ignore_DB:
[root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# mysql MariaDB [(none)]> grant replication slave,replication client on *.* to ‘repluser‘@‘10.1.51.%‘ identified by ‘replpasswd‘; MariaDB [(none)]> change master to master_host=‘10.1.51.60‘,master_user=‘repluser‘,master_password=‘replpasswd‘,master_log_file=‘master-log.000003‘,master_log_pos=245; MariaDB [(none)]> start slave; MariaDB [(none)]> show slave status\G (仅是部分内容) Master_Host: 10.1.51.60 Master_User: repluser Master_Port: 3306 Connect_Retry: 60 Master_Log_File: master-log.000003 Read_Master_Log_Pos: 422 Relay_Log_File: slave-log.000003 Relay_Log_Pos: 530 Relay_Master_Log_File: master-log.000003 Slave_IO_Running: Yes Slave_SQL_Running: Yes Master_Server_Id: 1
MariaDB [(none)]> create database mydb;
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mydb | | mysql | | performance_schema | | test | +--------------------+
本文出自 “汪立明” 博客,请务必保留此出处http://afterdawn.blog.51cto.com/7503144/1928227
标签:mysql
原文地址:http://afterdawn.blog.51cto.com/7503144/1928227