centos6.5中的svn部署过程

centod6.5下的svn部署过程

安装:

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

创建版本库:

进入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后文件同步更新。

相关文章

文章浏览阅读903次。4.清除缓存目录(/var/cache/yum)下的软件...
文章浏览阅读1.5k次。Python 是一种高级解释性编程语言,已被...
文章浏览阅读2.6k次。打开终端或控制台,以root或具有sudo权...
文章浏览阅读744次,点赞24次,收藏26次。目标:通过AppSrv为...
文章浏览阅读1.1w次,点赞8次,收藏26次。chmod命令来自于英...
文章浏览阅读1.2k次。yum源的URL地址,本例中是文件系统的路...