学习笔记 (Linux下subversion服务端多版本库配置) [第五课-可忽略]

来源:互联网 发布:手机哼歌识曲的软件 编辑:程序博客网 时间:2024/05/01 08:40

声明:为了节省你的时间,请直接转向git的搭建和使用。
时间:2016-10-25 16:24:51 安贞新华金融大厦


版本控制软件是C/S模式的软件,有服务器端和客户端,这里说的是在Linux上安装Subversion的服务器端,提供版本控制服务功能。

subversion安装

先使用下面的命令查看系统是否已经安装了subversion:rpm -qa | grep subversion

使用下面的命令安装:yum  install subversion

安装之后使用下面的命令查看是否安装成功: svnserve --version

此时,并没有启动subversion的服务 svnserve


说明:在centos下启动svnserve的方式有两种:

services svnserve start 或者是  /etc/rc.d/init.d/svnserve start (这种方式是标准的,通用的)


但是我们并不使用这种方法启动,因为这样启动的是默认方式,我们要实现的目标是:启动svnserve,使之同时控制多个版本库,同时所有版本库使用相同的配置文件,又该如何实现?


创建多个版本库

假设我们的版本库全部放到 /data/目录下面

使用下面的命令可以创建版本库

svnadmin create /data/repo_cms

svnadmin create /data/repo_bbs

svnadmin create /data/repo_blog

这样我们就创建了3个版本库,然后创建配置文件保存目录,mkdir /data/conf


为了方便起见,你可以直接将之前创建的3个版本库中的任何一个版本库下面的conf目录下面的文件拷贝到你新创建的 /data/conf目录下面,

里面有三个文件,分别是 passwd、authz和svnserve.conf

passwd                      用户名密码保存文件

authz                           认证信息保存文件,可以对用户,用户组等配置权限

svnserve.conf            svnserve服务主配置文件


设置配置文件信息

下面分别给出3个文件的参考内容,你可以根据自己的情况对下面配置内容进行修改


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

#根据自己实际情况在下面添加用户

#格式为 用户名 = 密码

#要求是每行一个用户

svnuser = svnuser


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

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

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

# 下面是自己添加的授权信息,[/] 表示版本库根目录 svnuser = rw 表示 用户 svnuser 对版本库根目录有读写权限
[/]
svnuser = rw


svnserve.conf  文件

### 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.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = read
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 = repo_cms

[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


取消上面蓝色标出的五行的注释,并将realm的值设置为其中一个存在的版本库作为默认版本库,这里是设置成了realm=repo_cms



启动版本控制服务

使用下面的命令启动版本控制服务,这样就可以实现一套配置文件可以控制多个版本库系统

svnserve -d -r /data/ --config-file=/data/conf/svnserve.conf

启动说明:

svnserve :版本控制服务进程名称

-d 表示启动后成为守护进程,在后台运行

-r 表示指定svnserve版本库控制的根目录是 /data/

--config-file=配置文件路径 表示使用指定的配置文件启动svnserve

这样就实现了通过一个配置文件控制多个版本库的目的了



===============================================================================================

然后在客户端使用svn客户端软件连接访问即可。


说明:

我们一般情况下如果只是使用一个版本库,可以直接安装subversion后,使用/ect/rc.d/init.d/svnserve statr启动服务

使用svnadmin create 创建版本库,然后直接通过修改创建的版本库里面的conf文件夹下面的配置文件配置该库的属性和权限

然后使用客户端连接就可以了。

这样如果要创建多个版本库,只需要多次使用svnadmin create创建就可以了,并且默认情况下面每个版本库使用自己的conf目录下面的配置文件进行配置。


0 0