Linux服務器SVN配置及管理項目遷移
前言:本文章根據有些公司對於項目管理,所以有些公司對於SVN使用有些挑剔,有些會使用GIT或者Github等等,這不我們公司使用的就是SVN,技術老大說要把Windows系統上的SVN項目遷移至公司Linux服務器上,順便在Linux上面搭建SVN及配置SVN,小編在這裏有一萬句mp,第一次操作遷移至Linux服務器上,沒辦法搞唄,然後去網上查了一下,大部分的教程都是一樣,沒啥新意,但是有很多講的教程信息不全,看到這裏就想罵人,給人留這麽多坑。經過我一天的研究,完美成功,下面就請大家來欣賞。
安裝 SVN:
yum install subversion
創建svn倉庫路徑:
# cd /opt/svn/ # svnadmin create/opt/svn/test
drwxr-xr-x 2 root root 4096 Mar 30 20:05 conf drwxr-sr-x 6 root root 4096 Mar 30 20:05 db -r--r--r-- 1 root root 2 Mar 30 20:05 format drwxr-xr-x 2 root root 4096 Mar 30 20:05 hooks drwxr-xr-x 2 root root 4096 Mar 30 20:05 locks -rw-r--r-- 1 root root 229 Mar 30 20:05 README.txt
配置文件講解:
上面的文件中 , 文件夾 conf 是用來存放配置文件的 :
authz 是權限控制文件
passwd 是帳號密碼文件
svnserve.conf 是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] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe #用戶組 dev = dev #項目用戶名 bbt = yukai.li,test # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r #給予用戶加入讀寫權限 [/] @dev = rw [/] @bbt = rw
配置 passwd:
[root@bbt-dev conf]# more 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 test = 123456 yukai.li = 666666
修改配置 svnserve.conf,這裏按照我配置修改就可以了:
#把這個幾個前面#去掉就可以了,最後一個直接填寫你創建的項目目錄名 anon-access = one auth-access = write password-db = passwd authz-db = authz realm = test
[root@bbt-dev conf]# more 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 = one 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 = test [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@bbt-dev conf]#
啟動服務:
# svnserve -d -r /opt/svn/test
查看SVN進程:
# ps -ef|grep svn root 12538 1 0 14:40 ? 00:00:00 svnserve -d -r /opt/svn/test #或者直接用這個命令查看; [root@bbt-dev bbt]# ps -aux root 6122 0.0 0.0 152416 864 ? Ss Sep21 0:00 svnserve -d -r /opt/svn/test #這樣表示已啟動成功,再啟動的時候你只需要啟動你創建的beibeitou這個項目目錄就好;
客戶端連接:
使用 TortoiseSVN , 輸入地址svn://192.168.0.204:3690/即可 , 再輸入用戶名和密碼就能訪問了 (註:那個端口加不加都行了,我個人測試了一下可以不用添加,另外解釋一下為什麽地址開頭是svn,是因為 這個表示Linux服務器上定義的一個區別,用來區分http表示Windows上的svn,小編個人是這麽認為的,如大家想知道,可以去研究一下)
停止重啟SVN:
# killall svnserve //停止 # svnserve -d -r /opt/svn/test // 啟動
導入項目源代碼:
# svn import [源路徑][目標版本庫路徑] -m [日誌信息]//例如: svn import /home/work/ file:///svn/project1/trunk/ -m "Initial import" #不過我這裏沒有這樣操作使用,可以看看繼續操作,因為感覺那樣來回操作很麻煩;
接下來是我個人導入項目源碼的方式,我是直接使用SVN客戶端方式導入,我認為那樣比較安全,速度還是比較安全,你只需要把個人項目從SVN拉到本地電腦上,之後連接用客戶端連接我們創建好的svn服務器,不多說了請大家看圖:
1、首先桌面隨便創建一個文件夾,選中右鍵然後選中版本庫瀏覽器,輸入地址
2、確定後,就會彈出讓你輸入用戶名和密碼,這裏小編認為最好不要保存密碼
3、確定密碼後,就會彈出下面這個頁面;
4、我們剛搞好的SVN服務器裏面,這個裏面是空的,所以你只需要選擇左邊的那個地址然後右鍵,直接新創建一個文件名,之後選中新創建的文件夾,然後右鍵選中加入文件夾,然後找到你拉下來的項目,然後確定就OK了,導入完後,個人可以直接checkOut一下就知道了
linux搭建配置SVN,eclipse連接時遇到的問題
到這裏,小編還沒講完,因為搞好這些,我以為就完事了,因為我公司統一使用的eclipse開發,所以eclipse插件還是個問題,我在直接新建立資源位置的時候發現直接會返回這個錯誤Eclipse中的Subversion版本控制工具出現Malformed network data的問題,然後小編當場就蒙了,第一次遇到這個問題,我便上網查了很久後,都不可以,最後小編發現了一個牛掰的博客,我試了一下果然OK了,下面我給大家分享出來。
Eclipse安裝SVN插件
使用SVN進行項目的版本管理是非常流行的操作,這篇博客將描述Eclipse安裝SVN的方法(Linux安裝服務器端的請參考CentOS安裝SVN)。
從菜單欄依次打開 Help - Install New Software,然後在彈出的窗口點擊Add,在Location裏面輸入如下地址,獲取最新的SVN插件,如果需要其他版本,可以在 https://github.com/subclipse/subclipse/wiki 查找。
Subclipse - https://dl.bintray.com/subclipse/releases/subclipse/latest/
Name可以隨便寫,可以寫Subversion,然後點擊確定,等到獲取了所有的插件列表後,勾選這些插件,點擊下一步,然後接受協議,一步一步安裝就好了。
安裝完成後,需要打開SVN視圖,在菜單欄依次點擊 Window - Show View - Other,然後選擇 SVN - SVN資源庫,在資源庫空白處右鍵單擊,選擇新建 - 資源庫位置。然後依次填寫信息即可。
到此完結Linux建立SVN配置連接,全部OK了,真的廢了小編N個腦細胞
如有疑問不懂得,可以添加我的QQ:2919529566
Linux服務器SVN配置及管理項目遷移