예전부터 혼자 서버를 구축하고 싶었는데 이제 라즈베리파이가 있으니 직접 구축해보고 싶네요.
1. 구성
하드웨어: 라즈베리 파이 B4
하드 디스크: 4T 기계식 하드 디스크
시스템: ubuntu-22.04.2-preinstalled-server-arm64+raspi(Raspberry Pi 공식 웹사이트에서 다운로드)
2. 예비 준비
Raspberry Pi 공식 웹 사이트에 따라 시스템을 굽고 실행하십시오.
3. 하드디스크 장착
3.1 장착을 위한 기계식 하드 디스크 포맷
실제 작업 중 볼륨 레이블이 중국어인 경우 ubuntu 콘솔을 사용하여 볼륨 레이블을 수정하면 오류가 발생하므로 볼륨 레이블을 영어로 변경하는 것이 좋습니다.
3.2 하드 디스크 장착
하드디스크를 라즈베리파이에 연결 후 마운트 이 단계에서는 먼저 하드디스크를 연결한 후 기기를 시작해야 하며, 그렇지 않으면 작업 중 입/출력 오류가 보고됩니다.
3.2.1 디렉토리 생성:
리눅스에서 하드디스크 마운트는 리눅스 시스템이 자동으로 인식하지 못하기 때문에 시스템 디렉토리에 마운트해야 하고, 지정된 디렉토리에만 마운트가 가능하며, 인터넷에서는 일반적으로 mnt 디렉토리에 생성된다고 한다. 초보자로서 저도 이 디렉토리에 있습니다. 아래에 생성되었습니다.
sudo mkdir /mnt/DbDisk
3.2.2 하드 디스크 식별
fdisk -l 명령을 통해 하드 디스크를 식별합니다.
ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/loop0: 59.09 MiB, 61956096 bytes, 121008 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 59.12 MiB, 61988864 bytes, 121072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 109.61 MiB, 114929664 bytes, 224472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 43.19 MiB, 45289472 bytes, 88456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 43.18 MiB, 45277184 bytes, 88432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: e SSD ST600 MSAT
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x12c9124a
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 526335 524288 256M c W95 FAT32 (LBA)
/dev/sdb2 526336 250069679 249543344 119G 83 Linux
Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: 006-3CW104
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 9463367F-46F9-46DB-AC72-5633AEA58D7E
Device Start End Sectors Size Type
/dev/sda1 4096 7814037134 7814033039 3.6T Microsoft basic data
마운트하려는 하드 디스크는 마운트하려는 하드 디스크의 크기에 따라 식별되는 /dev/sda1입니다.
3.2.3 하드 디스크 장착:
sudo mount /dev/sda1 /mnt/DbDisk
sudo df를 통해서 하드디스크의 마운팅 상태를 볼 수 있습니다. 현재 DbDisk 디렉토리에 sda1 하드디스크를 마운트했습니다.
ubuntu@ubuntu:~$ sudo df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 388000 3176 384824 1% /run
/dev/sdb2 122731688 4809364 111667360 5% /
tmpfs 1939984 0 1939984 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
/dev/sdb1 258095 151621 106475 59% /boot/firmware
/dev/sda1 3907016516 221416 3906795100 1% /mnt/DbDisk
tmpfs 387996 4 387992 1% /run/user/1000
3.2.4 자동 마운트 설정
직접 마운트는 재시작할 때마다 한 번 마운트해야 하며 일반적으로 자동 마운트를 설정하는 것이 좋으며 이는 구성 파일을 수정하여 구현할 수 있습니다.
ubuntu@ubuntu:~$ sudo vim /etc/fstab
그런 다음 새로 마운트할 디스크를 구성 파일에 추가합니다.
LABEL=writable / ext4 discard,errors=remount-ro 0 1
LABEL=system-boot /boot/firmware vfat defaults 0 1
/dev/sda1 /mnt/DbDisk ntfs auto,user,rw 0 1
마운트 시작 부분의 식별 번호는 LABEL 볼륨 레이블, UUID 하드 디스크 번호이거나 나 같은 시스템에서 인식하는 장치 경로를 직접 쓸 수 있습니다. 실제 사용시 LABEL도 UUID도 인식이 안되는 상황이 있어서 디바이스 경로를 이용해서 직접 마운트 하도록 변경했는데 사용하기 편합니다.
설정 후 Raspberry Pi를 다시 시작하여 정상적으로 작동하는지 확인할 수 있습니다.
4. svnserver 설치
4.1 svn 서버 설치
sudo apt-get install subversion
4.2 svn 창고 폴더 만들기
ubuntu@ubuntu:~$ sudo mkdir /mnt/DbDisk/svn
svn 웨어하우스 폴더로 사용할 svn 웨어하우스 폴더를 하드 디스크 디렉토리에 생성합니다.
ubuntu@ubuntu:/mnt/DbDisk/svn$ sudo mkdir test
ubuntu@ubuntu:/mnt/DbDisk/svn$ ls
test
웨어하우스 디렉토리의 버전 라이브러리 테스트
4.3 저장소 생성
sudo svnadmin create /mnt/DbDisk/svn/test
ubuntu@ubuntu:/mnt/DbDisk/svn/test$ ls
README.txt conf db format hooks locks
ubuntu@ubuntu:/mnt/DbDisk/svn/test$ ls -a
. .. README.txt conf db format hooks locks
ubuntu@ubuntu:/mnt/DbDisk/svn/test$
생성이 완료되면 디렉토리에 파일이 있습니다.
4.4 구성
conf 폴더 아래의 파일을 수정하여 권한을 구성합니다.
구성 파일 svnserve.conf, authz, passwd 수정 시 모든 줄 헤더를 비워둘 수 없으며 끝에 빈 공백을 추가할 수 없습니다. 실제 수정 중에는 추가할 수 없습니다. 그렇지 않으면 "권한 부여 실패" 오류가 보고됩니다.
4.4.1 svnserve.conf 파일
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none # 设置匿名用户不可读
auth-access = write # 权限用户可写
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd # 使用用密码文件
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the
### directory containing this file. The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository. If you don't specify an authz-db,
### no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz # 使用权限文件
4.4.2 인증 파일
[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
# 在末尾添加信息
admin = admin # 管理员用户admin分组属于admin组
[/] # 从仓库开始设置权限
@admin = rw # 管理员组的权限是读写
4.4.3 암호 파일
[users]
# harry = harryssecret
# sally = sallyssecret
admin = 123456 # 在末尾添加用户和密码,明文输入
4.5 서버 시작
ubuntu@ubuntu:/mnt/DbDisk/svn/test/conf$ sudo svnserve -d -r /mnt/DbDisk/svn
- -d: 데몬 모드에서 플래그 시작
- -r: svn 저장소의 루트 디렉토리를 설정하므로 액세스 시 전체 경로를 입력하지 마십시오.
- 기타: 아직 공부하지 않았습니다.
4.6 연결 상태 보기
ubuntu@ubuntu:~$ ps -aux | grep svnserve
root 1588 0.0 0.0 18904 2552 ? Ss 07:46 0:00 svnserve -d -r /mnt/DbDisk/svn
ubuntu 1598 0.0 0.0 6420 1864 pts/0 S+ 07:51 0:00 grep --color=auto svnserve
u
서비스가 보이면 서버가 성공적으로 시작된 것입니다.
4.7 서버 중지
killall svnserve
5 svn에 대한 액세스
5.1 뷰 포트
ubuntu@ubuntu:~$ sudo netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 822/systemd-resolve
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1588/svnserve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 987/sshd: /usr/sbin
tcp 0 0 192.168.1.17:22 192.168.1.19:60135 ESTABLISHED 1312/sshd: ubuntu [
tcp6 0 0 :::3389 :::* LISTEN 936/xrdp
tcp6 0 0 ::1:3350 :::* LISTEN 896/xrdp-sesman
tcp6 0 0 :::22 :::* LISTEN 987/sshd: /usr/sbin
udp 0 0 127.0.0.53:53 0.0.0.0:* 822/systemd-resolve
udp 0 0 192.168.1.17:68 0.0.0.0:* 820/systemd-network
udp6 0 0 fe80::dea6:32ff:fe4:546 :::* 820/systemd-network
raw6 0 0 :::58 :::* 7 820/systemd-network
sudo netstat -anp를 통해 svn 서비스의 포트 번호를 보면 svn 서버의 기본 포트가 3690임을 알 수 있습니다.
5.2 svn 서버 포트 열기
ubuntu@ubuntu:~$ sudo ufw allow 3690 # 开放端口
Rule added
Rule added (v6)
ubuntu@ubuntu:~$ sudo ufw status #检查端口状态
Status: active
To Action From
-- ------ ----
3690 ALLOW Anywhere
3690 (v6) ALLOW Anywhere (v6)
포트가 열린 후 외부에서 액세스할 수 있습니다.
5.3 svn 라이브러리에 대한 액세스
Windows 환경에서 svn 클라이언트로 액세스합니다.
폴더 생성 시도:
5.4 재미있게 보내세요
인터넷에 있는 정보를 보면 알 것 같은 느낌이 들고 사실 문제를 찾으려면 아직 연습을 해야 하고 직접 설정을 해야 뭔가를 얻을 수 있습니다.