Load Nginx in Ubuntu to implement high-performance WEB server 4---RSYNC for website Synchronization

Source: Internet
Author: User
1. the NGINX architecture is used for frontend HTTP forwarding. the backend uses two APACHE2 WEB servers to ensure that the content of the two WEB servers is synchronized, that is, no matter which WEB server NGINX sends the request, the pages opened by the client must be consistent. In this case, RSYNC can be used to implement this function. Ubuntu Nginx load Implementation of High Performance WEB Server http://www.linuxidc.com/Linux/2012-05/613

1. Architecture

NGINX is used for frontend HTTP forwarding. the backend uses two APACHE2 WEB servers to ensure that the content of the two WEB servers is synchronized, that is, no matter which WEB server NGINX sends the request, the pages opened by the client must be consistent. In this case, RSYNC can be used to implement this function.

Related reading:

Ubuntu Nginx load Implementation of High Performance WEB Server http://www.linuxidc.com/Linux/2012-05/61327.htm
Nginx under Ubuntu load Implementation of High Performance WEB Server 2-log optimization http://www.linuxidc.com/Linux/2012-05/61328.htm
Ubuntu Nginx load Implementation of High Performance WEB Server 3-PHP website deployment and time synchronization http://www.linuxidc.com/Linux/2012-05/61329.htm
Ubuntu Nginx load to achieve high performance WEB server 4---RSYNC to achieve site synchronization http://www.linuxidc.com/Linux/2012-05/61330.htm
Ubuntu Nginx load Implementation of High Performance WEB Server 5 --- MySQL master synchronization http://www.linuxidc.com/Linux/2012-06/61687.htm

2. Installation

To install RSYNC in UBUNTU, follow these steps:

# Apt-get install rsync xinetd

2.1. edit/etc/default/rsync to start rsync as the daemon process using xinetd

# Vim/etc/default/rsync RSYNC_ENABLE = inetd

2.2. Create/etc/xinetd. d/rsync and run rsync through xinetd.

# Vim/etc/xinetd. d/rsync service rsync {disable = no socket_type = stream wait = no user = root server =/usr/bin/rsync server_args = -- daemon log_on_failure + = USERID}

2.3. Create/etc/rsyncd. conf and configure rsync in.

# Vim/etc/rsyncd. conf

# Address = 192.168.1.9
# Port = 873

# Limit access to private LANs
Max connections = 2
Hosts allow = 192.168.1.0/255.255.255.0
Hosts deny = *

Log file =/var/log/rsync. log
Pid file =/var/run/rsyncd. pid
Transfer logging = yes
Log format = % t % a % m % f % B
Timeout = 300

[Www]
Comment = web rsync
Path =/var/www/
Read only = no
List = yes
Uid = nobody
Gid = nogroup
# Uid = root
# Gid = root

# Ignore errors
Auth users = root, longwind
Secrets file =/etc/rsyncd. secrets

2.4. Create/etc/rsyncd. secrets to configure the user name and password.

# Vim/etc/rsyncd. secrets root: ubuntu2 # chmod 600/etc/rsyncd. secrets

5. Start/restart xinetd

$ Sudo/etc/init. d/xinetd restart

Rsync-avzu -- delete -- progress/var/www/root@192.168.1.10:/var/www #192.168.1.9 Server Run

Rsync-avzu -- progress -- delete root@192.168.1.9:/var/www // var/www #192.168.1.10 client execution

Note that the server to be synchronized must end with a slash (/); otherwise, it is a backup instead of a synchronization.

The parameters are as follows:

V details
A operates in archive mode, copying directories and symbols to connect
Z Compression
U is only updated to prevent new local files from being overwritten. Pay attention to the clock of both machines at the same time.
-Progress indicates display

You can create a file and use it as the client password for automatic logon,

Create rsync. ps on the client/root

Rsync. ps only contains the password.
Chmod 600 rsync. ps

In this way, the client runs rsync-avzu -- progress -- delete -- password-file =/root/rsync. ps root@192.168.1.9: www/var/www

You can log on automatically.

7.

Rsync has six different working modes:

1. Copy the local file. This mode is enabled when the SRC and DES paths do not contain a single colon (:) separator.
2. Use a remote shell program (such as rsh and ssh) to copy the content of the local machine to the remote machine. When DST
This mode is enabled when the path address contains a single colon (:) separator.
3. Use a remote shell program (such as rsh and ssh) to copy the contents of the remote machine to the local machine. When SRC
This mode is enabled when the address path contains a single colon (:) separator.
4. Copy files from the remote rsync server to the local machine. This mode is enabled when the SRC path information contains the ":" separator.
5. Copy files from the local machine to the remote rsync server. This mode is enabled when the DST path information contains the ":" separator.
6. List of remote machine files. This is similar to rsync transmission, but you only need to omit the local machine information in the command.

8. Configure website timed synchronization

You only need to configure on the client,

The content of the new rsync. sh file is

Rsync-avzu -- progress -- delete -- password-file =/root/rsync. ps root@192.168.1.9: www/var/www

Grant executable permissions

Chmod 755 rsync. sh

Add scheduled crontab-e

*/15 */root/rsync. sh>/var/log/web_rsync.log 2> & 1 # synchronize data every 15 minutes

Saved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.