Overview
In this tutorial we'll be taking a look at how we can run an aion java emulator on a linux host. This can beneficial if you want to run a server in the cloud for eg. on AWS or Google cloud, or if you're like me and don't use windows for development but still want to run an emulator locally to test changes.
This tutorial is made for the latest 22.04 LTS Ubuntu Desktop image but it can also be applied to Ubuntu 22.04 Server and Ubuntu 18.04 Server images as well. I will be using an Aion Lightning core for this tutorial, but any emulator should work fine.
NOTICE: This is general guidance for debian based systems and there are a plethora of ways to setup your server on different architectures and so this setup is more generalized for the novice server admin wanting to run their emulator on a linux system or linux host in the cloud.
Ram requirements are dependent on what you want your server to do, for eg. disabling the spawning system will free up a lot of memory and will work on a cheaper server but then you won't have any NPC's or mobs to interact with. It's all about balancing what you want to do and also how much money you want to pay to run your server in the cloud.
I've personally setup many servers over the years and 8GB of ram is the general rule of thumb and increase as necessary unless you have thousands of concurrent players doing lots of multi tasking, at that point look at running a dedicated server with 64GB of ram and a Threadripper or something.
Serious $$$ will be expended in the process :) Ok, that's all. I just wanted to touch on that subject while I have your attention.
Here are the sections and what they cover:
- Checking which JDK we need to use.
- Installing & Configuring Java and Ant or Maven.
- Creating a bash compile script to compile the servers.
- Installing & Configuring mysql server.
- Creating a non root mysql user.
- Importing the sql files into mysql server.
- Creating our individual run scripts for the LS, GS and CS.
- Modifying the server config to use our non root user.
- Running the server.
- Some tips and tricks.
Checking which JDK we need to use
In the AL-Login, AL-Game and AL-Chat directories there will be either a build.xml file or a pom.xml file.
Within either of those will be a compile step which should specify which version of JDK the source is for.
Mine shows a build.xml with 1.7 as my AL-Game source version and my AL-Login and AL-Chat both show 1.6.
1.6 is JDK 6 and 1.7 is JDK 7, typically you go with whatever the GS is using which will be around the same version as the LS and CS.
I'll be using 1.7 for this tutorial, so JDK 7. I personally recommend you update your core to a later JDK version such as JDK 17 LTS for support until 2024.
Installing Java, Ant and Maven
If your servers contain a pom.xml, you will need maven installed, if they contain a build.xml you will need ant installed, or if you're curious you can install both, it won't hurt anything :)
Visit https://www.oracle.com/java/technolo...loads/archive/ and download the required JDK version, in my setup I click on Java SE 7 and select the Linux x64 .tar.gz download for the SDK. You will need to sign up for an account to be able to download archived JDK versions.
If your server requires Ant visit https://ant.apache.org/bindownload.cgi you will be presented 2 options, one requiring at least JRE 5 and one requiring at least JRE 8. I selected 1.9.16 tar.gz file requiring at least JRE 5.
If your server requires Maven visit https://maven.apache.org/download.cgi and download the Binary tar.gz archive
All of these will need to be installed in /usr/local/bin using the command below.
Code:
sudo tar -xvf <tar.gz file> -C /usr/local/bin
Once they have been extracted to /usr/local/bin you will need to update your path to make use of the newly installed programs.
Update ~/.bashrc file with the contents below, substitute the paths specific to your version of files.
Code:
export JAVA_HOME="/usr/local/bin/jdk1.7.0_67"
export ANT_HOME="/usr/local/bin/apache-ant-1.9.16"
export MVN_HOME="/usr/local/bin/apache-maven-3.8.6"
export PATH = $JAVA_HOME/bin:$ANT_HOME/bin:$MVN_HOME/bin:$PATH
Reload the bashrc file with the command below.
You can now verify each installation with the 3 commands below, if they show the version output, you can proceed to the next step, otherwise check that you've followed the steps correctly and try again.
Code:
java -version
ant -version
mvn -version
Creating a bash compile script
The next thing is to create a bash script to compile each of our servers automatically. I need to use Ant but if you need to use Maven change ant to mvn instead.
Here is the script, it will go into each folder and run the command to compile each server. The brackets instruct bash to run as new shell so it stays in the current directory when it executes commands.
Code:
#!/bin/bash
(cd AL-Login && ant)
(cd AL-Game && ant)
(cd AL-Chat && ant)
The 3 servers should now compile, the pom.xml or build.xml will run a clean step to remove the old build folders so we don't need to worry about those in the build script.
Installing & configuring mysql server
Install mysql-server and mysql-client with the command below, this will install and start our server on localhost.
Code:
sudo apt install mysql-server mysql-client
If for some reason you need to reboot and the server isn't running but you want to run it again, use the command below.
Code:
sudo systemctl start mysql.service
Now that mysql server is installed and running, let's login as root and create our databases. It's strongly advised against using a root user, so we will create another user to use for our configs instead of root.
Login to the server with the command below, press enter when prompted for a password. There is no space between -u and root
Code:
sudo mysql -uroot -p
We should now be in our mysql server, run the commands below one by one to create the databases. You can check your database.properties file in each aion server config folder to see what each database should be called. in my case it's al_server_gs and al_server_ls.
Code:
CREATE DATABASE al_server_ls;
CREATE DATABASE al_server_gs;
We can verify our mysql databases have been successfully created by running the command below to show us all the current databases.
Create a non root mysql user
Let's add a new user to use our config files and give him access to all functions required for managing the databases.
Code:
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'areallylongandcoolpasswordgoeshere';
Let's grant access on each database with the commands below.
Code:
GRANT ALL ON al_server_gs.* TO 'developer'@'localhost';
GRANT ALL ON al_server_ls.* TO 'developer'@'localhost';
Importing the sql files into mysql server
Run the commands below to import the mysql files into each database as root user as some commands require some mysql operations that only root privileges can run.
Code:
#in AL-Login/sql run the following command
sudo mysql -uroot -p al_server_ls < al_server_ls.sql
#in AL-Game/sql run the following command
sudo mysql -uroot -p al_server_gs < al_server_gs.sql
If all runs fine, your databases should now be populated with the necessary tables and content.
Creating our individual run scripts for the LS, GS and CS
Let's create our run scripts for each server, inside each dist/ folder create the following files with the following contents.
NOTE: the commands below are for an AL core. If your core is different, check the shell scripts in each dist folder. They will have the correct commands for your emulator or maybe not at all, in that case change class path to match your emulator.
For the loginserver create a file in dist called startlogin.sh and put the following contents.
Code:
#!/bin/bash
java -Xms8m -Xmx32m -ea -Xbootclasspath/p:./libs/jsr166-1.7.0.jar -cp ./libs/*:AL-Login.jar com.aionemu.loginserver.LoginServer
For the gameserver create a file in dist called startgame.sh and put the following contents. Adjust the ram amount in megabytes, at least 4gb is recommended.
Code:
#!/bin/bash
java -Xms128m -Xmx8096m -ea -XX:-UseSplitVerifier -javaagent:./libs/al-commons-1.3.jar -cp ./libs/*:AL-Game.jar com.aionemu.gameserver.GameServer
For the chatserver create a file in dist called startchat.sh and put the following contents.
Code:
#!/bin/bash
java -Xms128m -Xmx128m -ea -Xbootclasspath/p:./libs/jsr166.jar -cp ./libs/*:ac-hat.jar com.aionemu.chatserver.ChatServer
Modifying the server configs to use our non root user.
In each network folder edit the database.properties file, change the user to what you set earlier and the password as well.
If you're running this on a server and need to specify external IP addresses, you can edit the ip configurations as well but the mysql ones will stay the same as the mysql server will always be local facing.
Running the servers
Compile the server using the compile script made earlier and then individually run each bash script. If all works fine it will connect and you'll have a functioning server running on linux. If it doesn't, go back through each step and confirm that you've configured everything correctly.
Some tips and tricks.
If you want the server to run when you disconnect from your ssh session or you want to manage multiple terminal windows, download and install tmux and utilize this cheatsheet https://tmuxcheatsheet.com/
If you get an error when trying to import the sql scripts, something about using '00000 0000:0000' as the default timestamp value is wrong, just change it to CURRENT_TIMESTAMP and try import again, it should work :)
If you come across any other issues or think I've missed something entirely, leave a reply below, I'll be casually editing this post for typing mistakes and silly errors I come across.
Some code snippets are formatted incorrectly, I can't fix it. silly forum software from the early 2000's makes it impossible to format everything correctly.