svn讲解及操作

svn

开放源代码的版本控制系统,相较于RCS、CVS,它采用了分支管理系统,它的设计目标就是取代CVS。互联网上很多版本控制服务已从CVS迁移到Subversion。说得简单一点SVN就是用于多个人共同开发同一个项目,共用资源的目的

Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节

  • 优点:安全性高,速度快
SVN图示理解

在这里插入图片描述

架构图示

在这里插入图片描述
Subversion支持Linux和Windows,更多是安装在Linux下。

svn服务器有2种运行方式:独立服务器和借助apache运行。两种方式各有利弊,用户可以自行选择。svn存储版本数据也有2种方式:BDB一种事务安全型表类型和FSFS一种不需要数据库的存储系统。

因为BDB方式在服务器中断时,有可能锁住数据,所以还是FSFS方式更安全一点。

安装配置SVN服务

[root@localhost ~]# yum install subversion -y
[root@localhost ~]# rpm -qa subversion
subversion-1.10.2-2.module+el8.0.0+3900+919b6753.x86_64
#建立SVN版本库数据存储根目录(svndata)及用户,密码权限目录(svnpasswd)
[root@localhost ~]# mkdir -p /home/svndata
[root@localhost ~]# mkdir -p /home/svnpasswd
#启动SVN服务指定访问的SVN根目录
[root@localhost ~]# svnserve -d -r /home/svndata/ 
#查看进程和端口
[root@localhost ~]# ps -ef |grep svn
root       49980       1  0 00:19 ?        00:00:00 svnserve -d -r /home/svndata/
root       51912   16189  0 00:20 pts/3    00:00:00 grep --color=auto svn
[root@localhost ~]#  lsof -i :3690
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
svnserve 49980 root    3u  IPv4 307692      0t0  TCP *:svn (LISTEN)
[root@localhost ~]# netstat -lntup|grep svn
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      49980/svnserve      
#建立项目版本库 
[root@localhost ~]# svnadmin create /home/svndata/test
[root@localhost ~]# tree /home/svndata/test/
/home/svndata/test/
├── conf
│   ├── authz
│   ├── hooks-env.tmpl
│   ├── passwd
│   └── svnserve.conf
├── db
│   ├── current
│   ├── format
│   ├── fsfs.conf
│   ├── fs-type
│   ├── min-unpacked-rev
│   ├── revprops
│   │   └── 0
│   │       └── 0
│   ├── revs
│   │   └── 0
│   │       └── 0
│   ├── transactions
│   ├── txn-current
│   ├── txn-current-lock
│   ├── txn-protorevs
│   ├── uuid
│   └── write-lock
├── format
├── hooks
│   ├── post-commit.tmpl
│   ├── post-lock.tmpl
│   ├── post-revprop-change.tmpl
│   ├── post-unlock.tmpl
│   ├── pre-commit.tmpl
│   ├── pre-lock.tmpl
│   ├── pre-revprop-change.tmpl
│   ├── pre-unlock.tmpl
│   └── start-commit.tmpl
├── locks
│   ├── db.lock
│   └── db-logs.lock
└── README.txt

10 directories, 28 files
[root@localhost ~]#  cd /root/svndata/test/conf/
-bash: cd: /root/svndata/test/conf/: 没有那个文件或目录
[root@localhost ~]# cd /home/svndata/test/
conf/  db/    hooks/ locks/ 
[root@localhost ~]# cd /home/svndata/test/conf/
[root@localhost conf]# ll
总用量 20
-rw-r--r--. 1 root root 1080 1012 00:22 authz
-rw-r--r--. 1 root root  885 1012 00:22 hooks-env.tmpl
-rw-r--r--. 1 root root  309 1012 00:22 passwd
-rw-r--r--. 1 root root 4375 1012 00:22 svnserve.conf
[root@localhost conf]# cp svnserve.conf svnserve.conf,ori
[root@localhost conf]# vim svnserve.conf

### users have read and write access to the repository.
anon-access = read      #去掉#键
auth-access = write       #去掉#键

### Uncomment the line below to use the default password file.
password-db = /home//svnpasswd/passwd     #去掉#键,修改位置

### Uncomment the line below to use the default authorization file.
authz-db =  /home/svnpasswd/authz      #去掉#键,修改位置

#把密码文件模板拷贝到相关目录
[root@localhost conf]# cp passwd authz /home/svnpasswd/
[root@localhost conf]# ll /home/svnpasswd/
总用量 8
-rw-r--r--. 1 root root 1080 1012 00:28 authz
-rw-r--r--. 1 root root  309 1012 00:28 passwd

#因为SVN默认都是明文密码,为了安全起见加上权限
[root@localhost conf]# cd /home/svnpasswd/
[root@localhost svnpasswd]# chmod 700 *
[root@localhost svnpasswd]# ll
总用量 8
-rwx------. 1 root root 1080 1012 00:28 authz
-rwx------. 1 root root  309 1012 00:28 passwd

#创建SVN用户及设置权限
[root@localhost svnpasswd]# cat passwd 
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
cyh = 123456
test = 123..
itcast = 123456

[root@localhost svnpasswd]# cat authz 
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[test:/]
cyh = rw
itcast = rw
test = rw

[root@localhost svnpasswd]# svnserve -d -r /home/svndata/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值