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

How to realize automatic synchronization of Web pages in linux system

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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.

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

Development

Wechat

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

12
Report