Subversion 版本控制服务配置

Subversion 简称SVN,是一款用来帮助管理软件开发版本库或者是公司文档库的版本控制软件

SVN服务器可以通过网络访问,从而使客户可以在不同主机间进行操作

SVN三种访问方式:svnserve , svnserve+ssh ,Apache间接访问

SVN服务器配置

安装软件

yum -y install subversion

svnadmin 工具是SVN软件提供的版本库管理工具,可以用来创建库,备份库,修订版本等,具体命令及用法可以 svnadmin help

1,创建服务器版本库,(本次配置创建web_project版本库)

mkdir /var/svn

svnadmin create /var/svn/web_project

2.使用svn命令将项目代码/software 导入至空的/var/svn/web_project版本库中

svn import /software/ file:///var/svn/web_project/ -m "software version

[root@master ~]# svn list file:///var/svn/web_project/
clusterlib-3.0.12.1-73.el6.x86_64.rpm
corosynclib-1.4.7-2.el6.x86_64.rpm
haproxy/
keepalived-1.2.13-5.el6_6.x86_64.rpm
lm_sensors-libs-3.1.1-17.el6.x86_64.rpm
luci-0.26.0-70.el6.centos.x86_64.rpm
modcluster-0.16.2-31.el6.x86_64.rpm
net-snmp-libs-5.5-54.el6.x86_64.rpm
openssl-1.0.1e-42.el6.x86_64.rpm
psml1
ricci-0.16.2-81.el6.x86_64.rpm

2 .认证与授权

客户端访问服务器时,服务器会根据每个版本库目录下的svnserve.conf文件中定义的认证与授权策略来控制访问权限

查看web_project 版本库的所有文件

[root@master ~]# tree /var/svn/web_project/
/var/svn/web_project/
├── conf
│   ├── authz
│   ├── passwd
│   ├── svnserve.conf
│   └── web_project
│       ├── clusterlib-3.0.12.1-73.el6.x86_64.rpm
│       ├── corosynclib-1.4.7-2.el6.x86_64.rpm
│       ├── haproxy
│       │   ├── haproxy-1.5.4-2.el6.x86_64.rpm
│       │   └── repodata
│       │       ├── 15008740007b88838ebdaa70a4937fa976fe29faab0de248fb83ba2471bbb0c0-primary.sqlite.bz2
│       │       ├── 76282d8b78e6f67f44a46a6afccfff7c7a167c0af2bb467206e1bfb06f31e582-primary.xml.gz
│       │       ├── b961f6c2b9912139e4fe6f2b7342df61df8a241ff596aac36e1d37d636e3a53c-other.sqlite.bz2
│       │       ├── e142297c0bd8b384f53e8941b3626e24a055a1fcacc4cfdda0da6de7bca3a266-filelists.sqlite.bz2
│       │       ├── e702b706c2b14ff9e5d5041c4d67a769e81a2180f792c213df1ba7e277b60537-filelists.xml.gz
│       │       ├── f91b9e815a39c8265b1f4881e44f060600bcb4b3d3ac4b498f542807b4ba9987-other.xml.gz
│       │       └── repomd.xml
│       ├── keepalived-1.2.13-5.el6_6.x86_64.rpm
│       ├── lm_sensors-libs-3.1.1-17.el6.x86_64.rpm
│       ├── luci-0.26.0-70.el6.centos.x86_64.rpm
│       ├── modcluster-0.16.2-31.el6.x86_64.rpm
│       ├── net-snmp-libs-5.5-54.el6.x86_64.rpm
│       ├── openssl-1.0.1e-42.el6.x86_64.rpm
│       ├── psml1
│       └── ricci-0.16.2-81.el6.x86_64.rpm
├── db
│   ├── current
│   ├── format
│   ├── fsfs.conf
│   ├── fs-type
│   ├── min-unpacked-rev
│   ├── rep-cache.db
│   ├── revprops
│   │   └── 0
│   │       ├── 0
│   │       └── 1
│   ├── revs
│   │   └── 0
│   │       ├── 0
│   │       └── 1
│   ├── transactions
│   ├── txn-current
│   ├── txn-current-lock
│   ├── txn-protorevs
│   ├── uuid
│   └── write-lock
├── format
├── hooks
│   ├── post-commit.tmpl
│   ├── post-lock.tmpl
│   ├── post-revprop-change.tmpl
│   ├── post-unlock.tmpl
│   ├── pre-commit.tmpl
│   ├── pre-lock.tmpl
│   ├── pre-revprop-change.tmpl
│   ├── pre-unlock.tmpl
│   └── start-commit.tmpl
├── locks
│   ├── db.lock
│   └── db-logs.lock
└── README.txt

可看到有conf目录下有svnserve.conf文件,还有passwd,authz ,passwd是存放可以访问SVN服务器账户密码信息的文件,authz是用来指定基于路径的访问控制文件名

[root@master ~]# cat /var/svn/web_project/conf/svnserve.conf

[general]

anon-access = none    #:匿名账户访问权限,可以使none,read,write,此处为none
auth-access = write     #:经过认证的账户权限,此处为write

password-db = passwd

authz-db = authz

realm = My First Repository #:版本库域

[root@master ~]# cat /var/svn/web_project/conf/passwd

[users]
harry = harryssecret
sally = sallyssecret

[root@master ~]# cat /var/svn/web_project/conf/authz

[groups]
harry_and_sally_vicente = harry,sally,vicente
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

[/]
@harry_and_sally_vicente = rw
* = r

注意红色部分,版本库根路径设置的权限,可以设置为需要控制的路径,此处/代表的是web_project版本库


3,启动svnserve 服务

svnserve  -d (-d 是指以守护进程方式运行)

[root@master ~]# lsof -i:3690 (默认监听端口号为3690)
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 4098 root    3u  IPv4  26976      0t0  TCP *:svn (LISTEN)


4, 客户端访问

svn命令行工具提供发布,copy,delete,import等很多用法,具体可以svn help 来查询具体用法

在另一台Linux主机上下载SVN 服务器上/web_project版本库至本地/web_project

注意红色字体部分,由于路径不对,导致无法找到SVN,通过添加绝对路径可下载

[root@puppetmaster ~]# svn co svn://192.168.1.111/web_project/ /web_project/ 
svn: No repository found in 'svn://192.168.1.111/web_project'

[root@puppetmaster ~]# svn co svn://192.168.1.111//var/svn/web_project/ /web_project/
A    /web_project/keepalived-1.2.13-5.el6_6.x86_64.rpm
A    /web_project/ricci-0.16.2-81.el6.x86_64.rpm
A    /web_project/net-snmp-libs-5.5-54.el6.x86_64.rpm
A    /web_project/modcluster-0.16.2-31.el6.x86_64.rpm
A    /web_project/openssl-1.0.1e-42.el6.x86_64.rpm
A    /web_project/corosynclib-1.4.7-2.el6.x86_64.rpm
A    /web_project/haproxy
A    /web_project/haproxy/repodata
A    /web_project/haproxy/repodata/e142297c0bd8b384f53e8941b3626e24a055a1fcacc4cfdda0da6de7bca3a266-filelists.sqlite.bz2
A    /web_project/haproxy/repodata/repomd.xml
A    /web_project/haproxy/repodata/b961f6c2b9912139e4fe6f2b7342df61df8a241ff596aac36e1d37d636e3a53c-other.sqlite.bz2
A    /web_project/haproxy/repodata/e702b706c2b14ff9e5d5041c4d67a769e81a2180f792c213df1ba7e277b60537-filelists.xml.gz
A    /web_project/haproxy/repodata/f91b9e815a39c8265b1f4881e44f060600bcb4b3d3ac4b498f542807b4ba9987-other.xml.gz
A    /web_project/haproxy/repodata/15008740007b88838ebdaa70a4937fa976fe29faab0de248fb83ba2471bbb0c0-primary.sqlite.bz2
A    /web_project/haproxy/repodata/76282d8b78e6f67f44a46a6afccfff7c7a167c0af2bb467206e1bfb06f31e582-primary.xml.gz
A    /web_project/haproxy/haproxy-1.5.4-2.el6.x86_64.rpm
A    /web_project/luci-0.26.0-70.el6.centos.x86_64.rpm
A    /web_project/clusterlib-3.0.12.1-73.el6.x86_64.rpm
A    /web_project/psml1
A    /web_project/lm_sensors-libs-3.1.1-17.el6.x86_64.rpm
Checked out revision 1.

另一种解决办法是使用svnserve -d -r /var/svn/ ,为版本库指定一个虚拟路径,

[root@master ~]# svnserve -d -r /var/svn/
[root@master ~]# lsof -i:3690
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 6816 root    3u  IPv4  55799      0t0  TCP *:svn (LISTEN)

[root@puppetmaster ~]# svn co svn://192.168.1.111/web_project/ /web_project1
A    /web_project1/keepalived-1.2.13-5.el6_6.x86_64.rpm
A    /web_project1/ricci-0.16.2-81.el6.x86_64.rpm
A    /web_project1/net-snmp-libs-5.5-54.el6.x86_64.rpm
A    /web_project1/modcluster-0.16.2-31.el6.x86_64.rpm
A    /web_project1/openssl-1.0.1e-42.el6.x86_64.rpm
A    /web_project1/corosynclib-1.4.7-2.el6.x86_64.rpm
A    /web_project1/haproxy
A    /web_project1/haproxy/repodata
A    /web_project1/haproxy/repodata/e142297c0bd8b384f53e8941b3626e24a055a1fcacc4cfdda0da6de7bca3a266-filelists.sqlite.bz2
A    /web_project1/haproxy/repodata/repomd.xml
A    /web_project1/haproxy/repodata/b961f6c2b9912139e4fe6f2b7342df61df8a241ff596aac36e1d37d636e3a53c-other.sqlite.bz2
A    /web_project1/haproxy/repodata/e702b706c2b14ff9e5d5041c4d67a769e81a2180f792c213df1ba7e277b60537-filelists.xml.gz
A    /web_project1/haproxy/repodata/f91b9e815a39c8265b1f4881e44f060600bcb4b3d3ac4b498f542807b4ba9987-other.xml.gz
A    /web_project1/haproxy/repodata/15008740007b88838ebdaa70a4937fa976fe29faab0de248fb83ba2471bbb0c0-primary.sqlite.bz2
A    /web_project1/haproxy/repodata/76282d8b78e6f67f44a46a6afccfff7c7a167c0af2bb467206e1bfb06f31e582-primary.xml.gz
A    /web_project1/haproxy/haproxy-1.5.4-2.el6.x86_64.rpm
A    /web_project1/luci-0.26.0-70.el6.centos.x86_64.rpm
A    /web_project1/clusterlib-3.0.12.1-73.el6.x86_64.rpm
A    /web_project1/psml1
A    /web_project1/lm_sensors-libs-3.1.1-17.el6.x86_64.rpm
Checked out revision 1.

客户端使用svnserve+ssh访问SVN服务器

[root@puppetmaster ~]# svn co svn+ssh://192.168.1.111/var/svn/web_project/ /web_project3
[email protected]'s password:
[email protected]'s password:
A    /web_project3/keepalived-1.2.13-5.el6_6.x86_64.rpm
A    /web_project3/ricci-0.16.2-81.el6.x86_64.rpm
A    /web_project3/net-snmp-libs-5.5-54.el6.x86_64.rpm
A    /web_project3/modcluster-0.16.2-31.el6.x86_64.rpm
A    /web_project3/openssl-1.0.1e-42.el6.x86_64.rpm
A    /web_project3/corosynclib-1.4.7-2.el6.x86_64.rpm
A    /web_project3/haproxy
A    /web_project3/haproxy/repodata
A    /web_project3/haproxy/repodata/e142297c0bd8b384f53e8941b3626e24a055a1fcacc4cfdda0da6de7bca3a266-filelists.sqlite.bz2
A    /web_project3/haproxy/repodata/repomd.xml
A    /web_project3/haproxy/repodata/b961f6c2b9912139e4fe6f2b7342df61df8a241ff596aac36e1d37d636e3a53c-other.sqlite.bz2
A    /web_project3/haproxy/repodata/e702b706c2b14ff9e5d5041c4d67a769e81a2180f792c213df1ba7e277b60537-filelists.xml.gz
A    /web_project3/haproxy/repodata/f91b9e815a39c8265b1f4881e44f060600bcb4b3d3ac4b498f542807b4ba9987-other.xml.gz
A    /web_project3/haproxy/repodata/15008740007b88838ebdaa70a4937fa976fe29faab0de248fb83ba2471bbb0c0-primary.sqlite.bz2
A    /web_project3/haproxy/repodata/76282d8b78e6f67f44a46a6afccfff7c7a167c0af2bb467206e1bfb06f31e582-primary.xml.gz
A    /web_project3/haproxy/haproxy-1.5.4-2.el6.x86_64.rpm
A    /web_project3/luci-0.26.0-70.el6.centos.x86_64.rpm
A    /web_project3/clusterlib-3.0.12.1-73.el6.x86_64.rpm
A    /web_project3/psml1
A    /web_project3/lm_sensors-libs-3.1.1-17.el6.x86_64.rpm
Checked out revision 1.

在windows端使用图形工具连接库版本服务器

下载安装TortoiseSVN软件,在桌面单击右键选择svn checkout

Subversion 版本控制服务配置_第1张图片


注意路径,由于之前我在SVN服务器上执行了svnserve -d -r /var/svn/,而authz的路径为(/),所以此处路径应为

svn://192.168.1.111/web_project

点击OK即可将SVN 服务器上的web_project版本库下载至本地桌面web_project


使用Apache+svn访问SVN服务器(本例访问/var/www/svn/web_project,cp -r /var/svn /var/www/ )

安装httpd 及相关模块

yum -y install httpd

yum -y install mod_dav_svn

[root@master ~]# vim /etc/httpd/conf.d/subversion.conf


DAV svn
SVNParentPath /var/www/svn/

#
#   # Limit write permission to list of valid users.
#  
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/www/svn/.pass
Require valid-user

#  


"/etc/httpd/conf.d/subversion.conf" 55L, 1395C written                  

红色字体部分为需要修改注意的地方,尤其是路径

上面提前将/web_preject版本库拷贝至/var/www/下

chown -R apache.apache /var/www/svn 修改权限

htpasswd -c /var/www/svn/.pass jerry    创建账户,对应在配置文件AuthUserFile /var/www/svn/.pass

service httpd start

客户端访问,使用浏览器访问

Subversion 版本控制服务配置_第2张图片


                              











你可能感兴趣的:(Linux高级服务)