>  기사  >  운영 및 유지보수  >  Linux에서 웹 페이지 자동 동기화를 구현하는 방법

Linux에서 웹 페이지 자동 동기화를 구현하는 방법

PHPz
PHPz앞으로
2023-05-15 16:58:21896검색

여러 웹 서버를 사용하여 로드 밸런싱을 달성하려면 프런트 엔드 웹 서버에서 리소스의 일관성을 유지하기 위해 업데이트된 파일을 마스터 서버의 rsync를 통해 다른 슬레이브 서버(읽기 전용 서버)에 동기화할 수 있습니다. 작성), 실시간 동기화는 자동으로 수행할 수 없습니다. inotify

Master 서버: 192.168.6.205 inotify
Slave 서버: 192.168.6.36 rsync

1. 마스터 서비스가 이 서버에 리소스를 동기화할 수 있도록 rsync 서비스를 활성화합니다

vim /etc/rsyncd.conf
uid = nginx
gid = nginx
port = 873
host all = 192.168.6.205
use chroot = on
max 연결 = 4
timeout = 예
[wordpress]
path = /usr/local/nginx/html/wordpress
comment = rsync 파일
오류 무시
읽기 전용 = no
list = 예
auth 사용자 = rsync
secrets 파일 = /etc/rsync.passwd

/etc/rsync.passwd 비밀번호 구성 파일 만들기
vim /etc/rsync.passwd
#user:password
rsync:rsync

2. server

tar -zxvf inotify-tools -3.14.tar.gz
cd inotify-tools-3.14
./configure –prefix=/usr/local/inotify
make && make install

에서 rsync 비밀번호 파일을 구성하세요. 슬레이브 서버에 데이터를 동기화하기 위한 마스터 서버
vim /etc/rsync.passwd
#password
rsync

create script
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 파일을 읽는 동안 $src | 수정, 삭제, 생성, 속성
do
$rsync -vzrtopg –delete –progress –password- file=/etc/rsync.passwd $ src $user@$host::$dst
        echo "${files}이(가) rsynced되었습니다" >>/tmp/rsync.log 2>&1
  done

위 내용은 Linux에서 웹 페이지 자동 동기화를 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제