Linux SVN服务器部署
1.什么事SVN
1.svn(subversion)跨平台的,开源的版本控制系统。 2.数据放置一个中央资料档案库(repository),会记录每一次修改更新变动 3.不仅可以管理程序源码,还可以管理文件,文本,视频,图片。软件等
2.svn相关站点
http://subversion.tigris.org http://subversion.apache.org svn客户端:http://tortoisesvn.net svn中文站:http://www.iusesvn.com
3.svn版本控制系统工作流程
1.在中央库上创建或从主干复制一个分支 2.从中央库check out下这个分支的代码 3.增加自己的代码文件,修改现存的代码或删除代码文件 4.commit代码,假设有人在刚刚的分支上提交了代码,你就会被提示代码过期,你得先up你的代码后再提交,up代码的时候如果出现冲突,需要解决好冲突再进行提交 5.缺点:依赖于网络 【SVN的备份需要备份代码数据以及所有更改的版本记录】
4.svn服务运行的方式
1.独立服务器访问 svn://svn.xiaoyi.com/sadoc 2.借助apache等http服务 http://svn.xiaoyi.com/sadoc 3.本地直接访问 file:///application/svndata/sadoc
5.svn客户端访问
1.file:// 直接通过本地磁盘或网络磁盘访问版本库 2.http:// 通过WebDAV协议访问支持Subversion的Apache服务器 3.https:// 与http://相似,但是用SSL加密访问 4.svn:// 通过TCP/IP自定义协议访问svnserver服务器 5.svn+ssh:// 通过认证并加密的TCP/IP自定义协议访问svnserver服务器
6.SVN档案数据库格式
svn存储版本有2种方式:BDB(一种事务安全型表类型)1.2以前版本
FSFS(一种不需要数据库的存储系统)
BDB方式在服务器中断,有可能锁住数据,所以还是FSFS方式更安全一点
7.svn优缺点
1.每一次提交都保留一个原始副本,因此SVN数据库容量会暴增 2.SVN服务器断开,就不能提交,还原,对比,网络依赖高 3.不适合非常多人员开发的项目
SVN优点: 1.管理方便,逻辑清晰明确 2.易于管理,集中式svn服务器更能保证数据安全性 3.代码一致性非常高 4.适合开发人员不多的项目开发 5.普及度高,适用非常广
========================================================================================
1.查看是否安装svn,yum更新svn
[root@svnserver ~]# rpm -qa | grep subversion subversion-1.6.11-9.el6_4.x86_64 [root@svnserver ~]# yum update subversion [root@svnserver ~]# rpm -qa subversion subversion-1.6.11-15.el6_7.x86_64
2.建立svn数据目录,用户配置文件及启动svn服务器
[root@svnserver ~]# mkdir /data/svn/data -p [root@svnserver ~]# mkdir /data/svn/conf -p [root@svnserver ~]# svnserve -d -r /data/svn/data/ --pid-file=/data/svn/svn.pid --log-file=/data/svn/svn.log
3.查看svn进程
[root@svnserver svn]# ps -ef | grep svn root 1508 1 0 17:44 ? 00:00:00 svnserve -d -r /data/svn/data/ --pid-file=/data/svn/svn.pid --log-file=/data/svn/svn.log root 1540 1403 0 18:29 pts/0 00:00:00 grep svn [root@svnserver svn]# lsof -i :3690 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME svnserve 1508 root 3u IPv4 15275 0t0 TCP *:svn (LISTEN)
4.创建svn数据根目录,并在根目录生成很多文件
[root@svnserver svn]# svnadmin create /data/svn/data/ [root@svnserver svn]# ll data/ total 24 drwxr-xr-x. 2 root root 4096 Feb 21 18:38 conf drwxr-sr-x. 6 root root 4096 Feb 21 18:38 db -r--r--r--. 1 root root 2 Feb 21 18:38 format drwxr-xr-x. 2 root root 4096 Feb 21 18:38 hooks drwxr-xr-x. 2 root root 4096 Feb 21 18:38 locks -rw-r--r--. 1 root root 229 Feb 21 18:38 README.txt
5.编辑svn配置文件
[root@svnserver conf]# cd /data/svn/data/conf/ [root@svnserver conf]# ll total 12 -rw-r--r--. 1 root root 1080 Feb 21 18:38 authz -rw-r--r--. 1 root root 309 Feb 21 18:38 passwd -rw-r--r--. 1 root root 2279 Feb 21 18:38 svnserve.conf [root@svnserver conf]# cp svnserve.conf svnserve.conf.bak [root@svnserver conf]# vim svnserve.conf ... 12 anon-access = none # 取消注释,改为noe 13 auth-access = write # 取消注释 ... 20 password-db = /data/svn/conf/passwd # 统一用户名、密码 ... 27 authz-db = /data/svn/conf/authz # 统一认证权限文件
6.修改了svnserve.conf文件需要重启svn服务器
[root@svnserver conf]# kill -USR1 `cat /data/svn/svn.pid` [root@svnserver conf]# svnserve -d -r /data/svn/data/ --pid-file=/data/svn/svn.pid --log-file=/data/svn/svn.log
7.复制用户,权限文件到统一目录下及修改文件为700
[root@svnserver conf]# cp authz passwd /data/svn/conf/ [root@svnserver conf]# cd /data/svn/conf/ [root@svnserver conf]# ll total 8 -rw-r--r--. 1 root root 1080 Feb 21 18:48 authz -rw-r--r--. 1 root root 309 Feb 21 18:48 passwd [root@svnserver conf]# chmod 700 * [root@svnserver conf]# ll total 8 -rwx------. 1 root root 1080 Feb 21 18:48 authz -rwx------. 1 root root 309 Feb 21 18:48 passwd
8.建立用户及密码
[root@svnserver conf]# 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 xiaoyi = 123456 xiaoming = 123
9.配置用户权限
[root@svnserver conf]# vim authz [groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r svngroup = xiao,xiaoming # 配置组权限 [/] # svn根目录 xiaoyi = rw # 用户读写权限 xiaoming = r # 用户读权限 @svngroup = r # 组读权限

浙公网安备 33010602011771号