Topics covered:
Adding swap to a new cloud instance
- Checking for swap
- Creating swap
- Changing swappiness
Installing Java
- Downloading the JDK to the server
- Installing the JDK
- Setting the default JDK
- Downloading WildFly
- Creating the wildfly user
- Installing the init.d scripts
- Starting WildFly as a service
- Open public interface to all IP's
- Open the management interface to all IP's (optional)
- Remove the welcome content (optional)
Adding swap to a new cloud instance
Swap is an area on your hard drive that can store data when your RAM is full. First we need to check to see if a swap area is configured:sudo swapon -sIf you get the headers back only, you have no swap space:
Now lets create a 4 gig swap:
sudo fallocate -l 4G /swapfileVerify that is has been created and is the correct size
ls -lh /swapfileYou should see something like this:
Now change the folder permissions:
sudo chmod 600 /swapfileSet up swap
sudo mkswap /swapfileYou will should see the output below.
Now enable swap
sudo swapon /swapfileLets check to see if we have swap space
sudo swapon -sWe should get the following output:
To make the changes permanent you need to update the fstab file
sudo echo '/swapfile none swap sw 0 0' >> /etc/fstab
Update swappiness
Swappiness can be configured between 0 and 100. The nearer to 0 the more data will be put into the RAM rather than the swap.To view the current swappiness:
cat /proc/sys/vm/swappinessTo change the swapiness to 10:
sudo echo 'vm.swappiness=10' >> /etc/sysctl.confThis only takes effect on reboot, so also run this command to effect this change immediately
sudo sysctl vm.swappiness=10
Updating the server using apt-get
If you have not already updated your new server, do so now:sudo apt-get update sudo apt-get upgrade
Installing Java
Personally I like to install the Oracle JDK rather than OpenJDK. As you need to accept the Oracle licence before downloading, you will need to browse to the Java download page using your browser. Agree to the terms, and then click on download. As soon as it starts, pause it, and copy the download link.Go to your server and use wget to download the file using the download link you just copied:
wget -c http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz?AuthParam=1423681612_d8066e1256e66a7a4895ad467fc7cd07When is has finished downloading, extract it to the /opt/java folder (or any other folder of your choosing)
mkdir /opt/java tar -xvzf jdk-8u31-linux-x64.tar.gz -C /opt/javaNow add the following to the end of /etc/environment:
JAVA_HOME="/opt/java/jdk1.8.0_31" PATH="$JAVA_HOME/bin:$PATH"Now source the file to load the new $PATH and $JAVA_HOME properties
. /etc/environment
Installing WildFly
cd /opt wget -c http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.tar.gz tar -xzvf wildfly-8.2.0.Final.tar.gz
Create the wildfly user and group
addgroup wildfly useradd -g wildfly wildflyChange the ownership of the wildfly folder recursively:
chown -R wildfly:wildfly /opt/wildfly-8.2.0.Final/Create a symbolic link so that if you change WildFly versions, you don't have to update any other configuration:
ln -s wildfly-8.2.0.Final /opt/wildfly
Installing the init.d scripts
To easiest way to start and stop WildFly is to use a startup script. Copy and paste the init.d script within the WildFly install to the /etc/init.d/ folder, change the permissions, and make it executable:cp /opt/wildfly/bin/init.d/wildfly-init-debian.sh /etc/init.d/wildfly sudo chown root:root /etc/init.d/wildfly sudo chmod ug+x /etc/init.d/wildflyTo start/stop WildFly you will simply run the commands
sudo /etc/init.d/wildfly start sudo /etc/init.d/wildfly stop
Starting WildFly as a service
To enable WildFly to start automatically when the server starts, you need to add it to the linux run-levels:sudo update-rc.d wildfly defaultsYou should see the following output:
Configuring WildFly - open the public interface to all IP's
To access WildFly from an IP other than 127.0.0.1 (localhost) you will need to update the bind address for the public interface. Update this:<interface name="public"> <inet-address value="${jboss.bind.address:127.0.0.1}"/> </interface>to this:
<interface name="public"> <any-address/> </interface>You will now be able to access WildFly from any IP using port 8080
Open the management interface to all IP's (optional)
If you want to access the management console (on port 9990), you will need to update the bind address as you did for the public interface:<interface name="management"> <any-address/> </interface>You will now be able to access the management interface on port 9990 from any computer.
Remove the welcome content (optional)
<server name="default-server"> <http-listener name="default" socket-binding="http"/> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content"/> <filter-ref name="server-header"/> <filter-ref name="x-powered-by-header"/> </host> </server> <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/> </handlers>
You will now be able to deploy your application to WildFly and view it on your_ip:8080. Make sure you configure your jboss-web.xml and set the context root to /.
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <context-root>/</context-root> </jboss-web>Enjoy :)
I don't think you meant this:
ReplyDeleteln -s wildfly-8.2.0.Final.tar.gz /opt/wildfly
Thanks for letting me know, I have updated. :)
DeleteHi Chris do you have one for Wildfly 9.0.1 Final ?
ReplyDeleteMany thanks the documentations is also valid for 9.x versions.
ReplyDeleteOne can have only to replace wildfly-8.2.0.Final with the newer fname like wildfly-9.0.1.Final
In the "Configuring WildFly" section, what file are you modifying?
ReplyDelete