Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize automatic synchronization of Web pages in linux system

Shulou Source: shulou.com Published: 2022-06-01 04:00:05 10月02日 Update

This article mainly introduces how to achieve automatic synchronization of web pages in linux system related knowledge, detailed and easy to understand, simple and fast operation, has a certain reference value, I believe everyone read this article how to achieve automatic synchronization of web pages in linux system will have some gains, let's take a look at it.

Load Balancer is implemented by using multiple web servers. In order to maintain the consistency of resources on the front-end web server, updated files can be synchronized to other slave servers (read-only servers) through rsync on the master server (writable data), but real-time synchronization cannot be automatically implemented. Real-time synchronization can be achieved by using inotify.

Primary server: 192.168.6.205 inotify

From Server: 192.168.6.36 rsync

1. Configure rsync on the slave server and enable the rsync service so that the master server can synchronize resources to the server.

vim /etc/rsyncd.conf

uid = nginx

gid = nginx

port = 873

host all = 192.168.6.205

use chroot = on

max connections = 4

timeout = yes

[wordpress]

path = /usr/local/nginx/html/wordpress

comment = rsync files

ignore errors

read only = no

list = yes

auth users = rsync

secrets file = /etc/rsync.passwd

Create the/etc/rsync.passwd password configuration file

vim /etc/rsync.passwd

#User: Password

rsync:rsync

2. Install inotify-tools on the master server

tar -zxvf inotify-tools-3.14.tar.gz

cd inotify-tools-3.14

./ configure -prefix=/usr/local/inotify

make && make install

Configure an rsync password file on the master server to synchronize data to the slave server

vim /etc/rsync.passwd

#Password

rsync

create scripts

vim inotifyrsync.sh

#!/ bin/bash

host=192.168.6.36

src=/usr/local/nginx/html/wordpress/

dst=wordpress

user=rsync

inotifywait=/usr/local/inotify/bin/inotifywait

rsync=/usr/bin/rsync

$inotifywait -mrq -timefmt '%d/%m/%y %h:%m' -format '%t %w%f' -e modify,delete,create,attrib $src | while read files

do

$rsync -vzrtopg -delete -progress -password-file=/etc/rsync.passwd $src $user@$host::$dst

echo "${files} was rsynced" >>/tmp/rsync.log 2>&1

done

About "how to achieve automatic synchronization of web pages in linux system" the content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of "how to achieve automatic web page synchronization in linux system" knowledge. If you still want to learn more knowledge, please pay attention to the industry information channel.

Tags: Services servers synchronization systems web pages passwords files knowledge configuration content real-time data articles resources consistency equilibrium consistency value front end available through Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info NVidia OPPO Reno Docker