背景
IP:172.16.14.6(主) 172.16.17.2(从)17.2 安装svn
安装配置SVN服务
[root@iz2 ~]# yum install subversion -y
[root@iz2 hooks]# cat /usr/lib/systemd/system/svnserve.service
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/svnserve
ExecStart=/usr/bin/svnserve -d --config-file=/data/svn/svnserver.conf --pid-file=/run/svnserve/svnserve.pid $OPTIONS
[Install]
WantedBy=multi-user.target
[root@iz2 ~]# systemctl daemon-reload
[root@iz2 ~]# systemctl start svnserve.service
Job for svnserve.service failed because the control process exited with error code. See "systemctl status svnserve.service" and "journalctl -xe" for details.
[root@iz2z ~]# systemctl status svnserve.service
● svnserve.service - Subversion protocol daemon
Loaded: loaded (/usr/lib/systemd/system/svnserve.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-05-08 14:15:58 CST; 10s ago
Process: 29000 ExecStart=/usr/bin/svnserve -d --config-file=/data/svn/svnserver.conf --pid-file=/run/svnserve/svnserve.pid $OPTIONS (code=exited, status=1/FAILURE)
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz systemd[1]: Starting Subversion protocol daemon...
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz svnserve[29000]: svnserve: Root path '/var/svn' does not exist or is not a directory. //没有svn的家目录
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz systemd[1]: svnserve.service: control process exited, code=exited status=1
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz systemd[1]: Failed to start Subversion protocol daemon.
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz systemd[1]: Unit svnserve.service entered failed state.
May 08 14:15:58 iz2ze8ip0m748wp4lnu6piz systemd[1]: svnserve.service failed.
[root@iz2z ~]# systemctl restart svnserve.service
Job for svnserve.service failed because the control process exited with error code. See "systemctl status svnserve.service" and "journalctl -xe" for details.
[root@iz2z ~]# svnadmin create /data/svn/develop/
[root@iz2z ~]# systemctl restart svnserve.service
Job for svnserve.service failed because the control process exited with error code. See "systemctl status svnserve.service" and "journalctl -xe" for details.
[root@iz2z hooks]# cat /etc/sysconfig/svnserve
# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="-r /data/svn" ##修改svn root path
[root@iz2 ~]# systemctl restart svnserve.service
配置 svn 主从
需要在主服务机器配置 hook
- 记得把post-commit +x 执行权限(chmod +x post-commit )
[root@iz2z hooks]# pwd
/data/svn/develop/hooks
[root@iz2zecs69qbuuy757q805kz hooks]# ls
post-commit post-commit.tmpl post-lock.tmpl post-revprop-change.tmpl post-unlock.tmpl pre-commit.tmpl pre-lock.tmpl pre-revprop-change pre-revprop-change.tmpl pre-unlock.tmpl start-commit.tmpl
[root@iz2z hooks]# cat post-commit
#!/bin/bash
REPOS="$1"
REV="$2"
mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf
svnsync sync svn://172.16.17.2/develop
重启服务后 当出现 如下报错
- svnsync init <svn://172.16.17.2/develop> <svn://172.16.14.6/develop>
- svn: E165006: Repository has not been enabled to accept revision propchanges;
- ask the administrator to create a pre-revprop-change hook
[root@iz2z hooks]# ls
post-commit post-commit.tmpl post-lock.tmpl post-revprop-change.tmpl post-unlock.tmpl pre-commit.tmpl pre-lock.tmpl pre-revprop-change pre-revprop-change.tmpl pre-unlock.tmpl start-commit.tmpl
[root@iz2zecs69qbuuy757q805kz hooks]# cat pre-revprop-change
#! /bin/sh
exit 0
[root@iz2z ~]# chmod +x pre-revprop-change
[root@iz2z ~]# systemctl restart svnserve.service
在14.6(主) : svnsync sync svn://172.16.17.2/develop
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。