一、SVN安装
1.1 yum命令在线安装
[root@localhost~]$ yum -y install subversion
1.2 手动离线安装
1.2.1 .gz 源码安装(待完善)
1.2.2 .rpm 包安装 (待完善)
1.3 检查是否安装成功
输出svnserve的版本信息 ,则安装成功。
[root@svn svnrep]$ svnserve --version
svnserve, version 1.7.14 (r1542130)
compiled Sep 30 2020, 17:44:04
copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository back-end (FS) modules are available:
* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.
Cyrus SASL authentication is available.
查看当前系统是否安装了SVN:
[root@svn ~]$ rpm -qa | grep subversion
subversion-1.7.14-16.el7.x86_64
subversion-libs-1.7.14-16.el7.x86_64
如果需要可以通过 rpm 指令进行卸载 :
[root@svn ~]$ rpm -e subversion --nodesps
二、SVN服务器配置&使用
2.1 创建资源库
[root@svn ~]$ svnadmin create /mnt/svnrep
创建成功,进入/mnt/svnrep文件夹,存在目录如下:
[root@svn svnrep]$ ls -l
total 8
drwxr-xr-x. 2 root root 54 Aug 24 17:29 conf
drwxr-sr-x. 6 root root 253 Aug 24 17:46 db
-r--r--r--. 1 root root 2 Aug 24 16:52 format
drwxr-xr-x. 2 root root 231 Aug 24 16:52 hooks
drwxr-xr-x. 2 root root 41 Aug 24 16:52 locks
-rw-r--r--. 1 root root 229 Aug 24 16:52 README.txt
2.2 权限配置
进入/mnt/svnrep/conf 目录下:
[root@svn conf]$ ls -l
total 12
-rw-r--r--. 1 root root 1179 Aug 24 17:29 authz
-rw-r--r--. 1 root root 461 Aug 24 17:29 passwd
-rw-r--r--. 1 root root 3198 Aug 24 17:16 svnserve.conf
authz:负责账号权限的管理
svnserve:SVN服务器配置文件
2.3 设置并添加用户和密码
[root@svn conf]$ vi /mnt/svnrep/passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
#添加用户 & 密码
admin = comleader@123
2.4 设置用户权限
### 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]
# 设置用户组admin
admin = admin, root
dev = usr1, usr2
#根目录下,组成员权限rw,根路径[/mnt/svnrep] 根据svnserve.conf 文件设置的命名空间
[/]
@admin = rw
* = r
#设置文件夹下,组用户权限 如:[/mnt/svnrep/data/svn]
[/data/svn]
@dev = r
2.5 SVN主服务设置
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none #未授权无法访问
auth-access = write #授权用户写权限
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd #用户密码
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz #用户权限
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository
realm = /mnt/svnrep #资源库所在路径
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256
三、 SVN 服务使用
3.1 启动SVN服务(默认端口 3690)
#默认端口3690 且SVN服务器URL svn://(ip)/
[root@svn conf]$ svnserve -d -r /mnt/svnrep
#默认端口3690 且SVN服务器URL svn://(ip)/svnrep
[root@svn conf]$ svnserve -d -r /mnt/
#指定端口3696, SVN服务器URL svn://(ip):3696/
[root@svn conf]$ svnserve -d -r /mnt/svnrep --listen-port 3696
3.2 关闭SVN服务
[root@svn conf]$ killall svnserve
[root@svn conf]$ ps -aux | grep svnserve
root 11953 0.0 0.0 197712 1280 ? Ss 17:22 0:00 svnserve -d -r /mnt/svnrep/
root 13067 0.0 0.0 112716 932 pts/0 S+ 18:54 0:00 grep --color=auto svnserve
[root@svn conf]$ kill -9 11953
至此SVN搭建以及配置完成。
四、问题及解决
4.1 无法访问Error:Can't connect to host "192.168.3.103":由于链接方在一段时间没有正确答复或链接的主机没有反应:
防火墙,3690端口被防火墙限制出站/入栈
systemctl stop firewalld.service
解决方法二(解除3690端口限制):
sudo firewall-cmd --permanent --add-port=3690/tcp
sudo firewall-cmd --reload
4.2 开启需要重新启动SVN服务:
设置开机自启动:
sudo systemctl enable svnserve.service
4.3 格式化硬盘,并挂载到指定目录下作为SVN的版本库
mkfs.xfs /dev/sdb
mount /dev/sdb /mnt/svnrep