SVN是Subversion的簡稱,是一個開放源代碼的版本控制系統,相較於RCS、CVS,它採用了分支管理系統,它的設計目標就是取代CVS。互聯網上不少版本控制服務已從CVS遷移到Subversion。說得簡單一點SVN就是用於多我的共同開發同一個項目,共用資源的目的。apache
[root@centos7 ~]# [root@centos7 ~]# yum install -y subversion
出現以下問題:
[root@centos7 ~]# [root@centos7 ~]# yum install -y subversion 已加載插件:fastestmirror, langpacks /var/run/yum.pid 已被鎖定,PID 爲 4137 的另外一個程序正在運行。 Another app is currently holding the yum lock; waiting for it to exit... 另外一個應用程序是:PackageKit 內存: 99 M RSS (502 MB VSZ) 已啓動: Fri Mar 22 18:57:37 2019 - 00:52以前 狀態 :睡眠中,進程ID:4137 Another app is currently holding the yum lock; waiting for it to exit... 另外一個應用程序是:PackageKit 內存: 99 M RSS (502 MB VSZ) 已啓動: Fri Mar 22 18:57:37 2019 - 00:54以前 狀態 :睡眠中,進程ID:4137
緣由:
這是由於yum處於鎖定狀態中。能夠經過強制關掉yum進程來解決這個問題,直接在終端運行 rm -f /var/run/yum.pid 將該文件刪除,而後再次運行yum便可。
解決方法:
[root@centos7 ~]# sudo rm -rf /var/run/yum.pid [root@centos7 ~]#
新建一個目錄用於存儲SVN目錄、通常存放在 /var/local/vim
[root@centos7 ~]# cd /usr/local/ [root@centos7 local] [root@centos7 local]# mkdir svn
[root@centos7 local]# cd svn/ [root@centos7 svn]# svnadmin create test
而後查看當前目錄下、會發現多了一個 test 文件夾、而後進入到 test 下。centos
[root@centos7 svn]# [root@centos7 svn]# ll # 總用量 4 # drwxr-xr-x. 6 root root 4096 3月 22 21:13 test [root@centos7 svn]# cd test/ [root@centos7 test]# ll # 總用量 24 # drwxr-xr-x. 2 root root 4096 3月 22 21:13 conf # drwxr-sr-x. 6 root root 4096 3月 22 21:13 db # -r--r--r--. 1 root root 2 3月 22 21:13 format # drwxr-xr-x. 2 root root 4096 3月 22 21:13 hooks # drwxr-xr-x. 2 root root 4096 3月 22 21:13 locks # -rw-r--r--. 1 root root 229 3月 22 21:13 README.txt [root@centos7 test]#
如下關於目錄的說明:服務器
conf目錄: 是這個倉庫配置文件(倉庫用戶訪問帳戶,權限) format目錄:是一個文本文件,裏邊只放了一個整數,表示當前文件庫配置的版本號 hooks目錄: 放置hook腳步文件的目錄 locks目錄: 用來放置subversion的db鎖文件和db_logs鎖文件的目錄,用來追蹤存取文件庫的客戶端
[root@centos7 test]# [root@centos7 test]# cd conf/ [root@centos7 conf]# ll # 總用量 12 # -rw-r--r--. 1 root root 1080 3月 22 21:13 authz # -rw-r--r--. 1 root root 309 3月 22 21:13 passwd # -rw-r--r--. 1 root root 3090 3月 22 21:13 svnserve.conf
一、修改SVN服務的配置文件svnserver.conf
[root@centos7 conf]# vim svnserve.conf # 修改四處 # 分別爲 1九、20、2七、34行
具體以下: 1 ### This file controls the configuration of the svnserve daemon, if you 2 ### use it to allow access to this repository. (If you only allow 3 ### access through http: and/or file: URLs, then this file is 4 ### irrelevant.) 5 6 ### Visit http://subversion.apache.org/ for more information. 7 8 [general] 9 ### The anon-access and auth-access options control access to the 10 ### repository for unauthenticated (a.k.a. anonymous) users and 11 ### authenticated users, respectively. 12 ### Valid values are "write", "read", and "none". 13 ### Setting the value to "none" prohibits both reading and writing; 14 ### "read" allows read-only access, and "write" allows complete 15 ### read/write access to the repository. 16 ### The sample settings below are the defaults and specify that anonymous 17 ### users have read-only access to the repository, while authenticated 18 ### users have read and write access to the repository. 19 anon-access = read ##注意前邊不要有空格,要頂齊 20 auth-access = write ##注意前邊不要有空格,要頂齊 21 ### The password-db option controls the location of the password 22 ### database file. Unless you specify a path starting with a /, 23 ### the file's location is relative to the directory containing 24 ### this configuration file. 25 ### If SASL is enabled (see below), this file will NOT be used. 26 ### Uncomment the line below to use the default password file. 27 password-db = passwd ##注意前邊不要有空格,要頂齊 28 ### The authz-db option controls the location of the authorization 29 ### rules for path-based access control. Unless you specify a path 30 ### starting with a /, the file's location is relative to the the 31 ### directory containing this file. If you don't specify an 32 ### authz-db, no path-based access control is done. 33 ### Uncomment the line below to use the default authorization file. 34 authz-db = authz ##注意前邊不要有空格,要頂齊 35 ### This option specifies the authentication realm of the repository. 36 ### If two repositories have the same authentication realm, they should 37 ### have the same password database, and vice versa. The default realm 38 ### is repository's uuid. 39 # realm = My First Repository 40 ### The force-username-case option causes svnserve to case-normalize 41 ### usernames before comparing them against the authorization rules in the 42 ### authz-db file configured above. Valid values are "upper" (to upper- 43 ### case the usernames), "lower" (to lowercase the usernames), and 44 ### "none" (to compare usernames as-is without case conversion, which 45 ### is the default behavior). 46 # force-username-case = none
二、配置訪問用戶及密碼
[root@centos7 conf]# [root@centos7 conf]# vim passwd # 按內容中已知的規則添加用戶密碼
具體以下: 1 ### This file is an example password file for svnserve. 2 ### Its format is similar to that of svnserve.conf. As shown in the 3 ### example below it contains one section labelled [users]. 4 ### The name and password for each user follow, one account per line. 5 6 [users] 7 # harry = harryssecret 8 # sally = sallyssecret 9 root = root 10 test1 = test 11 test2 = test
三、配置新用戶的受權文件
[root@centos7 conf]# [root@centos7 conf]# vim authz
具體以下: 1 ### This file is an example authorization file for svnserve. 2 ### Its format is identical to that of mod_authz_svn authorization 3 ### files. 4 ### As shown below each section defines authorizations for the path and 5 ### (optional) repository specified by the section name. 6 ### The authorizations follow. An authorization line can refer to: 7 ### - a single user, 8 ### - a group of users defined in a special [groups] section, 9 ### - an alias defined in a special [aliases] section, 10 ### - all authenticated users, using the '$authenticated' token, 11 ### - only anonymous users, using the '$anonymous' token, 12 ### - anyone, using the '*' wildcard. 13 ### 14 ### A match can be inverted by prefixing the rule with '~'. Rules can 15 ### grant read ('r') access, read-write ('rw') access, or no access 16 ### (''). 17 18 [aliases] 19 # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average 20 21 [groups] 22 # harry_and_sally = harry,sally 23 # harry_sally_and_joe = harry,sally,&joe 24 25 # [/foo/bar] 26 # harry = rw 27 # &joe = r 28 # * = 29 30 # [repository:/baz/fuz] 31 # @harry_and_sally = rw 32 # * = r 33 34 admin = root,test1 35 user = test2 36 [/svn/test] 37 @admin = rw 38 @user = r 39 * =
備註: admin = root,test1 # 建立admin組,組成員爲:root,test1 user = test2 # 建立用戶組,用戶成員:test2 [/svn/test] # 賦予根權限,爲了便於管理和權限的控制,能夠把權限細化到版本庫中相應的目錄 @admin = rw # admin組有讀寫的權限 @user = r # user組只有讀的權限 *= # 表示除了上面設置的權限用戶組之外,其餘全部用戶都設置空權限,空權限表示禁止訪問本目錄,這很重要必定要加上。
[root@centos7 conf]# svnserve -d -r /usr/local/svn/ [root@centos7 conf]# # 沒有出錯邊是成功、若是出現如下錯誤、則需先關閉kill進程、而後從新啓動。 # 具體操做以下:
[root@centos7 conf]# svnserve -d -r /usr/local/svn/ # svnserve: E000098: 不能綁定服務器套接字: 地址已在使用 [root@centos7 conf]# [root@centos7 conf]# ps aux | grep svn # root 8682 0.0 0.0 199280 1028 ? Ss 09:29 0:00 svnserve -d -r /usr/local/svn/ # root 24448 0.0 0.0 112656 968 pts/1 S+ 09:31 0:00 grep --color=auto svn [root@centos7 conf]# [root@centos7 conf]# kill 8682 [root@centos7 conf]# ps aux | grep svn # root 24507 0.0 0.0 112656 968 pts/1 S+ 09:32 0:00 grep --color=auto svn [root@centos7 conf]# [root@centos7 conf]# svnserve -d -r /usr/local/svn/ [root@centos7 conf]#