svn
主:106.13.123.85 备:1.15.242.143
主安装
yum install subversion -y
查看是否安装完成
rpm -qa subversion
创建仓库目录
mkdir -p /opt/svn/repositories
svnadmin create /opt/svn/repositories/plat
进入仓库
cd /opt/svn/repositories/plat
修改配置
vim conf/svnserve.conf
anon-access=none
auth-access=write
password-db=passwd
authz-db=authz
realm=/opt/svn/repositories/plat
修改授权
vim conf/authz
[groups]
admin = super,sync
[/]
@admin = rw
修改密码
vim conf/passwd
[users]
super = xxxx
sync=xxxx
启动
svnserve -d -r /opt/svn/repositories/
备份服务器同样的操作
同步操作
cp hooks/pre-revprop-change.tmpl hooks/pre-revprop-change
chmod +x hooks/pre-revprop-change
vim hooks/pre-revprop-change
把末尾的exit 1 改为exit 0
初始化
svnsync init svn://106.13.123.85/plat svn://1.15.242.143/plat --username sync --password xxxx
#svnsync init svn://1.15.242.143/plat svn://106.13.123.85/plat --username sync --password xxxx
测试同步
打开小乌龟:
在106.13.123.85上上传文件,1.15.242.14刷新没有文件
在106.13.123.85服务器上执行语句
在1.15.242.14刷新文件,有文件同步过来
刷新之后
svnsync synchronize --non-interactive svn://1.15.242.143/plat
#svnsync synchronize --non-interactive svn://106.13.123.85/plat
配置文件中同步,不需要手动同步
1)在主服务器svn的hooks目录下 cp hooks/post-commit.tmpl hooks/post-commit
2)vim hooks/post-commit 把其他的所有的都注释掉,然后在末尾添加
svnsync synchronize --non-interactive svn://1.15.242.143/plat
#svnsync synchronize --non-interactive svn://106.13.123.85/plat
3)然后保存退出。
赋予权限
chmod +x hooks/post-commit
到此主从同步搭建完成
其中的目录和账号密码什么的根据自己的情况设置,不一定和我一样
配置同步中发生的错误
[root@VM-16-2-centos app1]# svnsync synchronize --non-interactive svn://106.13.123.85/plat
svnsync: E000022: Destination HEAD (4) is not the last merged revision (97); have you committed to the destination without using svnsync?
手动提交出现错误
[root@VM-16-2-centos app1]# svn propset --revprop -r0 svn:sync-last-merged-rev 4 svn://106.13.123.85/plat
property 'svn:sync-last-merged-rev' set on repository revision 0
[root@VM-16-2-centos app1]# svnsync synchronize --non-interactive svn://106.13.123.85/plat
出现这种错误是是因为106.13.123.85是先初始化的,先初始化是无法执行语句的。
svn propset --revprop -r0 svn:sync-last-merged-rev 1 svn://1.15.242.143/plat
svn简单命令操作
#检索
svn checkout svn://1.15.242.143/plat .
svn checkout svn://106.13.123.85/plat .
svn checkout svn://192.168.170.168/plat .
svn checkout svn://192.168.2.75/plat .
用户名和密码输入
创建新的文件
echo "bbbb" >> b.txt
#第一次没有的文件
[root@localhost plat]# svn add b.txt
#已存在文件,第一次提交
[root@localhost plat]# svn commit -m "b" b.txt
[root@localhost plat]# svn info
[root@localhost plat]# svn up
svn list svn://1.15.242.143/plat
svn配置http
yum -y install httpd
yum -y install mod_dav_svn
vim /etc/httpd/conf.modules.d/10-subversion.conf
<Location /plat>
DAV svn
#SVNParentPath /var/lib/svn
SVNPath /opt/svn/repositories/plat
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /opt/svn/httpdata/plat/conf/passwd
AuthzSVNAccessFile /opt/svn/httpdata/plat/conf/authz
Satisfy all
Require valid-user
#</LimitExcept>
</Location>
创建权限
mkdir -p /opt/svn/httpdata/plat/conf
cp -r /opt/svn/repositories/plat/conf/authz /opt/svn/httpdata/plat/conf/
创建密码
-c只可以使用一次
htpasswd -bc /opt/svn/httpdata/plat/conf/passwd sync sync@123
htpasswd -b /opt/svn/httpdata/plat/conf/passwd sync sync@123
启动httpd
systemctl start httpd
http://106.13.123.85/plat
输入用户名和密码