服務器準備
操作系統:CentOS 7
CPU:4 核
內存:8 GB
- 安裝 svn
[root@svn ~]# yum -y install subversion
- 查看 svn 版本
[root@svn ~]# svnserve --version
- 創建 svn 版本庫
[root@svn ~]# mkdir -p /data/svn/repository # 目錄準備
[root@svn ~]# chmod -R 777 /data/svn/repository # 賦權
[root@svn ~]# svnadmin create /data/svn/repository # svn 倉庫創建
- svn 目錄說明
[root@svn ~]# ll /data/svn/repository/
total 8
drwxr-xr-x. 2 root root 54 Apr 14 23:30 conf # 配置文件目錄
drwxr-sr-x. 6 root root 233 Apr 14 23:30 db # 數據目錄
-r--r--r--. 1 root root 2 Apr 14 23:30 format
drwxr-xr-x. 2 root root 231 Apr 14 23:30 hooks
drwxr-xr-x. 2 root root 41 Apr 14 23:30 locks
-rw-r--r--. 1 root root 229 Apr 14 23:30 README.txt
- 查看配置文件目錄
[root@svn ~]# cd /data/svn/repository/conf/
[root@svn conf]# ll
total 12
-rw-r--r--. 1 root root 1080 Apr 14 23:30 authz
-rw-r--r--. 1 root root 309 Apr 14 23:30 passwd
-rw-r--r--. 1 root root 3090 Apr 14 23:30 svnserve.conf
- 修改配置文件 – 賬戶添加
[root@svn conf]# vim authz
# 1. 創建 administrator 組,並增加用戶
[groups]
administrator = lsr_zds,lsr,zds
# 2. 給與 administrator 組讀寫權限,在文件末尾添加
[/]
@administrator = rw
- 修改配置文件 – 密碼配置
[root@svn conf]# vim passwd
# 配置賬號和密碼,找到 "[users]",在下面添加之前添加的賬號,並配置密碼
lsr_zds = 123456
lsr = 123456
zds = 123456
- 修改配置文件 – svnserver.conf 文件
[root@svn conf]# vim svnserve.conf
# anon-access = read -- 更改前爲 read,放開註釋,並修改
anon-access = none
# auth-access = write -- 放開註釋
auth-access = write
# authz-db = authz -- 放開註釋
authz-db = authz
# realm = My First Repository -- 放開註釋,並修改,目錄爲之前指定
realm = /data/svn/repository
- 啓動 svn 目錄下的資源庫
[root@svn conf]# svnserve -d -r /data/svn # 指定啓動目錄,只到 svn 目錄
- 查看服務是否啓動
[root@svn conf]# ps -ef | grep svn
root 1946 1 0 02:18 ? 00:00:00 svnserve -d -r /data/svn
root 1948 1535 0 02:18 pts/0 00:00:00 grep --color=auto svn
[root@svn conf]# netstat -ntlp | grep 3690
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1946/svnserve
- svn 客戶端連接 – 創建拉取目錄
[root@svn ~]# mkdir /home/dev_dir
- svn 客戶端連接 – 連接 svn server
[root@svn dev_dir]# svn co svn://192.168.157.129/repository --username "zds" --password "123456"
- 查看拉取目錄
[root@svn dev_dir]# ls
repository
[root@svn dev_dir]# cd repository/
[root@svn repository]# ll
- 本地創建目錄 && 提交到 svn server
[root@svn repository]# mkdir {bin,lib,conf,log,operation,install}
[root@svn repository]# svn add ./* # 添加當前目錄更新
[root@svn repository]# svn commit -m 'mkdir dir for project' # 提交到 svn server
- svn 測試 – 刪除本地目錄
[root@svn dev_dir]# ll
total 0
drwxr-xr-x. 3 root root 18 Apr 15 07:15 repository
[root@svn dev_dir]# rm -rf repository
- svn 測試 – 從 svn server
[root@svn dev_dir]# svn checkout svn://192.168.157.129:3690/repository --username "lst" --password "123456"