Linux系统组建SVN服务器
Linux系统SVN服务
1、SVN服务介绍
SVN是一款非常优秀的版本管理工具,与CVS管理工具一样,SVN 是一种跨平台的开源的版本控制系统,它会备份并记录每个文件每一次的修改更新变动
官方网站:http://subversion.tigris.org
http://subvsion.apache.org
SVN客户端:http://tortoisesvn.net
SVN中文网站:http://www.iusesvn.com
SVN版本控制系统的工作流程:
1:在中央库上创建或主干复制一个分支
2:从中央库check out下这个分支的代码
3:然后进行修改,提交更新代码
2、SVN的安装
系统环境
[root@centos6 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@centos6 ~]# uname -r
2.6.32-431.el6.x86_64
安装SVN服务
[root@centos6 ~]# rpm -qa subversion
[root@centos6 ~]# yum install subversion
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
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 base 2.3 M
Transaction Summary
=============================================
Install 1 Package(s)
Total download size: 2.3 M
Installed size: 12 M
Is this ok [y/N]: y
Downloading Packages:
subversion-1.6.11-15.el6_7.x86_64.rpm | 2.3 MB 00:00
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!
启动SVN
[root@centos6 ~]# svnserve -d -r /application/svndata/
[root@centos6 ~]# ps -ef|grep svn
root 2077 1 0 15:25 ? 00:00:00 svnserve -d -r /application/svndata/
root 2079 2022 0 15:25 pts/0 00:00:00 grep svn
检查端口
[root@centos6 ~]# lsof -i :3690
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
svnserve 2077 root 3u IPv4 15031 0t0 TCP *:svn (LISTEN)
3、配置SVN服务器
创建版本库
[root@centos6 ~]# svnadmin create /application/svndata/docs
[root@centos6 ~]# ll /application/svndata/docs/
total 24
drwxr-xr-x. 2 root root 4096 Nov 26 15:36 conf
drwxr-sr-x. 6 root root 4096 Nov 26 15:36 db
-r--r--r--. 1 root root 2 Nov 26 15:36 format
drwxr-xr-x. 2 root root 4096 Nov 26 15:36 hooks
drwxr-xr-x. 2 root root 4096 Nov 26 15:36 locks
-rw-r--r--. 1 root root 229 Nov 26 15:36 README.txt
配置SVN的配置文件及权限
[root@centos6 ~]# cd /application/svndata/docs/conf/
[root@centos6 conf]# ll
total 12
-rw-r--r--. 1 root root 1080 Nov 26 15:36 authz
-rw-r--r--. 1 root root 309 Nov 26 15:36 passwd
-rw-r--r--. 1 root root 2279 Nov 26 15:36 svnserve.conf
[root@centos6 conf]# cp svnserve.conf svnserve.conf.bak
生产环境备份很重要!!!!!!
[root@centos6 conf]# diff svnserve.conf svnserve.conf.bak
12,13c12,13
< anon-access = none
< auth-access = write
---
> # anon-access = read
> # auth-access = write
20c20
< password-db = /application/svnpasswd/passwd
---
> # password-db = passwd
27c27
< authz-db = /application/svnpasswd/authz
---
> # authz-db = authz
比较两个文件就知道修改了哪些地方
配置密码文件与认证权限文件
[root@centos6 conf]# cp authz passwd /application/svnpasswd/
[root@centos6 conf]# cd /application/svnpasswd/
[root@centos6 svnpasswd]# ll
total 8
-rw-r--r--. 1 root root 1080 Nov 26 15:46 authz
-rw-r--r--. 1 root root 309 Nov 26 15:46 passwd
[root@centos6 svnpasswd]# chmod 700 ./*
[root@centos6 svnpasswd]# ll
total 8
-rwx------. 1 root root 1080 Nov 26 15:46 authz
-rwx------. 1 root root 309 Nov 26 15:46 passwd
配置用户名与密码
[root@centos6 svnpasswd]# vi 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
test1 = 123456
配置用户权限
[root@centos6 svnpasswd]# vi authz
[docs:/] 主目录权限
test = rw
test1 = rw
[docs:/file] 一级目录权限
test = r
test1 = rw
注:权限里配置的用户一定要在用户配置文件里存在的
配置完成后,无须重启,立即生效
4、SVN客户端操作
WIN平台操作
下载SVN客户端软件 进行安装
本地客户端新建一个文件svndata
右键文件夹——SVN check out
url处输入svn://192.168.1.235/docs点击OK
新建一个文件,然后右键SVNDATA文件——svn commit
LINUX 客户端操作
将文件下载到本地
[root@centos6 ~]# svn co svn://192.168.1.235/docs/ --username=test --password=123456
A docs/svn123.txt
A docs/test.txt
Checked out revision 3.
[root@centos6 ~]# ll
total 48
-rw-------. 1 root root 1229 Nov 18 11:13 anaconda-ks.cfg
drwxr-xr-x. 3 root root 4096 Nov 26 16:50 docs
-rw-r--r--. 1 root root 21712 Nov 18 11:13 install.log
-rw-r--r--. 1 root root 5890 Nov 18 11:12 install.log.syslog
-rw-r--r--. 1 root root 60 Nov 25 22:44 txt
[root@centos6 ~]# ll docs/
total 8
-rw-r--r--. 1 root root 50 Nov 26 16:50 svn123.txt
-rw-r--r--. 1 root root 24 Nov 26 16:50 test.txt
更新与列出文件列表
[root@centos6 ~]# svn update svn://192.168.1.235/docs/ --username=test --password=123456
Skipped 'svn://192.168.1.235/docs'
[root@centos6 ~]# svn list svn://192.168.1.235/docs/ --username=test --password=123456
svn123.txt
test.txt
安装与配置过程结束
长按关注公众号——友侃有笑