In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Rsync (remote sync) is a magical data mirror backup software under UNIX and UNIX-like platforms. Unlike FTP or other file transfer services, Rsync can make differential backups according to data changes, thus reducing data flow and improving work efficiency. You can use it to copy local or remote data, and Rsync can use SSH secure tunnels for encrypted data transmission. The Rsync server defines the source data, and the Rsync client will actually copy the data from the server to the local place only after the source data has changed. If the source data is deleted on the server side, the client data will also be deleted to ensure that the data between hosts is synchronized. Rsync uses port TCP 873.
It is very convenient to install and deploy Rsync using the CentOS 7 system. The rsync package is available on the installation CD and Yum source, and you can install it using YUM. The following example shows how to share the / common directory. To do this, we need to create the / common directory and copy some test files to store there. This example requires the manual creation of a configuration file / etc/rsync.conf, the specific syntax format of which is described in detail later.
[root@centos7 ~] # yum-y install rsync
[root@centos7 ~] # mkdir / common; cp / etc/init.d/* / common/
[root@centos7 ~] # vim / etc/rsync.conf
# / etc/rsyncd.conf# set server information prompt file name, write prompt message in this file motd file = / etc/rsyncd.motd# enable Rsync data transfer log function transfer logging = yes# set log file name You can set the log format log file = / var/log/rsyncd.log# set the Rsync process number to save the file name pid file = / var/run/rsyncd.pid# set the lock file name lock file = / var/run/rsync.lock# set the port number that the server listens to. The default is 873port = 87setting the IP address of the interface of the network card that the server is listening to. Here, the IP address of the server is the account name or ID number used for data transmission set by 192.168.0.254address = 192.168.0.25. By default, nobodyuid = nobody# is used to set the group name or GID number used for data transmission. By default, nobodygid = nobody# is used to set user chroot to yes. After rsync is set to chroot first, the root is mapped to the path parameter path, for the client # side. The root of the system is the path specified by the path parameter. However, doing so requires root permission, and when you synchronize the symbol # connection data, only the name will be synchronized, and the content will not be synchronized. Use chroot = whether no# allows the client to upload data, which is set to read-only here. Read only = yes# sets the number of concurrent connections. 0 means unlimited. After the number of concurrency is exceeded, if there is still a client connection request, it will receive # to the prompt message max connections = 1 shared module that will be retried later. Rsync defines the synchronized directory through the module, and the module is defined in the form of [name], which has the same effect as the Samba definition of shared directory. You can also define multiple modules in Rsync [common] # comment define the real path of the synchronized directory comment = Web content# through path specify path = / common# ignore some IO errors ignore errors#exclude can specify an exceptional directory, that is, a directory under the common directory is set to asynchronous data # exclude = test/# setting allows the account to connect to the server The account can be a user auth users = tom,jerry# that does not exist in the system to set the password authentication file name. Note that the permission requirement of this file is read-only, and the recommended permission is 600. valid secrets file = / etc/rsyncd.secrets# setting allows which hosts can synchronize data only after setting the auth users# parameter. It can be a single IP or a network segment. Use space # between multiple IP and network segment to separate hosts allow=192.168.0.0/255.255.255.0# setting to reject all (except hosts defined by hosts allow) hosts deny=*# client request to display module list, whether the module name is displayed or not, the default is truelist= false
Next, create a password file / etc/rsyncd.secrets through echo, and enter two accounts in this file: the password for the tom account is the password for the pass,jerry account. It should be noted that password files cannot have readable permissions for all people. For security, it is recommended to set the permissions to 600. Create a server prompt message file and import welcome words into the file. Since Rsync is not a boot service by default, in order to boot the Rsync service, we can append rsync-- daemon to the boot file / etc/rc.local through echo. Finally, the inbound data request of port 873 is opened by setting the firewall.
[root@centos7 ~] # echo "tom:pass" > / etc/rsyncd.secrets
[root@centos7 ~] # echo "jerry:111" > > / etc/rsyncd.secrets
[root@centos7 ~] # chmod 600 / etc/rsyncd.secrets
[root@centos7 ~] # echo "welcome to access" > / etc/rsyncd.motd
[root@centos7] # rsync-- daemon
[root@centos7 ~] # echo "/ usr/bin/rsync-- daemon" > > / etc/rc.local
[root@centos7] # firewall-cmd-- permanent-- add-port=873/tcp
# add firewall rules to allow data access to port 873
Client synchronizes data
Now let's start synchronizing the data. In the client host, we also use the rsync command to initialize the data transfer, using the same program, but the client host does not need the-- daemon option.
[root@centos7 ~] # yum-y install rsync
[root@centos7] # rsync-vzrtopg-- progress tom@192.168.0.254::common / test
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.