Considering master SVN has already setup and configured with Apache web server.
1) Install SVN (slave)
yum install mod_dav_svn subversion
2) Configure with Apache web server
shell>cd /etc/httpd/conf.d/
shell>vim subversion.conf
# Make sure you uncomment the following if they are commented out
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
# Add the following to allow a basic authentication and point Apache to where the actual
# repository resides.
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user
3) Adding SVN users
shell> htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:
shell> htpasswd -m /etc/svn-auth-conf anotherusername
New password:
Re-type new password:
4) Configure repository
shell> cd /var/www/
shell> mkdir svn
shell> cd svn
shell> svnadmin create repos
shell> chown -R apache.apache repos
shell> service httpd restart
5) Make mirror repository (slave) revision properties modifiable by synchronizing user
(Considering synchronizing user as “svnmirror”)
shell> cd /var/www/svn/repos/hooks
shell> vi pre-revprop-change
Mirror repository's pre-revprop-change hook script
#!/bin/sh
USER="$3"
if [ "$USER" = "svnmirror" ]; then exit 0; fi
echo "Only the svnmirror user may change revision properties" >&2
exit 1
shell> chmod 777 pre-revprop-change
6) Create subversion access control (Only svnmirror user has write access )
shell> cd /var/www/svn/repos/hooks
shell> vi start-commit
Mirror repository's start-commit hook script
#!/bin/sh
USER="$2"
if [ "$USER" = " svnmirror" ]; then exit 0; fi
echo "Only the svnmirror user may commit new revisions" >&2
exit 1
shell> chmod 777 start-commit
7) Register mirror repository for synchronization and initial synchronization
svnsync initialize file:///var/www/svn/repos http://sourceURL/svn/repos --sync-username svnmirror --sync-password svnmirrorpassword
svnsync synchronize file:///var/www/svn/repos --sync-username svnmirror --sync-password svnmirror123 >/var/log/svnsync/svnsyncdata.log
8) Configure Cron job to synchronize master and slave (mirror) in every 5 minutes.
*/5 * * * * root svnsync synchronize file:///var/www/svn/repos --sync-username svnmirror --sync-password svnmirrorpassword >/var/log/svnsync/svnsyncdata.log
No comments:
Post a Comment