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

How to realize rsync synchronization between solaris Services

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to achieve rsync synchronization between solaris services, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

Purpose:

By technical means, certain directories in server A are kept periodically synchronized to server B.

This article is for Sun Solaris version 5.9, other versions or other unix servers are informational only

For file synchronization between Windows servers, you can also use rsync, but to use the cwrsync tool, search for data from the internet.

Tools:

rsync: widely used synchronization software under unix platform, free to use, the latest version is 2.6.6

crontab: timed task manager on the solaris platform

Description:

rsync is installed on both Server A and Server B.

On Server A, rsync runs as a daemon, and you can configure certain directories on Server A to be published by rsync.

On Server B, rsync runs as a command-line tool that synchronizes published directories to Server B from another server running the rsync daemon (Server A).

Configure timed tasks on Server B to run synchronous commands at specified times.

Steps:

Install rsync software on Server A and Server B:

a) Find the latest version of rsync from [url]http://www.sunfreeware.com/programlistsparc9.html[/url] and download the found file from [url]http://ftp.saix.net/pub/solaris-freeware/sparc/5.9/[/url]. The latest version is 2.6.6, and the file can be found in the directory attached to this article under the name rsync-2.6.6-sol9-sparc-local.gz

b) Upload files to Server A and Server B via ftp command, execute commands on DOS command line of PC as follows:

ftp 10.1.4.10 #ftp server 10.1.4.10

bin #Set transmission mode to binary

put rsync-2.6.6-sol9-sparc-local.gz #Upload local files to 10.1.4.10

bye #exit ftp program

c) Install rsync on Server A and Server B, the command is very simple. On the DOS command line of your PC, execute the following command:

telnet 10.1.4.10 #Connect to terminal interface of 10.1.4.10

gzip -d rsync-2.6.6-sol9-sparc-local.gz #Unzip the gz file

pkgadd -d rsync-2.6.6-sol9-sparc-local.gz #Install rsync, press Enter when asked

/usr/local/bin/rsync --version #Verify rsync installation is complete

2. Configure rsync service on Server A

a) Edit the rsync configuration file,/etc/rsyncd.conf, which is not available at the beginning of the installation and needs to be created by yourself. The order reads as follows:

vi /etc/rsyncd.conf #Edit the/etc/rsyncd.conf file

The document reads as follows:

uid = root #Access file directories as root

gid = root #Access the file directory as root

use chroot = yes #can use chroot

max connections = 1 #Max connections

syslog facility = local5

pid file = /var/run/rsyncd.pid

hosts allow = 10.1.4.13 #Allow access only to 10.1.4.13

[grpdomain1] #This is a publish item, you can publish multiple

path=/data/bea/user_projects/grpdomain

read only=yes #read only

list = yes #List of allowed columns

comment=CenGRP3.0,Sinopec Portal Web Server. #Description information

The file can be found in the directory attached to this article under the name ServerA\rsyncd.conf

[grpdomain1] A publication name that will access Server A's rsync publication directory as other servers, and there can be as many sections as needed.

b) Start the rsync service as a daemon, with the following command:

/usr/local/bin/rsync --daemon&

c) Configure rsync to start automatically

vi /etc/rc3.d/S99Rsync #Edit/etc/rc3.d/S99Rsync

chmod 700 /etc/rc3.d/S99 The Rsync #settings file can be read and written by the root

The document reads as follows:

/usr/local/bin/ rsync --daemon&

The file can be found in the directory attached to this article under the name ServerA\S99Rsync

d) Verification Services

Log on to Server B and execute the command:

/usr/local/bin/rsync -ztruvoglp --progress rsync://10.1.3.87

grpdomain1 CenGRP3.0,Sinopec Portal Web Server. #Execution Results

Lists the names of directories published above Server A, indicating successful configuration

3. Set automatic file acquisition on Server A on Server B.

a) For ease of management, place the script file in a specific directory on Server B. The following command creates the directory/data/rsync:

mkdir /data/rsync

b) Create a list of asynchronous files. The file name of the list is defined by yourself. This file is optional. If this file is not created, you can directly use the parameter--exclude in the script command in the following step C) to indicate it.

vi /data/rsync/grpdomain1_exclude_file.list

Each line of the file represents one item, wildcards are supported, and the published item is taken as the current directory. The file contents are as follows:

grpdomain1.log* #indicates/data/bea/user_projects/grpdomain1/grpdomain1.log * out of sync

The requested URL/data/bea/user_projects/grpdomain1/newgrp was not found on this server.

home/logs

applications/cenep/WEB-INF/log

The file can be found in the directory attached to this article, with the name ServerB\grpdomain1_exclude_file.list

c) Create synchronization scripts, multiple scripts can be created as required, each script defines its own scheduling plan (see below)

vi /data/rsync/rsync-grpdomain1.sh #Edit files

chmod 700 /data/rsync/rsync-grpdomain1.sh #Set file to be main readable only

The file content is as follows, be careful not to wrap:

/usr/local/bin/rsync -ztruvoglp --exclude-from=/data/rsync/grpdomain1_exclude_file.list --delete --progress rsync://10.1.4.10/grpdomain1 /data/bea/user_projects/grpdomain1

Parameter Description:

l --ztruvoglp, which means compressed transmission, including subdirectories, keeping the same permissions, etc., can be ignored.

l --exclude-from, indicating from which file to read the list of excepted files

l --delete, indicating that when a file is deleted from Server A, it is also deleted on Server B

l --progress, whether to display details on the console, if running in scheduled tasks, it is best not to add this parameter.

l --exclude, directly indicating which files are out of sync on the command line, format--exclude="hgFF"

l rsync://10.1.4.10:873/grpdomain1, Same source, 873 is the default port, Can be ignored

l /data/bea/user_projects/grpdomain1 Sync destination

d) The file can be found in the directory attached to this article, named ServerB\rsync-grpdomain1.sh

e) Check whether the script is correct and directly execute the command: /data/rsync/rsync-grpdomain1.sh

f) Set 0 o'clock every day to execute synchronous command, execute the following command

crontab -e #Edit the current user's schedule

What is displayed is a vi interface. The contents of the file may be as follows, where the bold part is what we added:

#ident "@(#)root 1.20 01/11/06 SMI"

#

# The root crontab should be used to perform accounting data collection.

#

# The rtc command is run to adjust the real time clock if and when

# daylight savings time changes.

#

10 3 * * * /usr/sbin/logadm

15 3 * * 0 /usr/lib/fs/nfs/nfsfind

1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1

30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean

#Run sync script every night at 24:00, copy grpdomain1 file on 10 to local machine

0 0 * * * /data/rsync/rsync-grpdomain1.sh

#10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___

What works is 0 0 * * * /data/rsync/rsync-grpdomain1.sh, where the five items separated by spaces represent minutes, hours, days, months, and weeks.

g) Start and stop of timed services:

/etc/init.d/cron stop #Stop timed services

/etc/init.d/cron start #Start timed services

4, more file directory synchronization of ServerA operations

a) Modify/etc/rsyncd.conf of ServerA and add a new description. See the description of [grpdomain1].

b) Stop the rsync waiting process on Server A with the command:

ps -ef| grep rsync #Show rsync progress

kill 888 #888 to be replaced by actual process number

c) Restart the waiting process and execute:

/usr/local/bin/rsync -daemon

Thank you for reading this article carefully. I hope that the article "How to achieve rsync synchronization between solaris services" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

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