Minecraft server
Minecraft server
VM 생성
2: Prepare the data disk
sudo mkdir -p /home/minecraftsudo mkfs.ext4 -F -E lazy_itable_init=0,\lazy_journal_init=0,discard \/dev/disk/by-id/google-minecraft-disk
Result
sudo mkfs.ext4 -F -E lazy_itable_init=0,\> lazy_journal_init=0,discard \> /dev/disk/by-id/google-minecraft-diskmke2fs 1.43.4 (31-Jan-2017)Discarding device blocks: doneCreating filesystem with 13107200 4k blocks and 3276800 inodesFilesystem UUID: b7c787e3-4996-4c22-a21b-2a7fc266f091Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424Allocating group tables: doneWriting inode tables: doneCreating journal (65536 blocks): doneWriting superblocks and filesystem accounting information: done
Mount
sudo mount -o discard,defaults /dev/disk/by-id/google-minecraft-disk /home/minecraft
3. Install and run the application
Java 설치
sudo apt-get updatesudo apt-get install -y default-jre-headlesscd /home/minecraftsudo apt-get install wgetsudo wget https://launcher.mojang.com/v1/objects/d0d0fe2b1dc6ab4c65554cb734270872b72dadd6/server.jar
Initialize the Minecraft server
sudo apt-get updatesudo apt-get install -y default-jre-headlesscd /home/minecraftsudo apt-get install wgetsudo wget https://launcher.mojang.com/v1/objects/d0d0fe2b1dc6ab4c65554cb734270872b72dadd6/server.jarsudo java -Xmx1024M -Xms1024M -jar server.jar nogui
트러블슈팅
eula.txt
eula=true
Create a virtual terminal screen to start the Minecraft server
sudo apt-get install -y screen sudo screen -S mcs java -Xmx1024M -Xms1024M -jar server.jar nogui
Detach from the screen and close your SSH session
sudo screen -r mcs
Allow client traffic
Create a firewall rule
5: Schedule regular backups
gsutil mb gs://$YOUR_BUCKET_NAME-minecraft-backup gsutil mb gs://$YOUR_BUCKET_NAME-minecraft-backup
Backup.sh
#!/bin/bashscreen -r mcs -X stuff '/save-all\n/save-off\n'/usr/bin/gsutil cp -R ${BASH_SOURCE%/*}/world gs://${YOUR_BUCKET_NAME}-minecraft-backup/$(date "+%Y%m%d-%H%M%S")-worldscreen -r mcs -X stuff '/save-on\n'
sudo chmod 755 /home/minecraft/backup.sh . /home/minecraft/backup.sh
sudo crontab -e
0 */4 * * * /home/minecraft/backup.sh
Server maintenance
정지
sudo screen -r -X stuff '/stop\n'
Automate server maintenance with startup and shutdown scripts
https://storage.googleapis.com/cloud-training/archinfra/mcserver/startup.sh
https://storage.googleapis.com/cloud-training/archinfra/mcserver/shutdown.sh