Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Master-slave copy Replication of mysql learning notes

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Master-slave Replication 3.1 architecture diagram

3.2 Parameter Configuration 3.2.1 Creating a Shutdown Script

login.sh

#!/ bin/bashmysql -h227.0.0.1 -uroot -P3306 -p'Yxc@3306'

start.sh

#!/ bin/bashmysqld_safe --defaults-file=/data/mysql/3306/my3306.cnf --user=mysql &

shutdown.sh

#!/ bin/bash/usr/local/mysql/bin/mysqladmin -uroot -P3306 -p'Yxc@3306' -S /data/mysql/3306/mysql3306.sock shutdown3.2.2 Edit the master configuration file [mysqld]basedir=/usr/local/mysqldatadir=/data/mysql/3306/dataport=3306socket=/data/mysql/3306.sockcharacter-set-server=utf8log-error=/data/mysql/3306/log/error3306.logpid-file= The requested URL/data/mysql/3306/mysqld3306.pidlog_bin=mysql_binlog-format =Rowserver-id=513.2.3 was not found on this server. mysql_binserver-id=52relay-log-index=slave-relay-bin.indexrelay-log=slave-relay-bin3.3 create user create user 'repl'@'%' identified by 'repl'; grant replication slave on *.* to 'repl'@'%';3.4 Configuring Replication

Execute the command on the main library to get the current binlog log and location

show master status;

Get file, position information, execute the following scripts on the two slave libraries respectively

CHANGE MASTER TOMASTER_HOST='192.168.56.5',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='repl',MASTER_LOG_FILE='mysql_bin.000002',MASTER_LOG_POS=154;

From the library, start replication and view replication status

start slave;show slave status;

^Note: If the words as shown in the figure appear, it means success. For slave commands, you can use help slave;

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report