1. 程式人生 > >linux install SVN (CentOS_6.6)

linux install SVN (CentOS_6.6)

centos6.6 svn

一、環境準備

system:CentOS_6.6

IP:192.168.30.129

安裝yum:

rpm -Uhv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

二、安裝SVN

root@pts/0 # yum -y install subversion
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
epel/metalink                                                                                                     | 5.0 kB     00:00     
 * base: mirrors.btte.net
 * epel: mirrors.opencas.cn
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
base                                                                                                              | 3.7 kB     00:00     
base/primary_db                                                                                                   | 4.6 MB     00:06     
epel                                                                                                              | 4.3 kB     00:00     
epel/primary_db                                                                                                   | 5.7 MB     00:44     
extras                                                                                                            | 2.9 kB     00:00     
extras/primary_db                                                                                                 |  33 kB     00:00     
updates                                                                                                           | 3.4 kB     00:00     
updates/primary_db                                                                                                | 3.3 MB     00:04     
Resolving Dependencies
--> Running transaction check
---> Package subversion.x86_64 0:1.6.11-15.el6_7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================
 Package                          Arch                         Version                               Repository                     Size
=========================================================================================================================================
Installing:
 subversion                       x86_64                       1.6.11-15.el6_7                       updates                       2.3 M

Transaction Summary
=========================================================================================================================================
Install       1 Package(s)

Total download size: 2.3 M
Installed size: 12 M
Downloading Packages:
subversion-1.6.11-15.el6_7.x86_64.rpm                                                                             | 2.3 MB     00:02     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>
 Package: centos-release-6-6.el6.centos.12.2.x86_64 (@anaconda-CentOS-201410241409.x86_64/6.6)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : subversion-1.6.11-15.el6_7.x86_64                                                                                     1/1 
  Verifying  : subversion-1.6.11-15.el6_7.x86_64                                                                                     1/1 

Installed:
  subversion.x86_64 0:1.6.11-15.el6_7                                                                                                    

Complete!

輸入rpm -ql subversion查看安裝位置

root@pts/0 # rpm -ql subversion
/etc/bash_completion.d
/etc/bash_completion.d/subversion
/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
....

查看svn 幫助

root@pts/0 # 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.

Available subcommands:
   add
   blame (praise, annotate, ann)
   cat
   changelist (cl)
   checkout (co)
   cleanup
   commit (ci)
   copy (cp)
   delete (del, remove, rm)
   diff (di)
   export
   help (?, h)
   import
   info
   list (ls)
   lock
   log
   merge
   mergeinfo
   mkdir
   move (mv, rename, ren)
   propdel (pdel, pd)
   propedit (pedit, pe)
   propget (pget, pg)
   proplist (plist, pl)
   propset (pset, ps)
   resolve
   resolved
   revert
   status (stat, st)
   switch (sw)
   unlock
   update (up)

Subversion is a tool for version control.
For additional information, see http://subversion.tigris.org/

root@pts/0 # svnadmin --help
general usage: svnadmin SUBCOMMAND REPOS_PATH  [ARGS & OPTIONS ...]
Type ‘svnadmin help <subcommand>‘ for help on a specific subcommand.
Type ‘svnadmin --version‘ to see the program version and FS modules.

Available subcommands:
   crashtest
   create
   deltify
   dump
   help (?, h)
   hotcopy
   list-dblogs
   list-unused-dblogs
   load
   lslocks
   lstxns
   pack
   recover
   rmlocks
   rmtxns
   setlog
   setrevprop
   setuuid
   upgrade
   verify

三、創建svn版本庫目錄

root@pts/0 # mkdir -p /usr/local/svn/test

四、創建版本庫

root@pts/0 # svnadmin create /usr/local/svn/test
Test_1 [~] 2016-01-10 15:03:28
root@pts/0 # ll /usr/local/svn/test
total 24
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 conf
drwxr-sr-x. 6 root root 4096 Jan 10 15:03 db
-r--r--r--. 1 root root    2 Jan 10 15:03 format
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 hooks
drwxr-xr-x. 2 root root 4096 Jan 10 15:03 locks
-rw-r--r--. 1 root root  229 Jan 10 15:03 README.txt

五、進入conf目錄(該svn版本庫配置文件)

root@pts/0 # cd conf/
Test_1 [/usr/local/svn/test/conf] 2016-01-10 15:12:38
root@pts/0 # ll
total 12
-rw-r--r--. 1 root root 1080 Jan 10 15:03 authz
-rw-r--r--. 1 root root  309 Jan 10 15:03 passwd
-rw-r--r--. 1 root root 2279 Jan 10 15:03 svnserve.conf

authz文件是權限控制文件

passwd是帳號密碼文件

svnserve.conf SVN服務配置文件

六、設置帳號密碼

root@pts/0 # 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
test = test123
other = test123

在[users]塊中添加用戶和密碼,格式:帳號=密碼,如test = test123

七、設置權限

root@pts/0 # vim authz
....
[/]
test = rw
other = r

意思是版本庫的根目錄test對其有讀寫權限,other只有讀權限。

八、修改svnserve.conf文件

root@pts/0 # vim svnserve.conf
....
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /usr/local/svn/test

打開下面的幾個註釋:

anon-access = none #匿名用戶不可訪問

auth-access = write #授權用戶可寫

password-db = passwd #使用哪個文件作為賬號文件

authz-db = authz #使用哪個文件作為權限文件

realm = /var/svn/svnrepos # 認證空間名,版本庫所在目錄

九、啟動svn版本庫

root@pts/0 # svnserve -d -r /usr/local/svn
root@pts/0 # ps -ef |grep svn
root      3082     1  0 15:31 ?        00:00:00 svnserve -d -r /usr/local/svn

十、測試連接

root@pts/0 # mkdir -p /opt/test
Test_1 [/opt] 2016-01-10 15:37:01
root@pts/0 # cd /opt/test/
Test_1 [/opt/test] 2016-01-10 15:37:08
root@pts/0 # svn co svn://127.0.0.1/test /opt/test/
Authentication realm: <svn://127.0.0.1:3690> /usr/local/svn/test
Password for ‘root‘: 
Authentication realm: <svn://127.0.0.1:3690> /usr/local/svn/test
Username: test
Password for ‘test‘: 

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

   <svn://127.0.0.1:3690> /usr/local/svn/test

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)? yes
Checked out revision 0.

root@pts/0 # svn info
Path: .
URL: svn://127.0.0.1/test
Repository Root: svn://127.0.0.1/test
Repository UUID: ec5619f6-c7b2-4018-a560-616f7d6462cc
Revision: 0
Node Kind: directory
Schedule: normal
Last Changed Rev: 0
Last Changed Date: 2016-01-10 15:45:56 +0000 (Sun, 10 Jan 2016)

linux svn 更多命令可以查詢幫助信息!

十一、測試上傳文件,查看版本

root@pts/0 # touch file
Test_1 [/opt/test] 2016-01-10 16:15:57
root@pts/0 # echo "svn is test" > file 
Test_1 [/opt/test] 2016-01-10 16:16:14
root@pts/0 # svn add file 
A         file
Test_1 [/opt/test] 2016-01-10 16:16:21
root@pts/0 # svn commit file -m ‘test‘
Adding         file
Transmitting file data .
Committed revision 1.
Test_1 [/opt/test] 2016-01-10 16:16:56
root@pts/0 # ll
total 4
-rw-r--r--. 1 root root 12 Jan 10 16:16 file
Test_1 [/opt/test] 2016-01-10 16:17:08
root@pts/0 # svn info file 
Path: file
Name: file
URL: svn://127.0.0.1/test/file
Repository Root: svn://127.0.0.1/test
Repository UUID: ec5619f6-c7b2-4018-a560-616f7d6462cc
Revision: 1
Node Kind: file
Schedule: normal
Last Changed Author: test
Last Changed Rev: 1
Last Changed Date: 2016-01-10 16:16:42 +0000 (Sun, 10 Jan 2016)
Text Last Updated: 2016-01-10 16:16:14 +0000 (Sun, 10 Jan 2016)
Checksum: 304b5e95556c9066f5aa1268ede6df6a

顯示版本已更新為 1

十二、在Windows上測試

首先安裝TortoiseSVN

找地方新建svn目錄,右擊 - 檢出

技術分享圖片

添加svn版本庫URL 與 檢出 目錄

技術分享圖片

輸入賬戶密碼 user: test passwd: test123

技術分享圖片

可以看到剛才服務器提交的file文件已經更新

技術分享圖片

Windows更多操作這裏不多說,看幫助吧!

linux install SVN (CentOS_6.6)