Користувач:S.kostyushkin/Робоча сторінка4

Матеріал з Вікіпедії — вільної енциклопедії.
Перейти до навігації Перейти до пошуку

Для початку давайте розглянемо переваги які можна отримати при використанні Subversion:

1. Кросплатформеність 2. Відкритий сирцевий код - це може бути корисним якщо ви знайдете якусь помилку та захочете виправити її власноруч 3. Гнучка система додатків, що реалізується завдяки svn-hooks Легко інтегрується в різноманітні IDE Має багато прихильників / добре протестована


Benefits when using Subversion replication

Copy of the data on more than one server Eliminate single point or failur Share load across servers Repositories on many different GEO locations Works with usual load balancers in front READ / WRITE possible Drawbacks of using Subversion Replication

When the primary node fails, no commits are possible, but read-only still works Big commits can take some time to replay to slaves Importing dumps will mean the slaves become out of sync! More servers to maintain How it works - The concept

Setup the Master Create the Subversion Repository

Create Parent Directory

  1. mkdir /path/to/repos-parent
  2. chown $wwwuser:$wwwgroup -R /path/to/repos-parent
  3. chmod 770 -R /path/to/repos-parent

Create Repository

  1. su $wwwuser -c 'svnadmin create /path/to/repository'

Configuration of Apache HTTPD on the Master

Setup Apache HTTPD config Make sure Subversion module is loaded on startup LoadModule dav_svn_module modules/mod_dav_svn.so Describe your repository params in the "Location" directive <Location /repos>

  DAV svn
  SVNPath /path/to/repos
  # Limit write permission to list of valid users.
  <LimitExcept GET PROPFIND OPTIONS REPORT>
       AuthType "Basic"
       AuthName "SVN Repos"
       AuthBasicProvider "ldap"
       AuthzLDAPAuthoritative "off"
       AuthLDAPURL "<LDAPURL>"
       AuthLDAPBindDN "DOMAIN\testuser"
       AuthLDAPBindPassword "testpassword"
       Require ldap-user testuser
  </LimitExcept>

</Location> Setup the Slave Configuration of Apache HTTPD on the Slave

Setup Apache HTTPD config To set up a webdav proxy server in Apache, we need load the modules: LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule proxy_module modules/mod_proxy.so Describe your repository params in the "Location" directive <Location /repos>

  DAV svn
  SVNPath /path/to/repos
  SVNMasterURI http://<MASTER>/repos

</Location> Describe proxy-sync params for repository in the "Location" directive <Location /proxy-sync>

   DAV svn
   SVNPath /path/to/repos
   Order Deny,Allow
   Deny from all
   Allow from <MASTER>

</Location> Add hook on slave

@#!/bin/sh

  1. /path/to/repos/hooks/pre-revprop-change

USER=$3 if [ "$USER" != "svnsync" ]; then

  echo >&2 "Only the svnsync user is allowed to change revprops" 
  exit 1 

fi

exit 0 Init and Sync the Slave Repository

slave# svnsync init file:///path/to/repos http://<MASTER>/repos/ slave# svnsync sync file:///path/to/repos Add Subversion hooks to the Master for on-the-fly replication

@#!/bin/sh

  1. /path/to/repos/hooks/post-revprop-change

REV=$2 /path/to/svnsync --source-username=svnsync --sync-username=svnsync http://<SLAVE>/proxy-sync $REV 2>>/var/log/svnsynclog &

@#!/bin/sh

  1. /path/to/repos/hooks/post-commit

/path/to/svnsync --source-username=svnsync --sync-username=svnsync sync http://<SLAVE>/proxy-sync 2>>/var/log/svnsynclog & Known problems Problems with file locking

File locking will not work well enough with svnsync Solution: Use this locking utility Svnsync died but the lock file is still present Solution: Delete lock file and wait for the resync:

master# ps aux | grep svnsync master# svn proplist -- username=$syncuser --revprop -r0 http://$slave/proxy-sync/ | grep svn:sync-lock master# svn propdel svn:sync-lock --username=$syncuser --revprop -r0 http://$slave/proxy-sync/ or Create a queue synchronization

Out-of-sync on big commits / imports

Commit to slave server is not possible due to the out-of-sync of revisions Nothing can really help here, but here are some suggestions:

Schedule big imports to low-traffic time Notify your users about the “downtime“ if neccessary Poke the Subversion Development Team to better handle such situations in the next release=P 30