Fork me on GitHub

linux服务之svn

架构:c/s

开发语言:python

服务器端:在linux平台下部署

客户端:分gui与cli两种操作界面

相关包:

 

http://blog.sina.com.cn/s/blog_53b95aec0100ga3x.html  svn 出错信息总汇 

http://blog.csdn.net/daniel_h1986/article/details/8159811   SVN分支/合并原理及最佳实践

一种典型的项目代码实践方式是:
存在一个代码基线(Base Line)或称主干,不同的模块使用各自的分支进行功能开发,在开发完毕后合并回主干,准备交付。 

 

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

http://www.zhihu.com/question/20003204

http://blog.csdn.net/kahnsen/article/details/33724839

 

http://www.iteye.com/problems/102384

http://www.infoq.com/cn/articles/dev-op-xebia/

 

svn根目录
Trunk:主开发目录。
Branches:分支开发目录及测试目录,版本正式发布并生成tag后删除。
Tags:已发布版本(包括补丁)的存档目录,不允许修改。
Release:程序发布目录,含运行程序、升级脚本和标准库。由配置管理员在版本发布时创建。

trunk
Bin:运行程序存放路径。
Control:第三方控件存放路径。
Documents:产品开发文档存放路径。
Management:项目管理类文档存放路径。
Procedure:存储过程或包、初始化数据及视图存放路径。
Script:数据库升级更新脚本存放路径。
Sources:源代码存放路径。
Tools:工具存放路径

Branches
一级目录为程序修改版本标识,二级目录的目录结构与trunk一致。

Tags
一级目录为已发布程序基线版本号,二级目录为子版本标志,比如BL表示基线版本,sp1表示对应基线的第一个大补丁版本呢,三级目录的目录结构与trunk一致。

Release
一级目录为已发布程序基线版本号,二级目录如下:
Bin:执行程序存放位置。
Bin\Doc:操作手册、安装手册及升级说明存放位置。
Patch:补丁存放位置
Procedure:存储过程或包、初始化数据及视图存放位置。
Script:数据库升级更新脚本存放位置。
Stddb:标准库存放位置 


svn上面有这个功能,采用建立多个分支的方法,你把还在开发的项目放到trunk分支下,在这里进行功能增加和修改,把上线的项目放到release分支下,每增加或修改bug后把这两个分支merge一下,然后重新发布到release分支下

其实,如果能够灵活利用svn diff 命令,流程还可以更加优化。


版本库部署发布流程化

版本库的管理
    主干,分支,tag,release的管理
    权限的定义与分配
得到要发布的版本
    修改配置文件及其它参数
测试环境的部署(外网环境)
    作一些验证还有一些修改bug之类的操作
    功能的完备
    测试3天时间
预生产环境的部署(外网真实环境与生产环境一模一样)
    性能测试
    只用来客户端测试使用
    测试2天时间
    无问题的话直接同步到生产环境中
生产环境的部署

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

 

 

 

 

# Dictionary:
# BASE revision     基础版本
# blame             追溯
# branch            分支
# checkout          检出
# default           默认
# HEAD revision     最新版本
# overlay           重载  n. 覆盖图;覆盖物
# remove            删除
# rename            改名
# repository        版本库
# revert            恢复
# revision          版本
# Subversion book   Subversion 手册
# undo              撤销
# unified diff      标准差异
# unversioned       未版本控制
# versioned         已版本控制
# working copy      工作副本

 

nfs上的svn即svn的根目录位于nfs共享之中。挂载时要加-o nolock,不然建库时很慢,且报

[root@host02 bb]# svnadmin create 3a
svnadmin: database is locked
svnadmin: database is locked

mount  -o nolock 172.16.1.2:/mnt/vg0-file/svn/svn2/ /mnt/cc

 

Subversion tries to retain this atomicity in the face of program crashes, system crashes, network problems, 突然断电and other users' actions.

Typically, Subversion uses two config directories,
one for site-wide configuration
(/etc/subversion/)
and
one for per-user configuration
(~/.subversion)

/etc/profile
~/.bash_profile

 

 

svn版本库目录结构
该文是svn源代码分析系列文章服务端架构中的一篇,主要描述svn服务端版本库数据存储目录结构,并且对这些文件以及目录的作用进行简单分析。使用“svnmadin create”命令创建初始化版本库后,使用“tree”命令打印出没有经过任何修改的原始版本库目录。

$ svnadmin create /svnrepos/morepos
$ tree /svnrepos/morepos -p

 

conf 目录 存放版本库所用配置文件的目录
dav 目录 供mod_dav_svn使用
db 目录 版本数据存储目录
db/fs-type 文件 版本库数据真实存储格式,SVN有fsfs和bdb两种存储格式
db/revprops 目录 记录版本属性
db/revs 目录 版本库数据存储真实目录
db/uuid 文件 存储版本库唯一标识号,参考《svn版本库标识uuid简述》
db/txn-current 文件 记录当前事务
format 文件 存储一个整数的文件,此整数代表库层次结构版本
hooks 目录 存放版本库勾子目录
locks 目录 存储库锁目录,用来跟踪库的访问者

其中revs下面是以目录组织的版本结构,每1000个版本组成一个目录,每个版本自成一个文件,文件名即为commit后生成的版本号;即使删除掉部分版本也不会影响版本库的读取和显示;但是基础版本丢失会使版本库无法访问;

    版本库目录格式:
    [<版本库>:/项目/目录]
    @<用户组名> = <权限>
    <用户名> = <权限>
    其中,方框号内部分可以有多种写法:
    /,表示根目录及以下。根目录是svnserve启动时指定的,我们指定/svn/svndata。这样,/就是表示对全部版本库设置权限。
    repos1:/,表示对版本库1设置权限
    repos2:/abc, ,表示对版本库2中的abc项目设置权限
    repos2:/abc/aaa, ,表示对版本库2中的abc项目的aaa目录设置权限
    权限主体可以是用户组、用户或*,用户组在前面加@,*表示全部用户。权限可以是w、r、wr和空,空表示没有任何权限。


SVN是基于关系数据库或一系列二进制文件,一方面解决了许多问题(例如并行读写共享文件),以及添加了许多新功能。但是数据由此变得不透明,在服务器上是不能看到上传的文件的原件的

 

20.版本库的存储

唯一真正对FSFS不利的是相对于Berkeley DB的不成熟,缺乏足够的使用和压力测试,许多关于速度和可扩展性的判断都是建立在良好的猜测之上。在理论上,它承诺会降低管理员新手的门槛并且更加不容易发生问题。在实践中,只有时间可以证明。
总之,这两个中并没有一个是更正式的,访问版本库的程序与采用哪一种实现方式无关。通过上文和下表(从总体上比较了Berkeley DB和FSFS版本库),读者可以自行选择自己需要的存储方式

subversion-1.6.11 采用python2.6开发,存储使用BDB

svn服务器有2种运行方式:独立服务器和借助apache等web服务器。两种方式各有利弊。svn存储版本数据也有2种方式:BDB和FSFS。因为BDB方式在服务器中断时,有可能锁住数据,所以还是FSFS方式更安全一点。Subversion 的版本库(repository),就是位于服务器端,统一管理和储存数据的地方。要创建一个版本库,首先要确定采用哪种数据存储方式。在 Subversion 中,版本库的数据存储有两种方式,一种是在 Berkeley DB 数据库中存放数据;另一种是使用普通文件,采用自定义的格式来储存,称为 FSFS。

那你应该用什么服务器?什么最好?
显然,对这个问题没有正确的答案,每个团队都有不同的需要,不同的服务器都有各自的代价。Subversion项目没有更加认可哪种服务,或认为哪个服务更加“正式”一点。
下面是你选择或者不选择某一个部署方式的原因。

简单地说,SVN+SSH (SVN over SSH) 协议的工作方式就是在SVN客户端与服务器端先建立一个SSH连接,然后通过SSH连接推送命令和传输数据,从而借助SSH实现更加安全的SVN通信。使用SVN+SSH方式访问Repository,与普通的http或https方式最大的不同,或者说仅有的不同就是通过SSH安全认证登录到远程主机建立SSH连结,如果这一步完成了,剩下的就是纯SVN操作了。http://blog.csdn.net/bluishglc/article/details/8705864

linux(Centos6)安装SVN支持svn和svn+ssh方式

All Subversion protocols are supported

  • http://
  • https://
  • svn://
  • svn+ssh://
  • file:///
  • svn+XXX://

http://www.subversion.org.cn/svnbook/1.4/index.html

http://www.subversion.org.cn/
建立版本库
配置用户与权限
运行独立服务器
初始化导入
基本客户端操作
    取出一个workcopy
    修改并提交
    查看修改

[root@svnserv svnconf]# svn --version
svn, version 1.6.11 (r934486)
   compiled Mar  5 2014, 14:32:27

Copyright (C) 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 access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

服务器端安装配置

源码安装

http://subversion.tigris.org/downloads/subversion-1.4.0.tar.gz
http://subversion.tigris.org/downloads/subversion-deps-1.4.0.tar.gz
编译:
以root用户登录。
将subversion-1.4.0.tar.gz和subversion-deps-1.4.0.tar.gz传到服务器。
tar xfvz subversion-1.4.0.tar.gz
tar xfvz subversion-deps-1.4.0.tar.gz
subversion-deps包有四个目录zlib apr apr-util neon这四个目录都是依赖包,编译subversion所必须的代码
cd subversion-1.4.0
./configure –prefix=/opt/svn –without-berkeley-db –with-zlib
(注:以svnserve方式运行,不加apache编译参数。以fsfs格式存储版本库,不编译berkeley-db)
make clean
make
make install
vi /etc/profile,在/etc/profile最后加入:
PATH=$PATH:/opt/svn/bin
export PATH
测试:
svnserve –-version
如果显示如下,安装成功:

启动svn
建立启动svn的用户:
useradd svn
passwd svn
根据提示为用户svn设置密码
允许用户svn访问版本库:
chown -R svn:svn /opt/svndata
chown -R svn:svn /opt/data
启动svn:
su - svn -c “svnserve -d –listen-port 9999 -r /opt/svndata”
其中:
su - svn表示以用户svn的身份启动svn
-d表示以daemon方式(后台运行)运行
–listen-port 9999表示使用9999端口,可以换成你需要的端口。但注意,使用1024以下的端口需要root权限
-r /opt/svndata指定根目录是/opt/svndata
检查:
ps -ef|grep svnserve
如果显示如下,即为启动成功:
svn    6941   1 0 15:07 ?    00:00:00 svnserve -d –listen-port 9999 -r /opt/svndata

注意:
* 权限配置文件中出现的用户名必须已在用户配置文件中定义。
* 对权限配置文件的修改立即生效,不必重启svn。

yum安装

安装(centos下yum即可方便的完成安装)
# yum install subversion
测试安装是否成功:
# svnserve --version 回车显示版本说明安装成功

http://tortoisesvn.net/downloads.html    客户端乌龟
http://www.cnblogs.com/wrmfw/archive/2011/09/08/2170465.html

[root@localhost ~]# svnadmin create --fs-type bdb /root/aa
svnadmin: Repository creation failed
svnadmin: Could not create top-level directory
svnadmin: '/root/aa' exists and is non-empty
[root@localhost ~]# mkdir svnrepo
[root@localhost ~]# svnadmin create --fs-type bdb /root/svnrepo/
[root@localhost conf]# vi svnserve.conf
[svnrepo]
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = svnrepo
[root@localhost conf]# vi passwd
fgy = fgy
[root@localhost conf]# vi authz
[/]
fgy = rw
[root@localhost conf]# killall svnserve
[root@localhost conf]# svnserve  -d -r /root/svnrepo/
配置SVN服务器的HTTP支持
配置邮件提醒支持

etc/rc.d/init.d/svnserve
etc/subversion
usr/bin/svn
usr/bin/svnadmin
usr/bin/svndumpfilter
usr/bin/svnlook
usr/bin/svnserve
usr/bin/svnsync
usr/bin/svnversion

# 创建文件夹   
$ mkdir /etc/svn/repos  
# 运行创建版本库的命令,指定数据存储为 FSFS,如果要指定为 Berkeley DB,则将 fsfs 替换为 bdb  
$ svnadmin create --fs-type fsfs /etc/svn/repos

172.16.1.9 svn-server
/usr/bin/svnserve -d -r /home/svnroot
启动服务器
# svnserve -d -r /svndata
-d表示以daemon方式(后台运行)运行
-r /svndata指定根目录是/svndata
关闭SVN 服务器
# killall svnserve
# ps aux | grep svnserve 查看服务,端口:3690

每个版本库创建之后都会生成svnserve.conf主配文件
cat /home/svnroot/flt8a-2-server/conf/svnserve.conf
realm =kuming 库名

其中一个版本库
/home/svnroot/flt-oa
drwxr-xr-x 2 root root 4096 Jul 23  2013 conf
drwxr-sr-x 6 root root 4096 Jun 18 16:39 db
-r--r--r-- 1 root root    2 Jul 23  2013 format
drwxr-xr-x 2 root root 4096 Jul 23  2013 hooks
drwxr-xr-x 2 root root 4096 Jul 23  2013 locks
-rw-r--r-- 1 root root  229 Jul 23  2013 README.txt

[root@svnserv svnconf]# pwd
/home/svnroot/svnconf
-rw-r--r-- 1 svn svn 3958 Jun  9 14:02 authz
-rw-r--r-- 1 svn svn  631 Jun  9 14:03 passwd

# vim /home/svnroot/svnconf/passwd //svn用户配置文件
[users]
user1 = password1
user2 = password2
user3 = password3
user4 = password4
# vim /home/svnroot/svnconf/authz //svn权限控制配置文件
[groups] //设置组
group1 = user1,user2 #多用户用逗号隔开

[/] #根目录权限设置(就是“kuming”这个文件夹)
user3 = rw #用户1权限是:可读写
user4 = r #用户2权限是:可读,不可写
user = #什么都没写代表没有任何权限

@group1 = rw #设置组权限

[kuming:/123] #设置根目录下“123”文件夹的权限
#说明“123”这个文件件怎么创建?这是在SVN服务器配置好之后,创建一个权限很高的用户在客户端登录SVN
#然后创建一个文件夹“123”。

客户端配置

在Windows下推荐使用乌龟(Tortoise)SVN客户端。 TortoiseSVN 是 Subversion 版本控制系统的一个免费开源客户端,可以超越时间的管理文件和目录。文件保存在中央版本库(即SAE中央SVN仓库),除了能记住文件和目录的每次修改以外,版本库非常像普通的文件服务器。你可以将文件恢复到过去的版本,并且可以通过检查历史知道数据做了哪些修改,谁做的修改。这就是为什么许多人将 Subversion 和版本控制系统看作一种“时间机器”。
windows下的TortoiseSVN是资源管理器的一个插件,以覆盖图标表示文件状态,几乎所以命令都有图形界面支持,比较好用,这里就不多说。

(如果是第一次提交文件,很可能会出现“svn:'.'不是工作副本”,即当前目录不是工作副本,这个时候需要用到import:eg:svn import . url)

1、将文件checkout到本地目录
svn checkout path(path是服务器上的目录)
例如:svn checkout svn://192.168.1.1/pro/domain
简写:svn co
如果用户名输错,不能再连接的时候,删除下面的文件即可
[root@CentOS5 flt-oa]# svn co svn://172.16.1.9/flt-oa
[root@CentOS5 svn.simple]# rm -rf /root/.subversion/auth/svn.simple/8cad8fa6684ca29a56e83e7390947c1a

[root@CentOS5 fgy]# svn log flt-oa/index.php
[root@CentOS5 fgy]# svn info index.php    

svn help import

http://sae.sina.com.cn
1、从SVN仓库中检索出代码到工作拷贝:
# svn checkout https://svn.sinaapp.com/appname [workcopy]
其中workcopy是可选的,如果不写workcopy,SVN会默认将appname做为workcopy。
如果只检索某个版本:
# svn checkout https://svn.sinaapp.com/appname/appversion [workcopy]
只检索某个版本的某个目录:
# svn checkout https://svn.sinaapp.com/appname/appversion/folder [workcopy]

 

 

基本概念
An svn commit operation publishes changes to any number of files and directories as a single atomic transaction
atomic transaction    基本交易,原子事务类似于元数据metadata
repository与project一个库可能包含多个项目
versioning models
1.The Lock-Modify-Unlock Solution
2.The Copy-Modify-Merge Solution
working copy
revisions

下面是双向动作的概念对比
publish,push,写库,unpublished changes,commit,check in
merge,pull,读库,out of date,update,check out

 

linux客户端使用

0 查看当前工作目录svn 状态
简写:svn st

1、将文件checkout到本地目录
svn checkout path(path是服务器上的目录)
简写:svn co
svn co svn://172.16.1.14/7a --username fgy1 --password 123456
2、往版本库中添加新的文件,如果不添加,就不能提交(commit) svn add file
svn commit aa.txt -m "eifej"
svn: Commit failed (details follow):
svn: '/root/svn/7a/aa.txt' is not under version control

11:14:44 16 ~/svn/7a:#svn add aa.txt
A         aa.txt
11:15:07 17 ~/svn/7a:#svn commit aa.txt -m "eifej"
Adding         aa.txt
Transmitting file data .
Committed revision 10.

3、将改动的文件提交到版本库 svn commit -m “LogMessage” [-N] [--no-unlock] PATH(如果选择了保持锁,就使用–no-unlock开关) 简写:svn ci 4、加锁/解锁 svn lock -m “LockMessage” [--force] PATH svn unlock PATH 5、更新到某个版本 svn update -r m path 简写:svn up 6、查看文件或者目录状态 1)svn status path(目录下的文件和子目录的状态,正常状态不显示) 2)svn status -v path(显示文件和子目录状态) 简写:svn st 7、删除文件 svn delete path -m “delete test fle” 简写:svn (del, remove, rm) 8、查看日志 svn log path 9、查看文件详细信息 svn info path 10、比较差异 svn diff path(将修改的文件与基础版本比较) svn diff -r m:n path(对版本m和版本n比较差异) 简写:svn di 11、将两个版本之间的差异合并到当前文件 svn merge -r m:n path 12、SVN 帮助 svn help svn help ci [root@c64 build-finished]# svn st svn: warning: '.' is not a working copy [root@c64 build-finished]# mkdir web [root@c64 build-finished]# svn co svn://172.16.1.9/flt8a-2-server/webserver/trunk /root/newbuild/build-finished/web [root@c64 web]# svn help usage: svn <subcommand> [options] [args] Subversion command-line client, version 1.6.11. Type 'svn help <subcommand>' for help on a specific subcommand. Type 'svn --version' to see the program version and RA modules or 'svn --version --quiet' to see just the version number. Most subcommands take file and/or directory arguments, recursing on the directories. If no arguments are supplied to such a command, it recurses on the current directory (inclusive) by default. [root@c64 web]# svn info Path: . URL: svn://172.16.1.9/flt8a-2-server/webserver/trunk Repository Root: svn://172.16.1.9/flt8a-2-server Repository UUID: e452d122-dd6b-4849-94b0-2d396b7a452b Revision: 2670 Node Kind: directory Schedule: normal [root@c64 web]# svn ls .htaccess application/ attach cache/ data/ favicon.ico getRoute.php index.php load_data.sh shellext/ sqlnet.log system/ tcp.php upfile/ welcome.html [root@c64 web]# svn log -v|more ------------------------------------------------------------------------ r2670 | deravo | 2015-05-20 09:24:59 +0800 (Wed, 20 May 2015) | 1 line Changed paths: M /webserver/trunk/application/models/api/mod_rep_org.php ------------------------------------------------------------------------ r2669 | deravo | 2015-05-19 17:32:52 +0800 (Tue, 19 May 2015) | 1 line Changed paths: M /webserver/trunk/application/controllers/api/Relation/CarAndDriver/Get.php ------------------------------------------------------------------------ r2668 | deravo | 2015-05-19 17:30:58 +0800 (Tue, 19 May 2015) | 1 line Changed paths: M /webserver/trunk/application/controllers/api/BasicInfo/Vehicle/Del.php [root@c64 web]# svn log -v -r 2386 ------------------------------------------------------------------------ r2386 | deravo | 2015-01-15 17:22:24 +0800 (Thu, 15 Jan 2015) | 1 line Changed paths: M /webserver/trunk/application/controllers/api/Alarm/Action/act_Deal_Realtime_Result.php M /webserver/trunk/application/models/api/mod_alarm.php ------------------------------------------------------------------------ [root@c64 web]# svn up At revision 2670. [root@c64 web]# svn up A 新建文本文档.txt Updated to revision 2671. [root@c64 web]# svn st --show-updates Status against revision: 2671 [root@c64 api]# pwd /root/newbuild/build-finished/web/application/models/api [root@c64 api]# svn di -r 2640:2670 mod_org.php Index: mod_org.php =================================================================== --- mod_org.php (revision 2640) +++ mod_org.php (revision 2670) @@ -91,7 +91,8 @@ NULL TRANSPORT_NUM, NVL(VEHICLE_COUNT, 0) VEHICLE_COUNT, NVL(ONLINE_COUNT, 0) ONLINE_COUNT, - PLATE_SHOW_TYPE")->from(" + PLATE_SHOW_TYPE, + MONITOR_TYPE")->from(" (SELECT * FROM ORG_INFO WHERE ORG_ID = 120000 ) OI LEFT JOIN (

 

上传的文件放在SVN服务器的哪个目录下

SVN服务器版本库有两种格式,

一种为FSFS,

一种为BDB

把文件上传到SVN版本库后,上传的文件不再以文件原来的格式存储,而是被svn以它自定义的格式压缩成版本库数据,存放在版本库中。

如果是FSFS格式,这些数据存放在版本库的db目录中,里面的revs和revprops分别存放着每次提交的差异数据和日志等信息

 

The Cyrus Simple Authentication and Security Layer is open source software written by Carnegie Mellon University. It adds generic authentication and encryption capabilities to any network protocol, and as of Subversion 1.5 and later, both the svnserve server and TortoiseSVN client know how to make use of this library.


The Cyrus Simple Authentication and Security Layer is open source software written by Carnegie Mellon University. It adds generic authentication and encryption capabilities to any network protocol, and as of Subversion 1.5 and later, both the svnserve server and svn client know how to make use of this library. 

源码包  if you're building Subversion yourself
二进制包  If you're using a prebuilt Subversion binary package

It may or may not be available to you: if you're building Subversion yourself, you'll need to have at least version 2.1 of SASL installed on your system, and you'll need to make sure that it's detected during Subversion's build process. If you're using a prebuilt Subversion binary package, you'll have to check with the package maintainer as to whether SASL support was compiled in.
SASL comes with a number of pluggable modules that represent different authentication systems: Kerberos (GSSAPI), NTLM, OneTime-Passwords (OTP), DIGEST-MD5, LDAP, Secure-Remote-Password (SRP), and others.
Certain mechanisms may or may not be available to you; be sure to check which modules are provided.


For many teams, the built-in CRAM-MD5 authentication is all they need from svnserve. However, if your server (and your Subversion clients) were built with the Cyrus Simple Authentication and Security Layer (SASL) library, you have a number of authentication and encryption options available to you.


inherently    adv. 内在地;固有地;天性地

Normally, when a subversion client connects to svnserve, the server sends a greeting that advertises a list of the capabilities it supports, and the client responds with a similar list of capabilities.
If the server is configured to require authentication, it then sends a challenge that lists the authentication mechanisms available; the client responds by choosing one of the mechanisms, and then authentication is carried out in some number of round-trip messages.
Even when SASL capabilities aren't present, the client and server inherently know how to use the CRAM-MD5 and ANONYMOUS mechanisms (see the section called “Built-in Authentication and Authorization”).
If server and client were linked against SASL, a number of other authentication mechanisms may also be available. However, you'll need to explicitly configure SASL on the server side to advertise them.


SASL is also able to perform data encryption if a particular mechanism supports it.
The built-in CRAM-MD5 mechanism doesn't support encryption, but DIGEST-MD5 does, and mechanisms such as SRP actually require use of the OpenSSL library.

 

 client and server自带cram-md5与anonymous机制,只支持认证,不支持加密。要加密就要安装 yum install cyrus-sasl-md5

Subversion1.5引入了SASL库,这给了我们机会使用SASL提供的认证方式来为svnserve进行认证。
SASL核心发布目前支持认证协议有:
    ANONYMOUS
    CRAM-MD5
    PLAIN
    GSSAPI (MIT Kerberos 5 or Heimdal Kerberos 5)
    DIGEST-MD5
也支持如下的认证协议:
    LOGIN
    SRP
    NTLM
    OTP
    KERBEROS_V4

 sasl支持认证与加密

参考http://tortoisesvn.net/sasl_howto.html和svn-book

1.先看是否支持sasl

[Thu Nov 19 09:35:19 1029 /dev/pts/0 192.168.2.250 /svnroot/personal/conf]#svnserve --version
svnserve, version 1.6.11 (r934486)
   compiled Aug 17 2015, 08:37:43

Copyright (C) 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.

2.创建版本库
svnadmin create /svnroot/personal

3.安装支持库
[Thu Nov 19 09:35:25 1030 /dev/pts/0 192.168.2.250 /svnroot/personal/conf]#yum install cyrus-sasl-md5

4.修改为下面的
[Thu Nov 19 09:35:25 1030 /dev/pts/0 192.168.2.250 /svnroot/personal/conf]#grep -v "^#" svnserve.conf
[general]
anon-access = none
auth-access = write
authz-db = authz
realm = tele125server

[sasl]
use-sasl = true
min-encryption = 128
max-encryption = 256

5.sasl文件操作
mv /etc/sasl2/smtpd.conf /etc/sasl2/svn.conf
vi /etc/sasl2/svn.conf

pwcheck_method: auxprop
auxprop_plugin: sasldb
sasldb_path: /svnroot/personal/conf/sasldb
mech_list: DIGEST-MD5
只写一个DIGEST-MD5,意味着严格限制客户端,如果不严格限制,可以加
ANONYMOUS,CRAM-MD5,DIGEST-MD5
However, if you still want non-SASL clients to be able to authenticate, be sure to advertise the CRAM-MD5 mechanism as an option. All clients are able to use CRAM-MD5, whether they have SASL capabilities or not.

6.用户操作 添加用户 -u realm,这个realm与svnserve.conf中的realm要一致 saslpasswd2 -c -f /svnroot/personal/conf/sasldb -u tele125server fgy 查询用户 sasldblistusers2 -f /svnroot/personal/conf/sasldb 7.启动服务 svnserve -d -r /svnroot/ 过程中遇到的问题 1.用linux下的svn客户端报下面错误 svn: Cannot negotiate authentication mechanism 2.用win下的torisesvn客户端报下面错误 SASL authentication error: SASL(-1): generic failure: Unable to find a callback: 2 3.用win下的torisesvn客户端报下面错误 URL 'svn://125.76.228.16:873/personal' doesn't exist 问题解答 1与2其实要注意下面的书写,(还有客户端与服务端都要安装 yum install cyrus-sasl-md5这个包) mech_list: DIGEST-MD5 还有要做这个操作,默认是smtpd.conf。 mv /etc/sasl2/smtpd.conf /etc/sasl2/svn.conf 3的问题是服务启动时,要用下面, svnserve -d -r /svnroot 而不是 svnserve -d -r /svnroot/personal

 

14:53:03 99 ~/.subversion/auth/svn.simple:#cat 5863bb9415deff2b0aefee67ce902430
K 8
passtype
V 6
simple
K 8
password
V 6
123456
K 15
svn:realmstring
V 39
<svn://125.76.238.16:873> tele125server
K 8
username
V 3
f3y
END

本地出现这种提示的话,
选择no就是加密是下面这个文件里的内容
选择yes就是不加密是上面这个文件里的内容,密码明文保存

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://125.76.228.16:873> tele125server

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no

14:46:36 88 ~/.subversion/auth/svn.simple:#cat 5863bb9415deff2b0aefee67ce902430
K 15
svn:realmstring
V 39
<svn://125.76.238.16:873> tele125server
K 8
username
V 3
f3y
END

 

windows visualSVN迁移到linux下的subversion

将win下的库目录直接复制到linux下
svnserve -d -r /root/Repositories --log-file /root/svn.log

密码权限问题: windows下visualSVN使用apache的htpasswd,htpasswd密码采用md5加密 Linux下svn的passwd文件的密码是明文形式保存的。所以原来的MD5密码将不可使用。 版本问题:乌龟去连接时报下面的错误 Unable to connect to a repository at URL 'svn://192.168.1.153/test' Expected FS format between '1' and '4'; found format '6' 将conf下的format与conf/db/下的format改一下

 

 

yum install subversion httpd mod_ssl mod_dav_svn
[root@svn-199 svn]# cat /etc/httpd/conf.modules.d/00-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
[root@svn-199 svn]# cat /etc/httpd/conf.modules.d/10-subversion.conf
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
LoadModule dontdothat_module  modules/mod_dontdothat.so


分两种情况,空库,有数据的库

一。空库

svn部分

mkdir /home/svnroot
svnadmin create /home/svnroot/test
htpasswd -c /home/svnroot/test/conf/passwd lichao

将已有文件导入新库中
mkdir /home/aa
cp /root/svn.log /root/xe-guest-utilities-* /home/aa/
svn import /home/aa/ file:///home/svnroot/test/ -m "init"


[root@svn-199 svn]# cat /etc/sysconfig/svnserve 
# OPTIONS is used to pass command-line arguments to svnserve.
# 
# Specify the repository location in -r parameter:
#OPTIONS="-r /var/svn"
#OPTIONS="-d -r /root/Repositories --log-file /root/svn.log"
#OPTIONS="-d -r /home/svn/Repositories --log-file /root/svn.log"
OPTIONS="-d -r /home/svnroot --log-file /root/svn.log"

[root@svn-199 svn]# cat /home/svnroot/test/conf/authz
[/]
lichao = rw

https部分(ssl部分)

cd /etc/pki/tls/private  
openssl genrsa -out my.key 1024    
openssl req -new -key my.key -out my.csr  
cd /etc/pki/tls/certs  
openssl x509 -req -days 365 -in /etc/pki/tls/private/my.csr -signkey /etc/pki/tls/private/my.key -out my.crt  

修改为下面/etc/httpd/conf.d/ssl.conf文件
SSLCertificateFile /etc/pki/tls/certs/my.crt  
SSLCertificateKeyFile /etc/pki/tls/private/my.key

修改为下面/etc/httpd/conf/httpd.conf
<Directory />
    AllowOverride none
    Require all denied
主要是添加下面行,也可以将下面行加入到subversion.conf中,以达到只影响svn目录的效果。
    SSLRequireSSL
</Directory>


http目录部分

[root@svn-199 svn]# cat /etc/httpd/conf.d/subversion.conf 
<Location /svn>
     DAV svn
     SVNListParentPath on
     SVNParentPath /home/svnroot
     AuthType Basic
     AuthName "Authorization"
     AuthUserFile /home/svnroot/test/conf/passwd
     AuthzSVNAccessFile /home/svnroot/test/conf/authz
     Require valid-user
    SSLRequireSSL </Location>
SVNParentPath路径必须为svnadmin create生成数据仓库路径的父目录,如上面建立数据仓库的命令为svnadmin create /storage/svn/aiezu,则SVNParentPath为/storage/svn。
启动服务并查看报错 systemctl start svnserve httpd 两个日志可以查看报错 /var/log/httpd/error.log /root/svn.log 测试部分 浏览器访问https://ip/svn,看ssl,认证,及目录是否能看到。 二。有数据的库 将windows平台的visualSVN库打包压缩,然后传到linux上,再解包 unzip Repositories.zip [root@svn-199 svn]# cat /etc/httpd/conf.d/subversion.conf <Location /svn> DAV svn SVNListParentPath on SVNParentPath /home/svn/Repositories AuthType Basic AuthName "Authorization" AuthUserFile /home/svn/Repositories/SinoPes-xa/conf/passwd AuthzSVNAccessFile /home/svn/Repositories/SinoPes-xa/conf/authz Require valid-user </Location>

 

 
客户端
服务器
管理端
======================================
[root@oracle4 conf]# svn --version
svn, version 1.6.11 (r934486)
   compiled Aug 17 2015, 08:37:43

Copyright (C) 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 access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
 
========================================
[root@oracle4 conf]# svnserve --version
svnserve, version 1.6.11 (r934486)
   compiled Aug 17 2015, 08:37:43

Copyright (C) 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.
========================================
[root@oracle4 conf]# svnadmin --version
svnadmin, version 1.6.11 (r934486)
   compiled Aug 17 2015, 08:37:43

Copyright (C) 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.


tortoiseSVN

1、解决冲突的问题
reslove后再update
2、通过repo browser删除的目录,先要更新一下才能用
3、branch/tag时不需要事先创建目录

svnadmin help
svnadmin --version
svnadmin help create
svnadmin create /svnroot/


potential chaos    潜在的混乱
tailored    adj. 定做的;裁缝做的;剪裁讲究的
overlay        vt. 覆盖;遮盖
overlaps    v. 重叠;重复(overlap的第三人称单数)
typos    n. 打字错误
opted    选择




posted on 2014-06-10 17:06  阳光-源泉  阅读(4481)  评论(0编辑  收藏  举报

导航