确认OS版本:

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

  yum安装:

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

  安装验证:

[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


  建立SVN版本库目录(svndata)及密码权限目录(svnpasswd):

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

  启动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


  创建版本库:

[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


  配置文件授权:

[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

  只配置组成员:

[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

  重启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


  创建apache配置文件:

[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>

  启动apache:

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

  配置开机自启动:

[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服务配置开机自启动:

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


  清空文件:

> /application/svnpasswd/passwd

  创建svn用户:(密码:123456)

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


  浏览器访问:http://10.0.81.59/svn/yunqiandai/

image.png

  参考文档:

https://www.cnblogs.com/guge-94/p/10523716.html——Centos 7 最小化部署svn版本控制(http协议)

https://www.cnblogs.com/guge-94/p/10524059.html——Centos 7 最小化部署svn版本控制(svn协议)


  svn备份命令:(13G的数据,备份时间20分钟左右)

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

  svn还原命令:(13G的数据,备份时间半小时左右)

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

  参考文档:

https://www.jianshu.com/p/295b423d50ad——SVN迁移

  从正常使用的svn服务器把数据备份出来,在灾备测试服务器上还原数据即可。以上方法,svn用户需要重新创建,无法备份导出。