部署svn災備測試服務器

  確認OS版本:html

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

  yum安裝:apache

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

  安裝驗證:centos

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

[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


  配置文件受權:app

[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

  只配置組成員:tcp

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

[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配置文件:svn

[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用戶須要從新建立,沒法備份導出。

相關文章
相關標籤/搜索