要求:
运维组具有全部目录有完全控制权限,部门成员只对自己所属目录有读写权限,部门成员对public有读权限
检查是否已经有svn,如下显示还没安装
svnserve --version
-bash: svnserve: command not found
下面安装svn
yum install -y subversion
安装完成则可以看到如下信息 (若需查看svn安装位置,可以用命令 rpm -ql subversion)
[root@clone1_192.168.16.225 repositories]# svnserve --version
svnserve, version 1.6.11 (r934486)
compiled Apr 11 2013, 16:13:51
Copyright © 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
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.
创建版本库目录
mkdir /data/svn/
创建svn版本库
svnadmin create /data/svn/repositories
执行后,文件夹包含了repositories 目录下conf,db,format,hooks,locks,README.txt等文件,说明一个SVN库已经建立。
authz:负责账号权限的管理,控制账号是否读写权限
passwd:负责账号和密码的用户名单管理
svnserve.conf:svn服务器配置文件
打开passwd 进行用户密码配置
[root@clone1_192.168.16.225 conf]# vim 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
jishu1=123456
meishu1=123456
yunwei1=123456
打开authz 进行权限配置
[root@clone1_192.168.16.225 conf]# vim authz
[groups]
#harry_and_sally = harry,sally
#harry_sally_and_joe = harry,sally,&joe
jishu=jishu1
meishu=meishu1
yunwei=yunwei1
[/public]
@jishu=r
@meishu=r
[/jishu]
@jishu=rw
[/meishu]
@meishu=rw
[/]
@yunwei=rw
/ 表示根目录及以下,根目录是svnserve启动时指定的,我们指定的是/data/svn/;/ 就是指对全部版本库都具有权限
- 权限配置文件中出现的用户名必须已在用户配置文件中定义。
- 对权限配置文件的修改立即生效,不必重启svn。
打开svnserve.conf 配置
[root@clone1_192.168.16.225 conf]# vim svnserve.conf
anon-access = none #匿名访问的权限,可以是read,write,none,默认为read
auth-access = write #授权用户可写
password-db = passwd #使用哪个文件作为账号文件
authz-db = authz #使用哪个文件作为权限文件
realm =/data/svn/repositories #认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字,版本库所在目录
启动SVN
svnserve -d -r /data/svn/
不指定目录可以用
/etc/init.d/svnserve start
查看进程
#ps -ef|grep svn|grep -v grep
root 47946 1 0 19:47 ? 00:00:00 svnserve -d -r /data/svn/
检测SVN端口
服务器默认使用 3690 端口号 , 要使用非默认端口 , 可以在启动命令后面加一个 --listen-port xxxx :
#svnserve -d -r //data/svn/ --listen-port 3691
netstat -ln |grep 3690
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
停止SVN服务:
ps -aux |grep svn
kill -9 进程杀掉
测试
在windows安装TortoiseSVN,并新建 repositories文件夹
yunwei1用户对所有版本库有完全权限
jishu1对jishu有读写权限,对meishu没有权限,对public有读权限
在jishu目录下,创建jishu.txt,使用jishu1提交
在meishu目录下创建meishu.txt,可以发现,用jishu1用户提交时,报错。
在public创建public,用户jishu1和用户meishu1,只能下载,不能上传
下载
上传