Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1493897
  • 博文数量: 230
  • 博客积分: 474
  • 博客等级: 下士
  • 技术积分: 1955
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 18:40
文章分类

全部博文(230)

文章存档

2020年(3)

2019年(3)

2018年(12)

2017年(13)

2016年(11)

2015年(55)

2014年(74)

2013年(39)

2012年(2)

2011年(18)

我的朋友

分类: 系统运维

2016-01-22 10:23:28

SVN作为新一代代码版本管理工具,有很多优点,管理方便,逻辑明确,安全性高,代码一致性高。SVN数据存储有两种方式,BDB(事务安全表类型)和FSFS(一种不需要数据库的存储系统),为了避免在服务器连接中断时锁住数据,FSFS是一种更安全也更多人使用的方式。SVN的运行方式也有两种,一种是独立服务器,另一种是借助apache服务,各有利弊,下面就介绍一下这两种方式各自的部署步骤。

一.作为独立服务器运行,

1.安装subversion

#yum  install  subversion

#mkdir    -p    /opt/svn  //创建svn目录

#chmod  R 777  /opt/svn  //修改目录权限为777

#svnadmin  create  /opt/svn/repos  //创建一个svn版本仓库repos (repos 名字自己起)

#cd      /opt/svn/repos/conf    //进入repos版本仓库下的配置文件目录

修改此目录下的三个配置文件

1)  svnserve.conf    //配置版本库信息和用户文件和用户密码文件的路径、版本库路径

#vim  svnserve.conf

修改一下几处:

#anon-access = read

#auth-access = write

#password-db = passwd

将这三行前面的 #号去掉,每行的最左边不能有空格,改成如下:

anon-access =  none    //read改为none

auth-access = write

password-db = passwd

realm = repos            //改成自己的版本库

如图:

保存退出

2) 修改authz 文件,创建svn组和组用户的权限

#vim    authz

[group]

repos = test,test1      //创建一个repos的组,并添加2个用户test,test1

[/]      //修改根目录下的权限

@repos = rw        //repos组用户的权限为 读写

test = rw              //test 用户的权限为读写

* = r                    //其他用户的权限为只读

如图:

3)passwd 文件  创建或修改用户密码

#vim passwd

test = test    //用户名test的密码为test

test1 =  test1    //用户名为test2的密码为test2

保存退出




1.yum安装svn

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. yum install -y subversion    

等待一会儿,显示下边的内容。

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. Dependency Installed:  

  2.  gnutls.i686 0:2.8.5-10.el6_4.2               libproxy.i686 0:0.3.0-4.el6_3                    

  3.  libproxy-bin.i686 0:0.3.0-4.el6_3            libproxy-python.i686 0:0.3.0-4.el6_3            

  4.  neon.i686 0:0.29.3-3.el6_4                   pakchois.i686 0:0.4-3.2.el6                      

  5.  perl-URI.noarch 0:1.40-2.el6                  

  6. Complete!  

2.验证是否安装完成

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. svnserve --version  

这是我的显示内容。


[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. svnserve,版本 1.6.11 (r934486)  

  2.   编译于 Apr 11 2013,17:28:04  

  3. 版权所有 (C) 2000-2009 CollabNet。  

  4. Subversion 是开放源代码软件,请参阅 站点。  

  5. 此产品包含由 CollabNet() 开发的软件。  

  6. 下列版本库后端(FS) 模块可用:  

  7. * fs_base : 模块只能操作BDB版本库。  

  8. * fs_fs : 模块与文本文件(FSFS)版本库一起工作。  

  9. Cyrus SASL 认证可用。  


3.创建svn版本库

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. mkdir /var/svn #我这里把版本库放在了var目录下的svn文件夹,方便管理  

  2. svnadmin create /var/svn/repo0 #我这里将svn作为所有版本库的目录,并创建了一个名为repo0的版本库

4.配置当前的版本库

创建版本库后,在当前版本库目录中会生成下面的文件,其中我们关心的是配置文件。

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. [root@localhost svn]# ls  

  2. repo0  

  3. [root@localhost svn]# cd repo0  

  4. [root@localhost repo0]# ls  

  5. conf  db  format  hooks  locks  README.txt  

  6. [root@localhost repo0]# pwd  

  7. /var/svn/repo0  

  8. [root@localhost repo0]# cd conf  

  9. [root@localhost conf]# ls -a  

  10. .  ..  authz  passwd  svnserve.conf  



说明

           (1)svnserve.conf:  svn服务综合配置文件。

           (2)passwd: 用户名口令文件。

           (3)authz: 权限配置文件。

4.1 修改passwd文件

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  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. [users]  

  6. # harry = harryssecret  

  7. # sally = sallyssecret  

  8. repouser0 = user0passwd  

  9. rock=rockpasswd  


其中对应的是 用户名=密码 ,其中等号两边的空格不是必须的。


4.2修改authz文件

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. [aliases]  

  2. # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average  

  3. #这里实现了别名的定义  

  4. [groups]  

  5. # harry_and_sally = harry,sally  

  6. # harry_sally_and_joe = harry,sally,&joe  

  7. team0=erpouser0 #将上面创建的分成两个组  

  8. team1=rock  

  9. # [/foo/bar]  

  10. # harry = rw  

  11. # &joe = r #上面的别名定义在这里实现 &在这里理解为指针就很容易了  

  12. # * =  

  13. # [repository:/baz/fuz]  

  14. # @harry_and_sally = rw  

  15. # * = r  

  16. [repo0:/]  

  17. @team0=r  

  18. @team1=rw  

  19. # 第一个小组只有读取的权限,第二个小组有读写的权限  

  20. # 单个版本库的权限配置在这个文件中实现  



4.3 修改svnserve.conf

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. vim svnserve.conf  

[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. [general]  

  2. ### These options control access to the repository for unauthenticated  

  3. ### and authenticated users.  Valid values are "write", "read",  

  4. ### and "none".  The sample settings below are the defaults.  

  5. anon-access = none #没有登录的用户不能访问  

  6. auth-access = write #登录的用户可以写入  

  7. ### The password-db option controls the location of the password  

  8. ### database file.  Unless you specify a path starting with a /,  

  9. ### the file's location is relative to the directory containing  

  10. ### this configuration file.  

  11. ### If SASL is enabled (see below), this file will NOT be used.  

  12. ### Uncomment the line below to use the default password file.  

  13. password-db = passwd #密码文件为当前目录下的passwd  

  14. ### The authz-db option controls the location of the authorization  

  15. ### rules for path-based access control.  Unless you specify a path  

  16. ### starting with a /, the file's location is relative to the the  

  17. ### directory containing this file.  If you don't specify an  

  18. ### authz-db, no path-based access control is done.  

  19. ### Uncomment the line below to use the default authorization file.  

  20. authz-db = authz #验证文件为当前目录下的authz  


5 停止和启动svn


5.1启动svn


[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. svnserve -d -r /var/svn/  


5.2关闭svn


[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. ps -aux |grep svn  

  2. kill -9 进程id  


6 导入工程



[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. $ mkdir MyProject    

  2. $ mkdir MyProject/trunk    

  3. $ mkdir MyProject/branches    

  4. $ mkdir MyProject/tags    

  5. svn import MyProject svn://192.168.1.109/repo0/MyProject -m "first import project"  



7导出工程


[plain]view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. svn co svn://192.168.1.109/repo0/MyProject  


阅读(1631) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~