Deployment of svn disaster preparedness test server

Confirm OS version:

[root@bogon ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

yum installation:

[root@bogon ~]# yum -y install httpd mod_dav_svn subversion

Installation verification:

[root@bogon ~]# rpm -qa | egrep "httpd|mod_dav_svn|subversion"
httpd-tools-2.4.6-89.el7.centos.1.x86_64
httpd-2.4.6-89.el7.centos.1.x86_64
subversion-libs-1.7.14-14.el7.x86_64
subversion-1.7.14-14.el7.x86_64
mod_dav_svn-1.7.14-14.el7.x86_64
[root@bogon ~]# ls /etc/httpd/modules/ | grep "svn"
mod_authz_svn.so
mod_dav_svn.so


Establish the SVN version Library Directory (svndata) and password permission directory (svnpasswd):

[root@bogon ~]# mkdir -p /application/{svndata,svnpasswd}

Start svn:

[root@bogon ~]# svnserve -r /application/svndata/ -d
[root@bogon ~]# ps -ef|grep svn
root      1252     1  0 16:00 ?        00:00:00 svnserve -r /application/svndata/ -d
root      1254  1118  0 16:00 pts/0    00:00:00 grep --color=auto svn
[root@bogon ~]# netstat -lntup|grep svn
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      1252/svnserve


Create version libraries:

[root@bogon ~]# svnadmin create /application/svndata/yunqiandai
[root@bogon ~]# tree /application/svndata/
/application/svndata/
└── yunqiandai
    ├── conf
    │   ├── authz
    │   ├── passwd
    │   └── svnserve.conf
    ├── db
    │   ├── current
    │   ├── format
    │   ├── fsfs.conf
    │   ├── fs-type
    │   ├── min-unpacked-rev
    │   ├── revprops
    │   │   └── 0
    │   │       └── 0
    │   ├── revs
    │   │   └── 0
    │   │       └── 0
    │   ├── transactions
    │   ├── txn-current
    │   ├── txn-current-lock
    │   ├── txn-protorevs
    │   ├── uuid
    │   └── write-lock
    ├── format
    ├── hooks
    │   ├── post-commit.tmpl
    │   ├── post-lock.tmpl
    │   ├── post-revprop-change.tmpl
    │   ├── post-unlock.tmpl
    │   ├── pre-commit.tmpl
    │   ├── pre-lock.tmpl
    │   ├── pre-revprop-change.tmpl
    │   ├── pre-unlock.tmpl
    │   └── start-commit.tmpl
    ├── locks
    │   ├── db.lock
    │   └── db-logs.lock
    └── README.txt

11 directories, 27 files


Configuration file authorization:

[root@bogon ~]# mv /application/svndata/yunqiandai/conf/{passwd,authz} /application/svnpasswd/
[root@bogon ~]# ll /application/svnpasswd/
total 8
-rw-r--r-- 1 root root 1080 Aug 14 16:02 authz
-rw-r--r-- 1 root root  309 Aug 14 16:02 passwd

Configure only group members:

[root@bogon ~]# cat /application/svnpasswd/authz 
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = gagarin

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r


[yunqiandai:/]
@admin = rw

Restart svn:

[root@bogon ~]# ps -ef|grep svn
root      1252     1  0 16:00 ?        00:00:00 svnserve -r /application/svndata/ -d
root      1586  1118  0 16:34 pts/0    00:00:00 grep --color=auto svn
[root@bogon ~]# kill 1252
[root@bogon ~]# ps -ef|grep svn
root      1588  1118  0 16:34 pts/0    00:00:00 grep --color=auto svn
[root@bogon ~]# svnserve -r /application/svndata/ -d
[root@bogon ~]# ps -ef|grep svn
root      1590     1  0 16:35 ?        00:00:00 svnserve -r /application/svndata/ -d
root      1592  1118  0 16:35 pts/0    00:00:00 grep --color=auto svn


Create apache configuration files:

[root@bogon ~]# cat /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be both:
#
#   a) readable and writable by the 'apache' user, and
#
#   b) labelled with the 'httpd_sys_content_t' context if using
#   SELinux
#

#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#   # chcon -R -t httpd_sys_content_t stuff
#

<Location /svn/ >
        DAV svn
        SVNParentPath /application/svndata/
        SVNListParentPath on

        AuthType Basic
        AuthName "Y_Svn"
        AuthUserFile /application/svnpasswd/passwd
        AuthzSVNAccessFile /application/svnpasswd/authz
        Require valid-user
</Location>

Start apache:

[root@bogon ~]# systemctl restart httpd.service

Configure boot-up self-startup:

[root@bogon ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

svn service configuration boot-up self-start:

[root@bogon ~]# tail -2 /etc/rc.local
####add svn by huangyaoqi at 20190815
svnserve -r /application/svndata/ -d


Empty documents:

> /application/svnpasswd/passwd

Create svn user: (password: 123456)

[root@bogon ~]# htpasswd /application/svnpasswd/passwd gagarin
New password: 
Re-type new password: 
Adding password for user huangyaoqi


Browser access: http://10.0.81.59/svn/yunqiandai/

Reference documents:

https://www.cnblogs.com/guge-94/p/10523716.html-Centos 7 Minimizing Deployment of svn Version Control (http protocol)

https://www.cnblogs.com/guge-94/p/10524059.html-Centos 7 Minimizing Deployment of SVN Version Control (svn protocol)


svn backup command: (13G data, backup time about 20 minutes)

svnadmin dump /application/svndata/yunqiandai/ |gzip >repository-backup.gz.date

svn restore command: (13G data, backup time about half an hour)

zcat repository-backup.gz.date.20190814 |svnadmin load /application/svndata/yunqiandai/

Reference documents:

https://www.jianshu.com/p/295b423d50ad-SVN migration

Back up the data from the normal svn server and restore the data on the disaster preparedness test server. In the above method, the svn user needs to be recreated and cannot back up the export.

Keywords: Linux svn CentOS Apache yum

Added by xeirus on Mon, 30 Sep 2019 23:31:42 +0300