Naujausias pranešimas: Samba kritinis pažeidžiamumas
frame

Sveiki apsilankę!

Jei forume lankaisi pirmą kartą, kviečiame registruotis ir prisijungti prie diskusijų.

Prisijungti Registruotis

Unison - failų sinchronizavimas tarp 2 serverių CentOS 6 aplinkoje

IV_RomanLIV_RomanL Interneto vizija
edited 2021 sausio 20 Į Archyvas
Unison - aplikacija leidžianti sinchronizuoti failus tarp dviejų dedikuotų serverių. Didžiausias skirtumas nuo rsync failų sinchronizavimo aplikacijos tas, jog Unison aplikacija atlieka sinchronizavimą abejose pusėse.
Pavyzdys: pakeitus turinį serveryje 1, serveryje 2 failai pakinta taip pat ir atvirkščiai.

Pamoka parengta naudojant CentOS 6 64-bit operacinę sistemą abejuose serveriuose.

0. Patogiam failų turinio redagavimui naudojame "nano" aplikaciją. Ją įdiegti galite įvykdę šią komandą SSH konsolėje:
yum install nano -y
1. Įdiegiame Unison aplikaciją abejuose serveriuose:
rpm -Uvh http://ftp.uninett.no/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install unison -y
2. Generuojame private/public raktą pirmąjame serveryje ir perkeliame į antrąjį:
ssh-keygen -t dsa
Pastaba: prašant įvesti "Enter passphrase" spauskite iškart ENTER. Jei įvesite slaptažodį, tuomet Unison aplikacija neveiks.

Perkeliame raktą į serverį 2:
ssh-copy-id -i $HOME/.ssh/id_dsa.pub root@Serverio_2_IP_Adresas
3. Testuojame Unison serviso veikimą, vykdome komandą 1-ąjame serveryje:
unison /var/www ssh://2-ojo_serverio_IP//var/www
Pastaba: sukurkite testinį tekstinį failą 1-ąjame serveryje, tam jog vizuoliai pamatytumėte sinchronizacijos rezultatą 2-ąjame serveryje.

Patikrinus 2-ojo serverio /var/www aplanką turėtumėte rasti testinį tekstinį failą iš pirmojo serverio.

4. Automatizuojame sinchronizavimo procesą. Vykdome komandą 1-ąjame serveryje:
nano /root/.unison/default.prf
ir įklijuojame turinį pakoregavus nustatymus pagal pageidavimą:
# Unison preferences file
# Roots of the synchronization
root = /var/www
root = ssh://2-ojo_serverio_IP//var/www

# Paths to synchronize
#path = current
#path = common
#path = .netscape/bookmarks.html

# Some regexps specifying names and paths to ignore
#ignore = Path stats    ## ignores /var/www/stats
#ignore = Path stats/*  ## ignores /var/www/stats/*
#ignore = Path */stats  ## ignores /var/www/somedir/stats, but not /var/www/a/b/c/stats
#ignore = Name *stats   ## ignores all files/directories that end with "stats"
#ignore = Name stats*   ## ignores all files/directories that begin with "stats"
#ignore = Name *.tmp    ## ignores all files with the extension .tmp

#          When set to true, this flag causes the user interface to skip
#          asking for confirmations on non-conflicting changes. (More
#          precisely, when the user interface is done setting the
#          propagation direction for one entry and is about to move to the
#          next, it will skip over all non-conflicting entries and go
#          directly to the next conflict.)
auto=true

#          When this is set to true, the user interface will ask no
#          questions at all. Non-conflicting changes will be propagated;
#          conflicts will be skipped.
batch=true

#          !When this is set to true, Unison will request an extra
#          confirmation if it appears that the entire replica has been
#          deleted, before propagating the change. If the batch flag is
#          also set, synchronization will be aborted. When the path
#          preference is used, the same confirmation will be requested for
#          top-level paths. (At the moment, this flag only affects the
#          text user interface.) See also the mountpoint preference.
#confirmbigdel=true

#          When this preference is set to true, Unison will use the
#          modification time and length of a file as a `pseudo inode
#          number' when scanning replicas for updates, instead of reading
#          the full contents of every file. Under Windows, this may cause
#          Unison to miss propagating an update if the modification time
#          and length of the file are both unchanged by the update.
#          However, Unison will never overwrite such an update with a
#          change from the other replica, since it always does a safe
#          check for updates just before propagating a change. Thus, it is
#          reasonable to use this switch under Windows most of the time
#          and occasionally run Unison once with fastcheck set to false,
#          if you are worried that Unison may have overlooked an update.
#          The default value of the preference is auto, which causes
#          Unison to use fast checking on Unix replicas (where it is safe)
#          and slow checking on Windows replicas. For backward
#          compatibility, yes, no, and default can be used in place of
#          true, false, and auto. See the section "Fast Checking" for more
#          information.
fastcheck=true

#          When this flag is set to true, the group attributes of the
#          files are synchronized. Whether the group names or the group
#          identifiers are synchronizeddepends on the preference numerids.
group=true

#          When this flag is set to true, the owner attributes of the
#          files are synchronized. Whether the owner names or the owner
#          identifiers are synchronizeddepends on the preference
#          extttnumerids.
owner=true

#          Including the preference -prefer root causes Unison always to
#          resolve conflicts in favor of root, rather than asking for
#          guidance from the user. (The syntax of root is the same as for
#          the root preference, plus the special values newer and older.)
#          This preference is overridden by the preferpartial preference.
#          This preference should be used only if you are sure you know
#          what you are doing!
prefer=newer

#          When this preference is set to true, the textual user interface
#          will print nothing at all, except in the case of errors.
#          Setting silent to true automatically sets the batch preference
#          to true.
silent=true

#          When this flag is set to true, file modification times (but not
#          directory modtimes) are propagated.
times=true
Sukuriame periodinę užduotį:
crontab -e
Ir įrašome (komanda "unison" bus vykdoma kas 5 minutes):
*/5 * * * * /usr/bin/unison &> /dev/null
Viskas, sinchronizavimo procesas automatizuotas.

---
Naudingos nuorodos:

http://www.cis.upenn.edu/~bcpierce/unison/
Pažymėtos temos:
Ši diskusija uždaryta
Dedikuoti.lt
Šiame forume rasite informaciją kaip atlikti serverio administravimą, konfigūravimą, įvairių tarnybų bei papildomų aplikacijų diegimą. Taip pat pateiksime rekomendacijų, skirtų serverių saugumui, monitoringui ir optimizavimui. Kviečiame prisijungti prie dedikuotų serverių administratorių bendruomenės, dalyvauti diskusijose ir praplėsti savo žinias serverių administravimo srityje!
© 2007 - 2023 Dedikuoti.lt forumas, visos teisės saugumos.