Detailed explanation of Linux inotify real-time backup implementation method

Detailed explanation of Linux inotify real-time backup implementation method

Real-time replication is the most important way to back up enterprise data. It is mainly used to back up data submitted by users. For ordinary files (pictures, compressed packages, videos, documents, etc.) submitted by users to the server, the inotify/sersync+rsync real-time backup method can be used; for data files, there are more complex distributed storage tools that can back up data into multiple copies at the same time, such as: FastDFS, GlusterFS, etc.; for data submitted to the database, the master-slave replication of the database (for example: MySQL, Oracle) can be used for backup, which is the real-time replication backup method that comes with the software. Some companies will adopt more ideas to realize that data is converted into multiple copies at the same time. For example, when submitting data, the program business logic is submitted to two servers at the same time.

Simulate real-time replication deployment preparation

Real-time replication software introduction

Commonly used software: inotify-tools, sersync (recommended)

Introduction to the real-time replication inotify mechanism

The Linux kernel has added Inotify support since 2.6.13. It is an asynchronous system event monitoring mechanism. Through inotify, various events such as adding, deleting, modifying, and moving in the file system can be monitored. Using this kernel interface, third-party software (such as inotify-tools, sersync) can monitor the changes of various files in the file system and make real-time responses.

Note: The sersync software is developed based on inotify, and has more powerful functions. It supports configuration files, scheduled retry replication, filtering mechanism, provides interfaces for CDN data updates, and supports multi-threaded operations.

Pros and Cons

Advantages of inotify: monitor changes in file system events and achieve real-time data replication through replication tools. Supports multi-threaded real-time replication.

Disadvantages of inotify: If the number of concurrent copies is greater than 200 files (10-100k), there will be a delay in copying.

Solution: Buy time at the front desk. For example, after we register an account or upload data and click Submit, the page will display for a few seconds and then return to the original page.

inotify+rsync project practice

1. Ensure that the rsync service is available and that data can be pushed and pulled from the nfs01 server to the backup server.

2. Check system support

①The kernel version must be greater than 2.6.13 ②The following three files must be present

3. Test the inotify-tools software

[root@nfs01 ~]# yum install inotify-tools -y

Open two windows to test:

Writing the script:

Note: Open another nfs01 window to create, modify, and delete files, and check whether they are synchronized in real time on the backup server.

4. Test the sersync software

Upload Package

Unzip

tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /application/sersync/

The configuration file of sersync is an XML file. Back it up first. cp confxml.xml{,.ori}

Modify the configuration file (enter :set nu to display line numbers):

implement

Because sersync is not installed by yum, you cannot use the systemctl command to start, stop, or restart

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Linux uses Rsync+Inotify to achieve real-time synchronization of local and remote data
  • Use Pyinotify module in Linux to monitor file system changes in real time
  • How to use Linux inotify to monitor file status
  • Using rsync+inotify in Linux system to achieve real-time synchronization of files between servers
  • Automatically synchronize web pages in Linux system through rsync+inotify
  • Realize real-time data backup through rsync+inotify under Linux (remote disaster recovery backup system)

<<:  Summary of basic knowledge points of MySql database

>>:  js to realize the rotation of web page pictures

Recommend

Solve the problem of docker's tls (ssl) certificate expiration

Problem phenomenon: [root@localhost ~]# docker im...

JavaScript selector functions querySelector and querySelectorAll

Table of contents 1. querySelector queries a sing...

Summary of 9 excellent code comparison tools recommended under Linux

When we write code, we often need to know the dif...

Detailed explanation of Vue form binding and components

Table of contents 1. What is two-way data binding...

Detailed explanation of Shell script control docker container startup order

1. Problems encountered In the process of distrib...

Mysql sorting and paging (order by & limit) and existing pitfalls

Sorting query (order by) In e-commerce: We want t...

Implementation of waterfall layout in uni-app project

GitHub address, you can star it if you like it Pl...

Nginx implements https website configuration code example

https base port 443. It is used for something cal...

Mariadb remote login configuration and problem solving

Preface: The installation process will not be des...

Vue3 gets the current routing address

Correct answer Using useRouter : // router path: ...

How to use Docker to build a development environment (Windows and Mac)

Table of contents 1. Benefits of using Docker 2. ...

Java example code to generate random characters

Sample code: import java.util.Random; import java...

Sample code for batch deployment of Nginx with Ansible

1.1 Copy the nginx installation package and insta...

Detailed tutorial on deploying Hadoop cluster using Docker

Recently, I want to build a hadoop test cluster i...

Detailed explanation of Docker compose orchestration tool

Docker Compose Docker Compose is a tool for defin...