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

Rsync replication

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Environment:

Operating system: CentOS 7u3

Source server: 192.168.30.147

Target server: 192.168.30.148

Purpose: to synchronize the / home_test directory on the source server to the / home_test of the target server in real time

First turn off the selinux of the two devices

Temporarily change to setenforce 0, permanently change to modify / etc/sysconfig/selinux, modify SELINUX=enforcing to SELINUX=diabled or SELINUX=permissive

Install the Rsync server (centos2) on the target server

Install Rsync server software

Rhel7:

# yum-y install rsync

Create a rsyncd.conf profile

# vi / etc/rsyncd.conf # 7 has a default configuration file. If there is no default file on rhel6, you need to create your own configuration file. Add the following code

Log file = / var/log/rsyncd.log

Pidfile = / var/run/rsyncd.pid

Lock file = / var/run/rsync.lock

Secrets file = / etc/rsync.pass # user authentication configuration file, which stores the user name and password, which will be created later

Motd file = / etc/rsyncd.Motd # rsync Welcome information page file location at startup (file content customization)

[home_test] # synchronization module name

Path = / home_test # rsync server data directory path

Comment = home_test

Uid = root

Gid = root

Port=873

Use chroot = no

Read only = no

List = no # does not display the list of rsync server resources

Max connections = 200

Timeout = 600,

Auth users = user1 # user name to perform data synchronization. Multiple user names can be set, separated by commas in English.

Hosts allow = 192.168.30.147 # client IP addresses that allow data synchronization. Multiple addresses can be set, separated by commas in English.

Hosts deny = *

Create a user authentication file

# vim / etc/rsync.pass

User1:123456 # format, user name: password, can be set multiple, one user name per line: password, or use echo "user1:123456" > / etc/rsync.pass

Set file permissions

Chmod / etc/rsyncd.conf # sets the read and write permissions of the file owner

Chmod / etc/rsync.pass # sets the read and write permissions of the file owner

Mkdir / home_test

Start rsync

Centos7:

# systemctl restart rsyncd

Centos 6: yum-y install xinetd service is required

# / etc/init.d/xinetd start # launch

# service xinetd stop # stop

# service xinetd restart # restart

Part two: operate on the source server 192.168.30.147

First, install Rsync client software

# yum install rsync

Create an authentication password file

# vim / etc/rsync.pass

123456 # password

Chmod / etc/rsync.pass # sets file permissions, and only sets the file owner with read and write permissions

Mkdir / home_test/ceshi # create a test folder on the source server, and then run the following command on the source server

Rsync-avH-port=873-progress-delete / home_test/ user1@192.168.36.82::home_test/-password-file=/etc/rsync.pass

The test succeeded

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

Servers

Wechat

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

12
Report