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

Zabbix master-slave replication

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Export in the zabbix main database except the appearance of the historical data table

Mysqldump-uroot-p-- single-transaction-R-default-character-set=utf8-- triggers-- events-- hex-blob-- databases zabbix-- ignore-table=zabbix.history-- ignore-table=zabbix.history_uint-- ignore-table=zabbix.history_log-- ignore-table=zabbix.history_str-- ignore-table=zabbix.history_text-- ignore-table=zabbix.trends-- ignore-table=zabbix.trends_uint-- master-data=2 > zabbix_ `date "+% Y%m%d" `. Sql

2. Export the table structure of large historical tables in the main zabbix library.

Mysqldump-uroot-p-d zabbix history history_uint trends_uint trends history_str history_text history_log > tables_ `date "+% Y%m%d" `. Sql

3. Import data from the library

Scp zabbix_xxx.sql tables_xxxx.sql xx.xxx.xx.xx (zabbix slave library)

Apply backup data in zabbix slave library

Mysql-uroot-p

< zabbix_xxx.sql mysql -uroot -p < tables_xxxx.sql #需要在脚本中添加use zabbix;语句 4、zabbix从库做主从关系 mysql>

Show master status

Mysql > reset master

Mysql > SET @ @ GLOBAL.GTID_PURGED='xxxx:1-xxxx'

Mysql > CHANGE MASTER TO MASTER_HOST='xxxx', MASTER_USER='xxxxx', MASTER_PASSWORD='xxxxx', MASTER_PORT=3306,MASTER_AUTO_POSITION = 1

Mysql > start slave

Note: if the master and slave database data are inconsistent, you can also make the premise of master-slave synchronization. Most of the operations in the zabbix master library are insert operations, which do not involve the operation of historical data.

Supplementary notes for the mysqldump command

1. Export the entire database structure and data, directly following the library name

Mysqldump-uroot-p database > dump.sql

2. Export a single data table structure and data, directly following the library name and table name

Mysqldump-uroot-p database table1 table2 > dump.sql

3. Export the entire database structure (without data) and follow the library name directly

Mysqldump-uroot-p-d database > dump.sql

4. Export a single data table structure (without data) and follow the library name and table name directly

Mysqldump-uroot-p-d database table1 table2 > dump.sql

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

Database

Wechat

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

12
Report