본문 바로가기
Server | Network

SVN 설치 및 저장소 설정,세팅

by 두루물 2011. 11. 16.
작업 결과 과정 정리 백업임))

SVN 설치

root@fgs:/etc# sudo apt-get install subversion libapache2-svn
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libneon27-gnutls libsvn1
Suggested packages:
  db4.8-util subversion-tools
The following NEW packages will be installed:
  libapache2-svn libneon27-gnutls libsvn1 subversion
0 upgraded, 4 newly installed, 0 to remove and 109 not upgraded.
Need to get 1,273 kB of archives.
After this operation, 4,104 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main libneon27-gnutls amd64 0.29.5-3 [76.9 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libsvn1 amd64 1.6.12dfsg-4ubuntu2.1 [815 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ natty-updates/universe libapache2-svn amd64 1.6.12dfsg-4ubuntu2.1 [83.3 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main subversion amd64 1.6.12dfsg-4ubuntu2.1 [298 kB]
Fetched 1,273 kB in 4s (310 kB/s)   
Selecting previously deselected package libneon27-gnutls.
(Reading database ... 52520 files and directories currently installed.)
Unpacking libneon27-gnutls (from .../libneon27-gnutls_0.29.5-3_amd64.deb) ...
Selecting previously deselected package libsvn1.
Unpacking libsvn1 (from .../libsvn1_1.6.12dfsg-4ubuntu2.1_amd64.deb) ...
Selecting previously deselected package libapache2-svn.
Unpacking libapache2-svn (from .../libapache2-svn_1.6.12dfsg-4ubuntu2.1_amd64.deb) ...
Selecting previously deselected package subversion.
Unpacking subversion (from .../subversion_1.6.12dfsg-4ubuntu2.1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libneon27-gnutls (0.29.5-3) ...
Setting up libsvn1 (1.6.12dfsg-4ubuntu2.1) ...
Setting up libapache2-svn (1.6.12dfsg-4ubuntu2.1) ...
Considering dependency dav for dav_svn:
Enabling module dav.
Enabling module dav_svn.
Run '/etc/init.d/apache2 restart' to activate new configuration!
Setting up subversion (1.6.12dfsg-4ubuntu2.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@fgs:/etc# service apache2 restart
 * Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
   ...done.

서브버전용 그룹생성 및 사용자 계정추가

root@fgs:/etc# groupadd svn
root@fgs:/etc# cat /etc/group |grep svn
svn:x:1002:
 
root@fgs:/etc# usermod -a -G svn krkim
root@fgs:/etc# usermod -a -G svn skshin
root@fgs:/etc# cat /etc/group |grep svn
svn:x:1002:krkim,skshin
 
저장소 생성
/home/project 하에
root@fgs:/etc# mkdir /home/project
root@fgs:/etc# cd /home/project

#파일단위 대신 버클리 데이타베이스 형식시
root@fgs:/home/project# svnadmin create --fs-type bdb cdn-a

#일반 파일단위 (--fs-type fsfs)
root@fgs:/home/project# svnadmin create /home/project/cdn-a 

root@fgs:/home/project# ls -l
total 4
drwxr-xr-x 6 root root 4096 2011-11-16 14:57 cdn-a
root@fgs:/home/project# chgrp -R svn cdn-a
root@fgs:/home/project# ls -l
total 4
drwxr-xr-x 6 root svn 4096 2011-11-16 14:57 cdn-a
root@fgs:/home/project# chmod -R g+w cdn-a
root@fgs:/home/project# ls -l
total 4
drwxrwxr-x 6 root svn 4096 2011-11-16 14:57 cdn-a
 
저장소 세부 환경 설정

root@fgs:/home/project# cd cdn-a
root@fgs:/home/project/cdn-a# ls
conf  db  format  hooks  locks  README.txt
root@fgs:/home/project/cdn-a# cd conf
root@fgs:/home/project/cdn-a/conf# ls
authz  passwd  svnserve.conf

root@fgs:/home/project/cdn-a/conf# vi svnserve.conf

#익명사용자 권한
 anon-access = none

#계정사용자 권한
 auth-access = write

#프로젝트 명
 realm = My First Game Repository

auth-access = write
password-db = passwd
authz-db = authz
realm = My Repository

root@fgs:/home/project/cdn-a/conf# vi authz
 
authz 파일편집
앞 공백주의,클라이언트 접속오류남
svnserve.conf 에서 authz_db 주석 풀기.

[groups]
 core = superuser1,superuser2
 others = user1,user2,user3
# 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

#모든 하위 폴더에 대해 권한부여
 [/]
 core = rw
 others = r 

*폴더별 권한
# [/foo/bar]
# harry = rw
# &joe = r
# * =

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


[/]
@core = rw
#@others = r

[/trunk/bin]
@others = r

[/trunk/doc]
@others = rw

[/trunk/works]
@others = rw

만일 특정사용자 그룹을 제외하고 src 폴더를 (소스폴더) 안보이게 하려면,
(@ = 그룹을 의미)

[/]
@core = rw
@others = r

[/trunk/src]
@core = rw
* = 
하면, 저장소엔 접속되나 src 폴더만 auth 실패로 내용을 볼수 없게 된다.
* = none 은 svn 서버오류가 난다.(구버전에 해당) 공백으로 비워줘야 한다.
http://kldp.org/node/77909 참조하면 됨.

 

비.번설정

root@fgs:/home/project/cdn-a/conf# vi 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
 krkim = whatmypass??


가동 및 중지

root@fgs:/home/project/cdn-a/conf# svnserve -d -r /home/project/cdn-a
root@fgs:/home/project/cdn-a/conf# killall svnserve

여러 프로젝트 구동 

저장소가 여러개인 경우, 서버 가동시
svnserve -d -r /home/project 까지만 수행한다.
단,각 저장소마다 http://fgs/ 다음에 저장소이름으로 접근

주소
svn checkout svn://fgs/home/project/cdn-a

trunk,branches,tags 폴더 생성

명령라인에서 svn mkdir svn://fgs/home/project/cdn-a/trunk (:q로 빠져나옴)

$ svn mkdir svn://localhost/cdn-a/trunk --username krkim 
$ svn mkdir svn://localhost/cdn-a/branches --username krkim 
$ svn mkdir svn://localhost/cdn-a/tags --username krkim

또는 tortoiseSVN 클라이언트 툴 REPO-BROWSER에서 접속후 Create-Folder 한다.


Add File And Folder

신규 추가할 프로젝트 파일들을 trunk에 추가.




Apache 와 SVN 연동

vi /etc/apache2/mods-enabled/dav_svn.conf (libapache2-svn 를 깔아야함)
 

<Location /svn> #url상에 표시되는 이름
 DAV svn
 SVNPath /home/project/cdn-a  #저장소 이름
 #SVNParentPath /home/project #저장소 총 홈디렉
 AuthType Basic
 AuthName "FG Repository"
 AuthUserFile /etc/apache2/dav_svn.passwd #아래에서 생성
 AuthzSVNAccessFile /home/project/cdn-a/conf/authz #svn내 계정권한
 Require valid-user
</Location>

Apache 접속 계정 비밀번호 설정
 
htpasswd  -cm /etc/apache2/dav_svn.passwd krkim (맨처음 파일 생성시 -c)
htpasswd  /etc/apache2/dav_svn.passwd otheruser(이후 유저 추가)

Repository 소유자 접근 권한 설정

chown -R www-data 저장소 경로 (데비안계열,우분투등에서 Apache가 사용하는 그룹,소유자)
또는  chown -R www.data:www-data 저장소 경로
다른 페도라 계열은 nobody nogroup로..

이전에 만들어서 추가했던 svn 그룹 유지해도 됨(www.data 둘다 안해줘도됨)

ls시 
root@ubuntu:/home/project# ls -l
total 121068
drwxrwxr-x 6 www-data svn       4096 2011-11-16 14:57 cdn-a
-rw-r--r-- 1 root     root 123964813 2011-11-17 15:33 cdn-a.dump
-rw-r--r-- 1 root     root       121 2011-11-17 15:35 readme

이걸 안하면, Could not open the requested SVN filesystem 에러 발생한다.

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<D:error xmlns:D="DAV:" xmlns:m="http://apache.org/dav/xmlns" xmlns:C="svn:">
<C:error/>
<m:human-readable errcode="160029">Could not open the requested SVN filesystem</m:human-readable>
</D:error>

 
아파치 재시작하면 된다.
service apache2 restart

부팅시 자동실행
 

vi /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

svnserve -d -r /home/project/cdn-a
exit 0
 

DB 백업
 

TO BACKUP:
svnadmin dump cdn-a > cdn-a.dump

TO LOAD:
svnadmin create cdn-a
svnadmin load cdn-a < cdn-a.dump

프로젝트 저장소 홈디렉토리의 부모디렉토리 또는 전체경로에서.(위에선 부모디렉토리)


DB 에러시 복구

svnadmin recover 저장소 경로 or
db_recover -c -v -h <path to subversion db dir>

http://stackoverflow.com/questions/119792/subversion-berkeley-db-broken-recovery-failed
 

에러 내용
svn: Berkeley DB error for filesystem '/home/project/cdn-a/db' while opening environment:

svn: DB_RUNRECOVERY: Fatal error, run database recovery
svn: bdb: PANIC: fatal region error detected; run recovery

root@ubuntu:~/aaa# svnadmin recover /home/project/cdn-a
Repository lock acquired.
Please wait; recovering the repository may take some time...

Recovery completed.
The latest repos revision is 100.
 
기타 싸이트

자세한 사항은 아래 참고:

2012.10.10

for AIX Information

http://www.perzl.org/aix/index.php?n=Main.Subversion

http://subversion.apache.org/download/?Preferred=http%3A%2F%2Fmirror.apache-kr.org%2F


'Server | Network' 카테고리의 다른 글

APACHE /VAR/WWW 임시 PERMISSION  (0) 2011.12.05
SSH Port 포트 변경  (0) 2011.11.25
adduser 새유저에 sudo 권한 주기  (0) 2011.11.16
OCKILL Error Log  (0) 2011.10.05
[BackUp] Find Command In UNIX  (0) 2011.10.05