It all started when I was doing Minecraft with several friends. ** Friend "I want to do multiplayer even in Java version" ** Dove "No, I live in an apartment so I can open the port ..." At that time, the electric current runs on the pigeon ――――――――――! When I connected to a server-based notebook PC by SSH from the outside, I used something like ** ngrok ** to open the port in a pseudo manner ... If I applied it and did something with Docker, something like this You can do it! !! ?? That's why I was able to build Micra Saba by saying Eun Eun for about an hour, so I wrote an article as a personal memorandum & reference. I think that it should be useful for junior and senior high school students who can not connect to the line, or for those who suddenly want to build Micra mackerel on the go. I'm going to write it so that even people who don't know much about servers can build it, but I don't think people who don't know much about servers will read this article. If you are familiar with servers, this article may be a little confusing, so it is recommended to read it.
--PC with Ubuntu ... 1 --Docker ... 1 animal --Ngrok ... 1 pick --nohup ... as you like
First is the ** server **. Since Docker is used, a server (PC) with ** Ubuntu ** (Linux OS) is desirable, but I think it's okay for some heroes to keep the power on while using WSL2 for a desktop with Win10. think. (In my opinion, Docker for Windows doesn't work well, so I recommend plain Ubuntu.) Docker Once the server is ready, let's install ** Docker ** next. In the first place, there may be some people who are Docker. Roughly speaking, it is a convenient tool that can be prepared by simply clicking on the troublesome environment construction such as the development environment and database. If you don't know, let's use it from now on. (I also want to write a Docker article) This If you read it, you can do it, but I'm writing an article, so I'll introduce it with a brief explanation.
First, update the existing package list to install the package!
$ sudo apt update
Install the packages required for Docker download!
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
Get the gpg key from the repository that contains Docker and save it!
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Allow Docker to be installed with apt!
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
Updated package list!
$ sudo apt update
Confirm that the repository of the installation destination has changed ...
$ apt-cache policy docker-ce
Install Docker!
$ sudo apt install docker-ce
Now on the Ubuntu terminal
$ sudo docker --version
You can confirm that docker is running by hitting it. If you want to be able to use Docker without sudo
, please refer to the above article.
After successfully installing Docker, let's build Micra Saba! Docker is a great guy who can finish building the environment just by touching it, so Micra Saba only needs to build an existing template. itzg/minecraft-server Let's install and build the Docker image here (the environment construction is completed, it looks like the replication source data) with Docker.
$ sudo docker pull itzg/minecraft-server
$ sudo docker run -d -p 25565:25565 --name mc itzg/minecraft-server
Wait and it's done.
[Addition] Not ... If you execute the following log check, EULA will be told.
$ sudo docker logs mc
Please check the license agreement attached to the URL. Then, before going to the next, run fails and the container is stopped, so let's delete it once.
$ sudo docker rm `docker ps -alq`
Then, if you agree after confirming the above terms
$ sudo docker run -e EULA=TRUE -d -p 25565:25565 --name mc itzg/minecraft-server
Please run the. Wait here and you're done. The postscript is over.
Now, while I'm waiting, lightly explain the part of -p 25565: 25565
.
For example, if you access http://www.google.com with Google Chrome, it will look up the address (IP address) of the server that operates the Google site and go to that PC. An IP address is a list of numbers such as 172.217.174.100
. (By the way, if you write this list of numbers in the URL, you can jump to Google.) Since there is not only one service on this server, it is necessary to determine which service to receive. It is the port number that determines it.
As an image, an office building containing multiple companies is a server, and each level has a company or an empty floor, and that level is like a port. Maybe.
And in this article, the office building is on the PC with Ubuntu, and the hierarchy with the company is on the left 25565 of -p 25565: 25565
. When you reach the 25565th floor of the server, there is a tunnel leading to the 25565th floor of Docker. When you reach the 25565th floor of Docker through the tunnel, it is an image that Micra's server is operated there.
For example, I have explained the real thing in a mess, but please read it with a spirit ().
Did the Micra server stand? You can check the current situation with the following command.
$ sudo docker logs -f mc
ngrok Now that we have built a Micra server, all we have to do is invite customers to the Ubuntu server. I'd like to open the port, but I live in an apartment, and even if I can enter and exit the address (IP address) here, who visits my IP address, who's office building on what floor and in what room? I don't know. In other words, the port cannot be opened. ** ngrok ** for you! This is amazing. You can open the port in a simulated manner without pulling a personal line just by clicking! !! Even on the apartment line, you can directly access the server of my house by pulling the ngrok tunnel that connects to the outside! So download & install Install the packages required for download ...
$ sudo apt update
$ sudo apt install wget unzip
Download ngrok ...
$ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
Unzip! !!
$ unzip ngrok-stable-linux-amd64.zip
It's annoying and I don't think the pass is passing, so let's move it.
$ sudo mv ngrok /usr/bin/ngrok
You should be able to use it with this (maybe you needed a confirmation login after unverified) You can now access Micra's server by accessing server number 25565. I'll have you connect a tunnel to that
$ ngrok tcp 25565
When you hit, a URL that can be accessed from the outside will be issued.
It seems that a URL like tcp: //X.tcp.ngrok.io: YYYYY
(X, YYYYY are numbers) will be issued.
With this, your friends can also invite you to Java Micra Multi! Yay! !! !!
Open Micra in Java version and select "Multiplayer"-> "Add Server" to freely change the server name and set the server address to "X.tcp.ngrok.io: YYYYY" (X, YYYYY are numbers) displayed earlier. If you participate, everyone can play! !!
nohup
You don't have to do this separately, but if you want the server to run other processes, or if you want to disconnect the server's SSH connection, you'll have to stop ngrok. Therefore, it is necessary to have it turned behind the scenes. That's where ** nohup ** comes in handy. When opening a port with ngrok
$ nohup ngrok tcp 25565&
Just hit and the terminal will be returned. But with this, the URL cannot be confirmed, so
$ curl localhost:4040/api/tunnels
You can check information such as the status of ngrok by tapping. There is an item "public_url" at the top, and the URL is written there. You have now built Micra's mackerel completely in the background! !! Congrats! !! !! !!
It was a Micra server that was finally built, but in the end, friends were crazy about the data that had been advanced in the integrated version, and no one came to Saba.
(´ ・ ω ・ `)
As an aside, I heard that Celeron has low power and is good for servers, so I overwrote Windows on my laptop with Ubuntu Server to make it a server. However, I am considering a rental server because it is not good to use a notebook PC as a server because it burns. (If you rent a rental server, you don't need this article) Well, I'm sure there will be demand for high school students when they build Saba.
Recommended Posts