December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Master and slave MySQL versions are MySQL5.6.31

Master and slave MySQL versions are MySQL5.6.31

Primary server IP: 192.168.1.178

From the server IP: 192.168.1.145

Master and slave are able to ping each other.

A?192.168.1.178?Master?
B?192.168.1.145?Slave?

 

service mysqld stop
service mysqld start
service mysqld restart

 

mysql> grant replication slave on *.* to ‘mohan’@’192.168.1.145’ identified by ‘123456’;
mysql> flush privileges;

vi /etc/my.cnf

port=3306

binlog-ignore-db=mysql
server-id=1
expire-logs-days=7
binlog-ignore-db=information_schema
binlog-ignore-db=performation_schema
binlog-ignore-db=sys
binlog-ignore-db=gogs

service mysqld restart

mysql -u root -proot -P3306
mysql> flush tables with read lock;

show master status;

mysql> show master status;
+——————+———-+————–+——————————————————-+——————-+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+——————+———-+————–+——————————————————-+——————-+
| mysql-bin.000001 | 154 | | mysql,information_schema,performation_schema,sys,gogs | |
+——————+———-+————–+——————————————————-+——————-+
1 row in set (0.00 sec)

5 Slave

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-bin=mysql-bin
server-id=3
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
binlog-ignore-db = performation_schema
binlog-ignore-db = sys
log-slave-updates
slave-skip-errors=all
slave-net-timeout=60

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

service mysqld restart

 

mysql> stop slave;
mysql> change master to master_host=’192.168.1.178′,master_user=’mohan’,master_password=’123456′,master_log_file=’mysql-bin.000001′, master_log_pos= 154;
mysql> show slave status \G;

mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql>

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>