SVN是Subversion的简称,是一个开放源代码的版本控制系统,它采用了分支管理系统。
svn服务器有2种运行方式:1.独立服务器 (url:svn://xxx.com/xxx);2.借助apache。(url:http://svn.xxx.com/xxx);
svn存储版本数据也有2种方式:BDB(一种事务安全型表类型)和FSFS(一种不需要数据库的存储系统)。
因为BDB方式在服务器中断时,有可能锁住数据,所以还是FSFS方式更安全一点。
1:yum安装svn服务器:
[root@CentOS-Slave1 svn]# yum -y install subversion
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile ……………… Installed: subversion.x86_64 0:1.7.14-7.el7_1.1 Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 neon.x86_64 0:0.30.0-3.el7 pakchois.x86_64 0:0.4-10.el7 subversion-libs.x86_64 0:1.7.14-7.el7_1.1 Complete!
2:查看svn版本:
[root@CentOS-Slave1 svn]# svn --version svn, version 1.7.14 (r1542130) compiled Sep 8 2015, 18:10:16 ……………………
注:如果版本不合适,可以自己网络下载rpm或者wget安装!
地址之1:http://subversion.tigris.org/downloads/
3:创建svn仓库:
[root@CentOS-Slave1 /]# svnadmin create /home/svn/repository
4:创建成功查看svn仓库结构:
[root@CentOS-Slave1 /]# cd /home/svn/repository/ [root@CentOS-Slave1 repository]# ll total 16 drwxr-xr-x. 2 root root 51 Oct 18 12:21 conf drwxr-sr-x. 6 root root 4096 Oct 18 12:21 db -r--r--r--. 1 root root 2 Oct 18 12:21 format drwxr-xr-x. 2 root root 4096 Oct 18 12:21 hooks drwxr-xr-x. 2 root root 39 Oct 18 12:21 locks -rw-r--r--. 1 root root 229 Oct 18 12:21 README.txt
配置路径:
[root@CentOS-Slave1 conf]# ll total 12 -rw-r--r--. 1 root root 1080 Oct 18 12:21 authz -rw-r--r--. 1 root root 309 Oct 18 12:21 passwd -rw-r--r--. 1 root root 3090 Oct 18 12:21 svnserve.conf
注:目录解说,文章最后备注附件!
5:详细配置备份附件,此处为快速配置:
权限配置文件authz,/ 为svn仓库根目录,下边追究用户:用户名 = 权限
[root@CentOS-Slave1 conf]# cat authz [/] tony = rw
用户名口令文件passwd,下边追究用户:用户名 = 口令(密码)
[root@CentOS-Slave1 conf]# cat passwd [users] tony = 123456
svn服务配置文件,svnserve.conf:
[root@CentOS-Slave1 conf]# cat svnserve.conf [general] anon-access = none anon-access = write password-db = passwd authz-db = authz realm = /home/svn/repository
详细说明和配置,备注附件!
6:启动svn服务:
[root@CentOS-Slave1 conf]# svnserve -d -r /home/svn/repository/
注: -d 表示守护进程, -r 表示在后台执行 ,顺序不能错,/home/svn/repository/ 为svn的安装目录,如果是svn的仓库目录可能出错
***注:设置开机启动:
***注:设置开机启动:
编辑文件:
vim /etc/rc.d/rc.local
/usr/bin/svnserve -d -r /home/svn
注:必须定位svn命令全路径!
/usr/bin/svnserve -d -r /home/svn
注:必须定位svn命令全路径!
7:本地安装客户端,访问:
8:然后从客户端,可以新建文件或者项目,Add到svn(右键单击->TortoiseSVN->有所有命令):
9:然后进行文件的commit提交:
10: 这就一次,新的上传项目,还可以update,reserve,delete等等的操作,上传结果:
11:上传到SVN的文件放在SVN服务器的哪个位置目录下?
[root@CentOS-Slave1 conf]# find / -name 测试文件夹 [root@CentOS-Slave1 conf]#
答疑:
SVN服务器版本库有两种格式,一种为FSFS,一种为BDB: 把文件上传到SVN版本库后,上传的文件不再以文件原来的格式存储,而是被svn以它自定义的格式压缩成版本库数据,存放在版本库中; 如果是FSFS格式,这些数据存放在版本库的db目录中,里面的revs和revprops分别存放着每次提交的差异数据和日志等信息.
错误1:Authorization failed
解决1:检查svn的3个配置文件,配置错误,请仔细检查
错误2:svn仓库不存在等错误,Target path '/repository' does not exist
[root@CentOS-Slave1 conf]# svnserve -d -r /home/svn/repository/ [root@CentOS-Slave1 conf]# ps -ef | grep svn root 7800 1 0 13:43 ? 00:00:00 svnserve -d -r /home/svn/repository/ root 7805 5817 0 13:45 pts/3 00:00:00 grep --color=auto svn [root@CentOS-Slave1 conf]# kill -9 7800 [root@CentOS-Slave1 conf]# svnserve -d -r /home/svn/
解决2:最后参数为svn的目录,去掉版本库名,启动!
备注附件:
详细配置文件:
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段配置用户组和用户 #引用用户组时要使用前缀"@" [groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe # 多个用逗号隔开 developer = kaka,aiai #版本库路径权限段的段名 #[<版本库名>:<路径>] #可省略段名中的版本库名 #若省略版本库名,则该版本库路径权限段对所有版本库中相同路径的访问控制都有效 #"*"表示任何用户 #权限的取值范围为''、'r'和'rw',''表示对该版本库路径无任何权限,'r'表示具有只读权限,'rw'表示有读写权限 #注:每行配置只能配置单个用户或用户组 #可以按组分配权限,也可以用单个用户分配权限 #用户对repository下的coding目录权限 #[repository:/coding] #@developer = rw #* = r #/代表仓库的根目录 [/] #用户组 @developer = rw #单个用户 tony = rw #段名为"[/foo/bar]"的版本库路径权限段设置了所有引用该权限配置文件的版本库中目录"/foo/bar"的访问权限 # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r
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 # 口令配置格式:用户名 = 口令 # 口令为未经过任何处理的明文 tony = 123456 kaka = 123456 aiai = 123456
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.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 = read # 非鉴权用户无权限访问该版本库 anon-access = none # 鉴权用户可对版本库进行读写 anon-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 = /home/svn/repository ### 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
参数和目录结构说明:
[root@CentOS-Slave1 repository]# pwd /home/svn/repository [root@CentOS-Slave1 repository]# ll total 20 drwxr-xr-x. 2 root root 4096 Oct 18 13:55 conf drwxr-sr-x. 6 root root 4096 Oct 18 14:07 db -r--r--r--. 1 root root 2 Oct 18 12:21 format drwxr-xr-x. 2 root root 4096 Oct 18 12:21 hooks drwxr-xr-x. 2 root root 39 Oct 18 12:21 locks -rw-r--r--. 1 root root 229 Oct 18 12:21 README.txt
conf 目录 存放版本库(用户权限/)所用配置文件的目录 dav 目录 供mod_dav_svn使用 db 目录 版本数据存储目录 db/fs-type 文件 版本库数据真实存储格式,SVN有fsfs和bdb两种存储格式 db/revprops 目录 记录版本属性 db/revs 目录 版本库数据存储真实目录 db/uuid 文件 存储版本库唯一标识号 db/txn-current 文件 记录当前事务 format 文件 存储一个整数的文件,此整数代表库层次结构版本 hooks 目录 存放版本库勾子目录 locks 目录 存储库锁目录,用来跟踪库的访问者
root@CentOS-Slave1 conf]# ll total 24 rw-r--r-- 1 root root 1092 Sep 23 21:31 authz -rw-r--r-- 1 root root 322 Sep 23 21:31 passwd -rw-r--r-- 1 root root 2326 Sep 23 21:27 svnserve.conf
svnserve配置文件svn仓库下的conf下的3个文本文件组成: svnserve.conf:svn服务配置文件 passwd:用户名口令文件,该文件名在文件svnserve.conf中指定,缺省为同目录下的 authz:权限配置文件,该文件名也在文件svnserve.conf中指定,缺省为同目录下的 svnserve.conf下由一个[general]配置段组成,[general]配置段中配置行格式:配置项 = 值 anon-access 控制非鉴权用户访问版本库的权限。取值范围为"write"、"read"和"none"。 即"write"为可读可写,"read"为只读,"none"表示无访问权限。 缺省值:read auth-access 控制鉴权用户访问版本库的权限。取值范围为"write"、"read"和"none"。 即"write"为可读可写,"read"为只读,"none"表示无访问权限。 缺省值:write password-db 指定用户名口令文件名。除非指定绝对路径,否则文件位置为相对conf 目录的相对路径。 缺省值:passwd authz-db 指定权限配置文件名,通过该文件可以实现以路径为基础的访问控制。 除非指定绝对路径,否则文件位置为相对conf目录的相对路径。 缺省值:authz 绝对路径:http://www.timespacexstar.com/conf/authz realm 指定版本库的认证域,即在登录时提示的认证域名称。若两个版本库的 认证域相同,建议使用相同的用户名口令数据文件。 缺省值:一个UUID(Universal Unique IDentifier,全局唯一标示)。
注:svnserve服务有效:对客户端通过前缀为svn://或svn+ssh://的URL访问版本库有效,对通过前缀http://、https://或
file:///的URL无效.
eclipse插件地址:
Links for 1.8.x Release: Name:Subclipse Eclipse update site URL: http://subclipse.tigris.org/update_1.8.x svn插件包下载: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240 Links for 1.6.x Release: Eclipse update site URL: http://subclipse.tigris.org/update_1.6.x svn插件包下载: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240 Links for 1.4.x Release: Eclipse update site URL: http://subclipse.tigris.org/update_1.4.x svn插件包下载: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240