yum install -y subversion
(server和client均安装subversion)
configure svn:
[root@node01 ~]# mkdir -p /data/svnroot/myproject
[root@node01 ~]# svnadmin create !$
svnadmin create /data/svnroot/myproject
[root@node01 ~]# cd !$/conf
cd /data/svnroot/myproject/conf
[root@node01 conf]# ll
total 12
-rw-r--r-- 1 root root 1080 Dec 29 23:02 authz
-rw-r--r-- 1 root root 309 Dec 29 23:02 passwd
-rw-r--r-- 1 root root 2279 Dec 29 23:02 svnserve.conf
[root@node01 conf]# vim authz
[groups]
admins = user1,user2
[/]
@admins = rw
* = r
[root@node01 conf]# vim passwd
[users]
# harry = harryssecret
# sally = sallyssecret
user1 = nihaoa
user2 = nihaoa
[root@node01 conf]# vim svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /data/svnroot/myproject
[root@node01 conf]# svnserve -d -r /data/svnroot/
[root@node01 conf]# ps -ef |grep svn
root 1303 1 0 23:15 ? 00:00:00 svnserve -d -r /data/svnroot/
root 1305 1250 0 23:15 pts/0 00:00:00 grep svn
[root@node01 conf]# netstat -lnpt |grep svn
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1303/svnserve
client checkout svn:
[root@node02 ~]# mkdir ~/svntest
[root@node02 ~]# cd !$
cd ~/svntest
[root@node02 svntest]# svn checkout svn://10.100.1.121/myproject --username=user1
Authentication realm: <svn://10.100.1.11:3690> /data/svnroot/myproject
Password for 'user1':
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<svn://10.100.1.11:3690> /data/svnroot/myproject
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
Checked out revision 0.
[root@node02 svntest]# ls
myproject
[root@node02 svntest]# ll -at myproject/
total 12
drwxr-xr-x 6 root root 4096 Dec 29 23:22 .svn
drwxr-xr-x 3 root root 4096 Dec 29 23:22 .
drwxr-xr-x 3 root root 4096 Dec 29 23:22 ..
[root@node02 svntest]# cd myproject/
[root@node02 myproject]# cp /etc/fstab .
[root@node02 myproject]# svn add ./fstab //添加到版本控制中心
A fstab
[root@node02 myproject]# svn commit -m "add fstab" //把文件上传到服务器
Adding fstab
Transmitting file data .
Committed revision 1.
[root@node02 myproject]# svn update //更新当前目录的文件
At revision 1.
[root@node02 myproject]# ls
fstab
[root@node01 ~]# mkdir ~/svntest
[root@node01 ~]# cd ~/svntest/
[root@node01 svntest]# svn checkout svn://10.100.1.121/myproject --username=user1
A myproject/fstab
Checked out revision 1.
[root@node01 svntest]# ll -at myproject/
total 16
drwxr-xr-x 6 root root 4096 Dec 29 23:37 .svn
drwxr-xr-x 3 root root 4096 Dec 29 23:37 .
-rw-r--r-- 1 root root 805 Dec 29 23:37 fstab
drwxr-xr-x 3 root root 4096 Dec 29 23:37 ..
[root@node01 myproject]# cp /etc/passwd .
[root@node01 myproject]# svn add ./passwd
A passwd
[root@node01 myproject]# svn commit -m "add passwd"
Adding passwd
Transmitting file data .
Committed revision 2.
[root@node01 myproject]# svn update
At revision 2.
[root@node01 myproject]# ll -t
total 8
-rw-r--r-- 1 root root 890 Dec 29 23:49 passwd
-rw-r--r-- 1 root root 805 Dec 29 23:37 fstab
[root@node01 myproject]# svn delete passwd //在本地删除文件
D passwd
[root@node01 myproject]# svn commit -m "delete passwd" //在服务器上删除
Deleting passwd
Committed revision 3.
[root@node01 myproject]# svn up //更新同步
At revision 3.
[root@node01 myproject]# ll -t
total 4
-rw-r--r-- 1 root root 805 Dec 29 23:37 fstab
[root@node01 myproject]# svn log //查看变更日志
------------------------------------------------------------------------
r3 | user1 | 2018-12-29 23:52:47 +0800 (Sat, 29 Dec 2018) | 1 line
delete passwd
------------------------------------------------------------------------
r2 | user1 | 2018-12-29 23:50:51 +0800 (Sat, 29 Dec 2018) | 1 line
add passwd
------------------------------------------------------------------------
r1 | user1 | 2018-12-29 23:32:00 +0800 (Sat, 29 Dec 2018) | 1 line
add fstab
------------------------------------------------------------------------