In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Linux system how to achieve file synchronization, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
The method of realizing File synchronization in Linux system
1. Prepare the source file address: 192.168.0.143
Destination file address: 192.168.0.20
Please turn off the firewall: systemctl stop firewalld.service
Check firewall status: firewall-cmd-state set the value of SELINUX in / etc/sysconfig/selinux file to disable, and restart linux after modification to make the modification take effect, otherwise it will affect the effect of the following steps of file synchronization:
The contents (/ opt/load/) under the synchronized folder in the client (application server, file source server) are synchronously copied to the server (backup server, target server) 192.168.0.20.
Second, to install Rsync and Inotify-tools in the client, you need to configure Inotify-tools but not Rsync.
To install Rsync in the server, you need to configure Rsync.
3. Install and configure Rsync1, the installation configuration in the server (192.168.0.20):
1.1. installation command (online installation): yum-y install xinetd rsync
1.2. Modify the configuration: change disable from yes to no in the / etc/xinetd.d/rsync file. If you do not have this file, create and add the following:
# default:off#description:The rsync server is a good addition to an ftp serve#r,as it\ allows crc checksumming etc.
Service rsync {disable = noflags = IPv6socket_type = streamwait = nouser = rootserver = / usr/bin/rsyncserver_args =-daemonlog_on_failure + = USERID}
1.3.Add under the / etc/rsyncd.conf file:
# configuration file synchronization port = 873uid = rootgid = rootuse chroot = nomax connections = 10strict modes = yespid file = / var/run/rsyncd.pidlock file = / var/run/rsyncd.locklog file = / var/run/ rsyncd.log [backup] path = / opt/upload/comment = analyseread only = falsehost allow = *
Restart the rsync service service xinetd restart
1.5.Test port: rsync port is 873netstat-natp
2. Installation configuration in the client (192.168.0.143): 2.1. installation command (online installation): yum-y install xinetd rsync
4. Install and configure Inotify-tools1 and install the Inotify-toolsInotify-tools tool in the client (192.168.0.143) as a file real-time monitoring tool, which needs to be supported by the linux operating system kernel. The kernel support version should be at least 2.6.13.
1.1.Test whether the operating system supports it: check the version: Uname-r
Indicates that version 3.10.0 is supported if it is greater than 2.6.13. Execute to see if it is supported by default: ll / proc/sys/fs/inotify has three outputs, indicating that Inotify is supported by default, and the Inotify-tools tool can be installed. If not, you need to use a new version of the linux system, and you can install the Inotify-tools tool if the version meets the requirements.
1.2.The download address of Inotify-tools: https://github.s3.amazonaws.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar. Gz?
1.3.install Inotify-tools and move inotify-tools-3.14.tar.gz to / usr directory to extract files: tar zxvf inotify-tools-3.14.tar.gz starts installation: run under cd inotify-tools-3.14/ directory:. / configure install make & & make install directly to check whether the installation is successful. If ll / usr/inotify-tools-3.14/src/ generates the following two files, the installation is successful:
Create and edit configuration files create Inotifyrsync.sh file in / usr/inotify-tools-3.14/: vi inotifyrsync.sh add the following: #! / bin/bashsrc=/opt/load//usr/inotify-tools-3.14/src/inotifywait-mrq-timefmt'% d/%m/%y% Hvi inotifyrsync.sh% M'-format'%T% w% f% e'- e close_write,delete,create Attrib src 192.168.0.20::backup/echo "${file} was rsynced" > > / opt/soft/log/rsync.log 2 > & 1done
1.5.Grant permissions: chmod 755 inotifyrsync.sh
1.6. background execution: bash inotifyrsync.sh &
Fifth, test the real-time synchronization to add, modify and delete files or folders under the synchronized file / opt/load/ in the client (192.168.0.143), and check whether there are any changes under the synchronized folder / opt/load/ in the server (192.168.0.20).
Note 1. The "owner" of client (192.168.0.143) and server (192.168.0.20) is the same as the value of uid and pid in / etc/rsyncd.conf file. Modify the "owner" of the load folder Chown-r root:root / opt/load/2, change the value of SELINUX in the / etc/sysconfig/selinux file to disable, restart linux after modification to make the change effective, and change several servers at the same time.
Configure ntp service implementation time real-time synchronization 1. Prepare the client (application server): 192.168.0.143 server (backup server): 192.168.0.20 Please turn off the firewall: systemctl stop firewalld.service to check the firewall status: firewall-cmd-state the effect achieved by the following steps: the client (application server) 192.168.0.143 synchronization time of the Chinese time service center The server synchronizes the time of the client (backup server) 192.168.0.20.
2. Configure customer 1, check whether ntp service rpm-qa is installed | grep ntp.2, install ntp service: yum install ntp-y.3, modify configuration file:. Only the following are retained in the modified / etc/ntp.conf The rest uses # Note: driftfile / var/lib/ntp/driftserver 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst.server 127.127.1.0fudge 127.127.1.0 stratum 10.includefile / etc/ntp/crypto/pw.keys / etc/ntp/keys.restrict 192.168.0.20 mask 255.255.255.0 nomodify # allows the server to This machine sends synchronous request server 210.72.145.44 prefer # synchronous China time Service Center time: 210.72.145.44 is China time Service Center ip
4. Set ntp service to boot and restart ntp service: set to boot self-boot: chkconfig ntpd on start ntp service: systemctl start ntpd restart ntp service: systemctl restart ntpd close ntp service: systemctl stop ntpd
3. Configure the server 1. Check whether the ntp service rpm-qa is installed | grep ntp.
2. Install ntp service: yum install ntp-y.
3. Modify the configuration file:
Only the following are left in the modified / etc/ntp.conf, and all the rest are annotated with #:
Driftfile / var/lib/ntp/drift server 192.168.0.143 # send a request to the client and synchronize the client time
Includefile / etc/ntp/crypto/pw keys / etc/ntp/keys.
4. Set the ntp service to boot automatically and restart the ntp service:
Set to self-boot: chkconfig ntpd on
Start the ntp service: systemctl start ntpd
Restart the ntp service: systemctl restart ntpd
Turn off the ntp service: systemctl stop ntpd
Fourth, the test will adjust the client time for one or two minutes, and then return to the Chinese time service center in about half an hour. Adjust the server time for a minute or two, and then slowly return to the client time. Date View current time ntpstat View synchronization status
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.