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    選擇





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM