centos6.5中的svn部署过程

本文详细介绍了如何在 CentOS 6.5 系统中部署 Subversion (SVN) 版本控制系统,包括安装 SVN、创建版本库、配置权限及用户、设置开机启动、开启端口等步骤,并讲解了如何通过客户端连接 SVN 服务器及实现自动部署。

centod6.5下的svn部署过程

安装:

yum -y install subversion  ,可用rpm -ql subversion查看svn的安装目录,默认在/usr/bin下

创建版本库:

mkdir /data/tools/svn/repos1
svnadmin create /data/tools/svn/repos1

执行上面的命令后,自动建立多个文件, 分别是conf, db, format, hooks, locks, README.txt。

进入conf修改配置文件:

vim passwd 进去后将以下信息添加在末尾
[users]
# harry = harryssecret
# sally = sallyssecret
用户名 = 密码      #用户名和密码,这里可以添加多个用户名和密码

vim authz  添加在末尾
...
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
users = 用户1,用户2                #用户组 = 用户 (这里用户可以有多个)
[/]
@users = rw

vim svnserve.conf 关闭注释以及修改变量
...
anon-access = none #匿名用户不可操作
auth-access = write #授权用户可写
password-db = /data/tools/svn/repos1/conf/passwd #使用哪个文件作为账号文件
authz-db = /data/tools/svn/repos1/conf/authz #使用哪个文件作为权限文件
realm = /data/tools/svn/repos1 # 认证空间名,版本库所在目录,和之前的一样

开启和关闭服务

1.编辑服务进程文件
vim /etc/init.d/svnserve 在最前面增加一行
OPTIONS=" -r /data/tools/svn"
2.启动svnserve服务
svnserve -d -r /data/tools/repos1   #开启     或者使用service svnserve restart
killall svnserve     #关闭
ps aux |greo svnserve  #查看是否在运行
3.设置svn开机自启动
chkconfig svnserve on

打开端口

这一步很重要,如果你都配置完了却发现连接不上,那一定是端口没有打开,默认端口是3690.

 iptables -I INPUT -i eth0 -p tcp --dport 3690 -j ACCEPT  #开放端口
  service iptables save #保存 iptables 规则(如不能保存请使用其他方法保存

测试

1.svn co svn://127.0.0.1/repos1 svntest --username toomee --password toomee1234
 ----------------------------------------------------------------------- 
ATTENTION!  Your password for authentication realm:
   <svn://127.0.0.1:3690> My First Repository
can only be stored to disk unencrypted!  You are advised to configure 
your system so that Subversion can store passwords encrypted, if 
possible.  See the documentation for details.
You can avoid future appearances of this warning by setting the value 
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in 
'/root/.subversion/servers'. 
----------------------------------------------------------------------- 
Store password unencrypted (yes/no)? yes 
A    svntest/Desktop.ini 
Checked out revision 1. 

2.touch svntest/test 
3.svn update svntest/ 
4.svn add svntest/test 
A         svntest/test 
5.svn ci -m "test" svntest/test 
Adding         svntest/test 
Transmitting file data . 
Committed revision 2. 

客户端连接

Windows

使用TortoiseSVN,url填写svn://你的服务器ip,账号密码填刚刚设置的。

Mac

使用CornerStone,url填写svn://你的服务器ip,账号密码填刚刚设置的。

自动部署

粗略的可以理解svn客户端将修改信息以一定格式传输到服务端保存在固定格式的文件里面,svn up的时候再将这些文件里的信息生效到代码目录里。我们有时候需要在服务端实时的看到代码更新信息,这就用到了post-commit钩子:

在客户端commit的时候触发服务端到/data/tools/svn/repos1执行svn up来更新文件,

同时减少日志文件的大小,防止服务端当机后的日志损失。

cd /data/tools/svn/repos1/hooks  #你的版本仓库目录
cp post-commit.tmpl post-commit

编辑post-commit:注释掉最后一行,添加

vim post-commit

export LANG=en_US.UTF-8
/usr/bin/svn update --force /data/tools/svn/repos1

另外,post-commit脚本必须有x权限。

chmod +x post-commit

到这里hook钩子就配置好了,重启svn进程,即可看到客户端commit后文件同步更新。

转载于:https://blog.51cto.com/13922718/2161853

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值