-
[게임/서버] 테라리아 리눅스 서버 만들기게임 (Game)/게임서버 2023. 5. 24. 20:47반응형
개요) 리눅스 서버에서 게임서버 구성하기
- 리눅스를 이미 설치한 가정하에 설명 (CentOS 7)
▷ CentOS 6은 glibc 버전이 낮아 구성이 불가 (glibc 2.12, 요구버전 2.15. glibc 컴파일로 해결 불가)
- 구성 위치는 /server/terraria 로 예제로 구성함
1) 파일 다운로드
- https://terraria.wiki.gg/wiki/Server#Downloads
▷ 글 작성시점 1.4.4.9 [링크]
2) 게임서버 파일을 리눅스 서버에 전송
- /server 디렉토리에 넣어둠
3) 압축해제
- unzip 명령으로 압축해제 (unzip -q terraria-server-1449.zip)
▷ unzip 명령이 없다면 yum 으로 설치
더보기yum install unzip -y
- 압축해제시 버전명의 디렉토리가 보임
- 리눅스 파일들은 '1449/Linux' 디렉토리로 확인됨
[root@terraria server]# yum install unzip -y Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package unzip.x86_64 0:6.0-5.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================= Installing: unzip x86_64 6.0-5.el6 C6.10-base 152 k Transaction Summary ========================================================================================================================================================= Install 1 Package(s) Total download size: 152 k Installed size: 324 k Downloading Packages: unzip-6.0-5.el6.x86_64.rpm | 152 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : unzip-6.0-5.el6.x86_64 1/1 Verifying : unzip-6.0-5.el6.x86_64 1/1 Installed: unzip.x86_64 0:6.0-5.el6 Complete!
[root@terraria ~]# mkdir /server [root@terraria ~]# cd /server [root@terraria server]# pwd /server [root@terraria server]# ll total 43588 lrwxrwxrwx. 1 root root 10 May 24 19:09 terraria -> 1449/Linux -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip [root@terraria server]# unzip -q terraria-server-1449.zip [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 lrwxrwxrwx. 1 root root 10 May 24 19:09 terraria -> 1449/Linux -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip
[root@terraria server]# cd 1449 [root@terraria 1449]# ll total 12 drwxr-xr-x. 3 root root 4096 May 24 19:11 Linux drwxr-xr-x. 3 root root 4096 Nov 17 2022 Mac drwxr-xr-x. 2 root root 4096 Nov 17 2022 Windows [root@terraria 1449]# cd Linux [root@terraria Linux]# ll total 45740 -rw-r--r--. 1 root root 547195 Nov 17 2022 changelog.txt -rw-r--r--. 1 root root 784896 Mar 23 2022 FNA.dll -rw-r--r--. 1 root root 871 Oct 14 2020 FNA.dll.config drwxr-xr-x. 2 root root 4096 Nov 17 2022 lib64 -rw-r--r--. 1 root root 4048 Nov 5 2020 monoconfig -rw-r--r--. 1 root root 34366 Nov 5 2020 monomachineconfig -rw-r--r--. 1 root root 212992 Nov 5 2020 Mono.Posix.dll -rw-r--r--. 1 root root 241152 Nov 5 2020 Mono.Security.dll -rw-r--r--. 1 root root 4641792 Nov 5 2020 mscorlib.dll -rw-r--r--. 1 root root 63 Nov 5 2020 open-folder -rw-r--r--. 1 root root 122880 Nov 5 2020 System.Configuration.dll -rw-r--r--. 1 root root 1087488 Nov 5 2020 System.Core.dll -rw-r--r--. 1 root root 2103296 Nov 5 2020 System.Data.dll -rw-r--r--. 1 root root 2615808 Nov 5 2020 System.dll -rw-r--r--. 1 root root 491008 Nov 5 2020 System.Drawing.dll -rw-r--r--. 1 root root 119808 Nov 5 2020 System.Numerics.dll -rw-r--r--. 1 root root 939008 Nov 5 2020 System.Runtime.Serialization.dll -rw-r--r--. 1 root root 316416 Nov 5 2020 System.Security.dll -rw-r--r--. 1 root root 3051008 Nov 5 2020 System.Windows.Forms.dll -rw-r--r--. 1 root root 543 Nov 5 2020 System.Windows.Forms.dll.config -rw-r--r--. 1 root root 3176448 Nov 5 2020 System.Xml.dll -rw-r--r--. 1 root root 137728 Nov 5 2020 System.Xml.Linq.dll -rw-r--r--. 1 root root 5631 Nov 5 2020 Terraria.png -rwxr-xr-x. 1 root root 410 Nov 5 2020 TerrariaServer -rwxr-xr-x. 1 root root 6021208 Nov 5 2020 TerrariaServer.bin.x86_64 -rwxr-xr-x. 1 root root 19957248 Nov 17 2022 TerrariaServer.exe -rw-r--r--. 1 root root 164864 Nov 5 2020 WindowsBase.dll
4) 경로 설정
- 심볼릭 링크 생성 (/server/terraria 호출시 /server/1449/Linux 호출하도록)
▷ ln -s /server/1449/Linux /server/terraria
[root@terraria server]# cd /server [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip [root@terraria server]# ln -s /server/1449/Linux /server/terraria [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 lrwxrwxrwx. 1 root root 10 May 24 19:09 terraria -> 1449/Linux -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip
5) 권한 설정
- 실행 해야될 파일에 실행권한 부여
▷ cd /server/terraria
▷ chmod +x TerrariaServer*
[root@terraria server]# cd /server/terraria [root@terraria terraria]# chmod +x TerrariaServer* [root@terraria terraria]# ll total 45740 -rw-r--r--. 1 root root 547195 Nov 17 2022 changelog.txt -rw-r--r--. 1 root root 784896 Mar 23 2022 FNA.dll -rw-r--r--. 1 root root 871 Oct 14 2020 FNA.dll.config drwxr-xr-x. 2 root root 4096 Nov 17 2022 lib64 -rw-r--r--. 1 root root 4048 Nov 5 2020 monoconfig -rw-r--r--. 1 root root 34366 Nov 5 2020 monomachineconfig -rw-r--r--. 1 root root 212992 Nov 5 2020 Mono.Posix.dll -rw-r--r--. 1 root root 241152 Nov 5 2020 Mono.Security.dll -rw-r--r--. 1 root root 4641792 Nov 5 2020 mscorlib.dll -rw-r--r--. 1 root root 63 Nov 5 2020 open-folder -rw-r--r--. 1 root root 122880 Nov 5 2020 System.Configuration.dll -rw-r--r--. 1 root root 1087488 Nov 5 2020 System.Core.dll -rw-r--r--. 1 root root 2103296 Nov 5 2020 System.Data.dll -rw-r--r--. 1 root root 2615808 Nov 5 2020 System.dll -rw-r--r--. 1 root root 491008 Nov 5 2020 System.Drawing.dll -rw-r--r--. 1 root root 119808 Nov 5 2020 System.Numerics.dll -rw-r--r--. 1 root root 939008 Nov 5 2020 System.Runtime.Serialization.dll -rw-r--r--. 1 root root 316416 Nov 5 2020 System.Security.dll -rw-r--r--. 1 root root 3051008 Nov 5 2020 System.Windows.Forms.dll -rw-r--r--. 1 root root 543 Nov 5 2020 System.Windows.Forms.dll.config -rw-r--r--. 1 root root 3176448 Nov 5 2020 System.Xml.dll -rw-r--r--. 1 root root 137728 Nov 5 2020 System.Xml.Linq.dll -rw-r--r--. 1 root root 5631 Nov 5 2020 Terraria.png -rwxr-xr-x. 1 root root 410 Nov 5 2020 TerrariaServer -rwxr-xr-x. 1 root root 6021208 Nov 5 2020 TerrariaServer.bin.x86_64 -rwxr-xr-x. 1 root root 19957248 Nov 17 2022 TerrariaServer.exe -rw-r--r--. 1 root root 164864 Nov 5 2020 WindowsBase.dll
6) 서버 기동 테스트
- cd /server/terraria
- ./TerrariaServer.bin.x86_64
[root@terraria ~]# cd /server/terraria [root@terraria terraria]# ./TerrariaServer.bin.x86_64
※ 월드가 없으므로 생성 (n 엔터)
Terraria Server v1.4.4.9 n New World d <number>Delete World Choose World:
※ 월드 크기
- 1 : 작음, 2 : 중간, 3 : 크게
Terraria Server v1.4.4.9 1 Small 2 Medium 3 Large Choose size:
※ 난이도 선택
Terraria Server v1.4.4.9 1 Classic 2 Expert 3 Master 4 Journey Choose difficulty:
※ 악마 선택
Terraria Server v1.4.4.9 1 Random 2 Corrupt 3 Crimson Choose world evil:
※ 월드명
Terraria Server v1.4.4.9 Enter world name:
※ 월드 생성시 참고할 시드
▷ 미입력시 랜덤
Terraria Server v1.4.4.9 Enter Seed (Leave Blank For Random):
- 월드 생성 완료
※ 월드 선택
▷ 1번 선택 (test1 월드)
Terraria Server v1.4.4.9 1 test1 n New World d <number>Delete World Choose World:
※ 서버 플레이어 제한수
▷ 기본 16명
Terraria Server v1.4.4.9 Max players (press enter for 16):
※ 서버 포트번호
▷ 기본은 7777
Terraria Server v1.4.4.9 Server port (press enter for 7777):
※ 자동 포트 포워드
▷ 기본은 켜짐
Terraria Server v1.4.4.9 Automatically forward port? (y/n):
※ 서버 접속에 필요한 패스워드
▷ 기본은 요구하지 않음
Terraria Server v1.4.4.9 Server password (press enter for none):
※ 서버 기동되어 명령어 입력 모드 상태
▷ 서버 접속 가능
Terraria Server v1.4.4.9 Listening on port 7777 Type 'help' for a list of commands. : Server started
※ help (도움말)
:help Available commands: help Displays a list of commands. playing Shows the list of players. clear Clear the console window. exit Shutdown the server and save. exit-nosave Shutdown the server without saving. save Save the game world. kick <player> Kicks a player from the server. ban <player> Bans a player from the server. password Show password. password <pass> Change password. version Print version number. time Display game time. port Print the listening port. maxplayers Print the max number of players. say <words> Send a message. motd Print MOTD. motd <words> Change MOTD. dawn Change time to dawn. noon Change time to noon. dusk Change time to dusk. midnight Change time to midnight. settle Settle all water. seed Displays the world seed. :
playing 플레이어 사용자 리스트 : playing
mple231 (172.30.1.7:10219)
1 player connected.clear 콘솔창 메세지 지우기 exit 서버 종료 (월드 저장) exit-nosave 서버 종료 (월드 저장 안함) save 월드 저장 kick (유저명) 플레이어 내쫓기 : kick mple231
172.30.1.7:10232 was booted: Kicked from server.
: mple231 has left.ban (유저명) 플레이어 내쫓기 (영구) : ban mple231
172.30.1.7:10244 was booted: Banned from server.
: mple231 has left.password 서버 패스워드 보기 password
Password: thetestserver
:password (패스워드) 서버 패스워드 설정 : password 1234
Password: 1234version 서버 버전 확인 : version
Terraria Server v1.4.4.9time 서버 시간확 : time
Time: 8:20 AMport 서버 포트번호 확인 : port
Port: 7777maxplayers 서버 제한인원 확인 : maxplayers
Player limit: 16say (할말) 월드에 채팅 보내기 : say hello
<Server> hellomotd 월드 입장시 메세지 보기 : motd
Welcome to test1!motd (메세지) 월드 입장시 메세지 변경 : motd hello dawn/noon/dusk/midnight 시간대 변경
- dawn (새벽 04:30)
- noon (정오 12:00)
- dusk (황혼 19:30)
- midnight (자정 00:00)settle settle all water
- 효과 잘 모르겠음: settle
Forcing water to settle.seed seed 보기 : seed
World Seed: 1.1.1.1252111696※ 밴 리스트 확인 후 제거
- /server/terraria/banlist.txt 파일을 수정 (ID 및 IP 삭제)
- 접속할 때에만 밴리스트 파일이 읽히므로 운영 중간에 파일을 수정해도 무방
[root@terratia terraria]# cat banlist.txt //mple231 172.30.1.7
※ 서버내 월드 파일 위치
- root로 실행한다면 /root/.local/share/Terraria
[root@terraria ~]# cd /root/.local/share/Terraria [root@terraria Terraria]# ll total 8 -rw-r--r--. 1 root root 43 May 24 19:21 favorites.json drwxr-xr-x. 2 root root 4096 May 24 19:21 Worlds [root@terraria Terraria]# cd Worlds/ [root@terraria Worlds]# ll total 5780 -rw-r--r--. 1 root root 2960781 May 24 20:10 test1.wld -rw-r--r--. 1 root root 2955413 May 24 20:10 test1.wld.bak
※ 백그라운드로 서버 운영
- 위의 실행 방법은 포그라운드로 돌아가서 터미널 창을 닫으면 서버가 유지되지 못함
- tmux 터미널을 사용하여 운영
(1) tmux 설치 (yum install tmux -y)
더보기[root@terraria ~]# yum install tmux -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package tmux.x86_64 0:1.8-4.el7 will be installed
--> Processing Dependency: libevent-2.0.so.5()(64bit) for package: tmux-1.8-4.el7.x86_64
--> Running transaction check
---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
tmux x86_64 1.8-4.el7 base 243 k
Installing for dependencies:
libevent x86_64 2.0.21-4.el7 base 214 k
Transaction Summary
====================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 457 k
Installed size: 1.3 M
Downloading packages:
(1/2): libevent-2.0.21-4.el7.x86_64.rpm | 214 kB 00:00:00
(2/2): tmux-1.8-4.el7.x86_64.rpm | 243 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------
Total 3.7 MB/s | 457 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libevent-2.0.21-4.el7.x86_64 1/2
Installing : tmux-1.8-4.el7.x86_64 2/2
Verifying : tmux-1.8-4.el7.x86_64 1/2
Verifying : libevent-2.0.21-4.el7.x86_64 2/2
Installed:
tmux.x86_64 0:1.8-4.el7
Dependency Installed:
libevent.x86_64 0:2.0.21-4.el7
Complete!(2) tmux 입력
(3) 서버 기동) /server/terraria/TerrariaServer
(4) 터미널을 나가기 위해 Ctrl+B 누른 후 D키
▷ tmux 터미널 창은 계속 서버에 남아 있는 상태
help Displays a list of commands. playing Shows the list of players. clear Clear the console window. exit Shutdown the server and save. exit-nosave Shutdown the server without saving. save Save the game world. kick <player> Kicks a player from the server. ban <player> Bans a player from the server. password Show password. password <pass> Change password. version Print version number. time Display game time. port Print the listening port. maxplayers Print the max number of players. say <words> Send a message. motd Print MOTD. motd <words> Change MOTD. dawn Change time to dawn. noon Change time to noon. dusk Change time to dusk. midnight Change time to midnight. settle Settle all water. seed Displays the world seed. : [0] 0:root@terraria:/server/terraria*
- Ctrl + B 누른 후 D키 누르면 tmux 에서 나옴
[root@terraria terraria]# tmux [detached] [root@terraria terraria]#
(5) 재접속
- 여러 터미널중 확인 필요
- tmux list-sessions 명령어로 남아 있는 세션 확인
▷ 아래 결과는 0번 세션만 남아 있음 확인
- 0번 세션으로 접속 (tmux attach-session -t 0)
[root@terraria terraria]# tmux list-sessions 0: 1 windows (created Wed May 24 20:23:46 2023) [132x29] [root@terraria terraria]# tmux attach-session -t 0
: [0] 0:root@terraria:/server/terraria* "terraria" 20:33 24-May-23
7) 기타
- https://terraria.wiki.gg/wiki/Server
- 서버 설정파일을 만들거나, 서버 실행 명령어 등은 위에 링크참조 (따로 언급안함)
- 서버 버전업
▷ 위에 설치 과정을 동일하게 하고, 심볼릭 링크만 바꿔준다
▷ 예) 현재 1449 버전인데 1450 버전이 설치된다면 아래와 같이 진행
▷ ▷ 문제가 있을 때 롤백 및 차후 업그레이드가 쉬워짐
[root@terraria server]# cd /server [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 drwxr-xr-x. 5 root root 4096 Nov 18 2022 1450 lrwxrwxrwx. 1 root root 10 May 24 19:09 terraria -> 1449/Linux -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip -rw-r--r--. 1 root root 44628068 May 25 19:09 terraria-server-1450.zip [root@terraria server]# unlink terraria [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 drwxr-xr-x. 5 root root 4096 Nov 18 2022 1450 -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip -rw-r--r--. 1 root root 44628068 May 25 19:09 terraria-server-1450.zip [root@terraria server]# ln -s /server/1450/Linux /server/terraria [root@terraria server]# ll total 43588 drwxr-xr-x. 5 root root 4096 Nov 17 2022 1449 drwxr-xr-x. 5 root root 4096 Nov 18 2022 1450 lrwxrwxrwx. 1 root root 10 May 24 19:09 terraria -> 1450/Linux -rw-r--r--. 1 root root 44628067 May 24 19:09 terraria-server-1449.zip -rw-r--r--. 1 root root 44628068 May 25 19:09 terraria-server-1450.zip
- 게임실행 스크립트
▷ CONFIG 부분만 바꿔서 실행 (직접 만들고 테스트 완료)
▷ 옵션을 미사용 할려면 앞에 #을 붙이면 됨
#!/bin/bash ###################### # ----- CONFIG ----- # ###################### # File (World) WORLD=/root/.local/share/Terraria/Worlds/test1.wld # File (Ban List) BAN_LIST=/server/terraria/banlist.txt # Port (Default 7777) PORT=7777 # MAX Players (1-255) MAX_PLAYER=16 # Server Password PASS="1234" # MOTD Message MOTD="Good Day" # Secure SECURE=1 #################### # ----- MAIN ----- # #################### cd "`dirname "$0"`" export MONO_IOMAP=all OPTION="" if [[ ! -z "$PORT" ]] then OPTION="-port $PORT " fi if [[ ! -z "$MAX_PLAYER" ]] then OPTION="$OPTION-maxplayers $MAX_PLAYER " fi if [[ ! -z "$MOTD" ]] then OPTION="$OPTION-motd '"$MOTD"' " fi if [[ $SECURE -eq 1 ]] then OPTION="$OPTION-secure $SECURE " fi if [[ ! -z "$PASS" ]] then OPTION="$OPTION-pass "$PASS" " fi if [[ ! -z "$BAN_FILE" ]] then OPTION="$OPTION-banlist "$BAN_LIST" " fi if [[ ! -z "$WORLD" ]] then OPTION="$OPTION-world "$WORLD" " fi ./TerrariaServer.bin.x86_64 $OPTION
8) 문제해결
- 서버는 열려 있으나 접속불가
▷ 서버 방화벽 점검 필요
▷ 기본적으로 22번 포트만 방화벽이 구성되어 있으므로 방화벽을 추가하든지 방화벽을 끈다 (아래 방법은 방화벽 끄는 방법으로 서술)
▷ (정지) systemctl stop firewalld / (서버 부팅시 자동으로 기동되지 않도록) systemctl disable firewalld
[root@terraria ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2023-05-24 20:44:25 KST; 11s ago Docs: man:firewalld(1) Main PID: 9781 (firewalld) CGroup: /system.slice/firewalld.service └─9781 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid May 24 20:44:25 c7steam systemd[1]: Starting firewalld - dynamic firewall daemon... May 24 20:44:25 c7steam systemd[1]: Started firewalld - dynamic firewall daemon. May 24 20:44:25 c7steam firewalld[9781]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will ...g it now. Hint: Some lines were ellipsized, use -l to show in full. [root@terraria ~]# systemctl stop firewalld [root@terraria ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: inactive (dead) since Wed 2023-05-24 20:44:47 KST; 2s ago Docs: man:firewalld(1) Process: 9781 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) Main PID: 9781 (code=exited, status=0/SUCCESS) May 24 20:44:25 c7steam systemd[1]: Starting firewalld - dynamic firewall daemon... May 24 20:44:25 c7steam systemd[1]: Started firewalld - dynamic firewall daemon. May 24 20:44:25 c7steam firewalld[9781]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will ...g it now. May 24 20:44:46 c7steam systemd[1]: Stopping firewalld - dynamic firewall daemon... May 24 20:44:47 c7steam systemd[1]: Stopped firewalld - dynamic firewall daemon. Hint: Some lines were ellipsized, use -l to show in full.
반응형