Install and setup Jenkins 1.6 on Tomcat 8 on Ubuntu 14.04

Posted on Sunday, August 9, 2015


Installing and setting up Jenkins 1.6 on Tomcat 8 on an Ubuntu 14.04 box.
  • Oracle Java 1.7
  • Tomcat 8
  • Create an init script for tomcat
  • Setup tomcat (tomcat-users.xml, server.xml,setenv.sh, APR fix)
  • Deploy Jenkins War file
  • Set up users on Jenkins
  • (a few cleanup things like logrotate)








Install Oracle Java 1.7


Install the Oracle Java 1.7  (this procedure is will auto accept the Oracle License… It's scriptable!!)


   > sudo clear
   > sudo echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true"  |   sudo /usr/bin/debconf-set-selections
   > sudo echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
    > sudo echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
    > sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
    > sudo apt-get update
    > sudo apt-get -y install oracle-java7-installer


Check the version


   > java -version












Set up Folder Structure


You can install Tomcat7 via apt-get in Ubuntu 14.04, but where is the fun in that ?

For this build I am going to install Tomcat 8.  Here is a good site for a how to on installing Tomcat 8 on ubuntu 14.04 https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-14-04 [2]


First where are you going to put tomcat on your system?  A good recommendation is /opt/tomcat see http://www.pathname.com/fhs/pub/fhs-2.3.html [2].  The /opt directory is traditionally for options packages.

But… I am not going to do that.  I like to separate things out a little more.  I like to mount two additional drives on a machine and mount them at
/<project or company name>/apps
/<project or company name>/logs



As an example I would make this structure

/10x13
   | -  apps
         | - tomcat8
         | - nginx
    | - logs
         | - tomcat8
         | - nginx

You can do it anyway you want, but this is how I am going to do it in this tutorial

The server I am doing this on does not actually have two extra drives.

Create the structure


   > sudo mkdir -p /10x13/apps/tomcat8
   > sudo mkdir -p /10x13/apps/jenkins
   > sudo mkdir -p /10x13/logs/tomcat8






Add Tomcat User


First add a tomcat user/group.


   > sudo groupadd tomcat
   > sudo useradd -s /bin/bash -g tomcat -d /10x13/apps/tomcat8 tomcat








Download and install Tomcat







Right click on tar.gz






Copy Link Address


In my case it's

http://apache.go-parts.com/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz

Download the file (you may need to change the url for the mirror)


   > cd
   > wget http://apache.go-parts.com/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz




Untar it and put it in the /10x13/apps/tomcat8 folder



   > sudo tar -xvzf apache-tomcat-8.0.24.tar.gz -C /10x13/apps/tomcat8 --strip-components=1


The --strip-compents=1 removes the first folder it would have made "apache-tomcat-8.0.24"





Change permissions




   > sudo chown -R tomcat:tomcat /10x13/apps/tomcat8
   > sudo chown -R tomcat:tomcat /10x13/apps/jenkins
   > sudo chown -R tomcat:tomcat /10x13/logs/tomcat8








Create a startup script


First figure out where java is installed.



   > which java






   > ls -alh /usr/bin/java




Then…


   > ls -alh /etc/alternatives/java


 

There it is…

/usr/lib/jvm/java-7-oracle/jre/bin/java

You will need this for your JAVA_HOME env variable.







Now for the script… I found three interesting ones posted as gists on github


I am going to pick bits from them all and make my own.


   > sudo vi /etc/init.d/tomcat8


And place the following in it.


#!/bin/bash
#
# Apache Tomcat 8 init script
#
###########################################

TOMCAT_HOME=/10x13/apps/tomcat8
LOG_HOME=/10x13/logs/tomcat8
PID_FOLDER=/var/run/tomcat8
PID_FILE=$PID_FOLDER/tomcat.pid

start() {
  echo -n "Starting Tomcat at $TOMCAT_HOME"
  if [ ! -d $PID_FOLDER ]; then
    mkdir $PID_FOLDER
    chown tomcat:tomcat $PID_FOLDER
  fi
  su - tomcat -c "$TOMCAT_HOME/bin/startup.sh"
  RETVAL=$?
}

stop() {
  echo -n "Stopping Tomcat"
  su - tomcat -c "$TOMCAT_HOME/bin/shutdown.sh -force"
  RETVAL=$?
}

status() {
  if [ -f $PID_FILE ]; then
    PID=`cat $PID_FILE`
    echo "Tomcat is running process Id: $PID"
  else
    echo "Tomcat is not running"
  fi

  RETVAL=$?
}

case "$1" in
 start)
  start
   ;;
 stop)
  stop
   ;;
 restart)
  stop
  start
   ;;
 status)
  status
   ;;
 version)
  $TOMCAT_HOME/bin/version.sh
  RETVAL=$?
   ;;
 *)
  echo "Usage: $0 {start|stop|restart|status|version}"
  exit 1
   ;;
esac

exit $RETVAL


This will run tomcat as the tomcat user.  It also gives you the ability to check the status of the tomcat and get the version of tomcat you are running.

Register it as a service


   > sudo chmod 755 /etc/init.d/tomcat8
   > sudo update-rc.d tomcat8 defaults






But we are not done yet!

I need some setting set like JAVA_OPTS, CATALINA_PID and a few other.  I could have set them here, but I would have had to export them as the tomcat user…

Ex.


su - tomcat -c "export JAVA_OPTS=…."


That would make this init script a little noisy.

The proper place to put this information is in
/10x13/apps/tomcat8/bin/setenv.sh

Here are a few examples of setenv.sh I found

Edit it as the tomcat user, since he needs access to it anyway


   > sudo su - tomcat -c "vi /10x13/apps/tomcat8/bin/setenv.sh"


And place the following in it


#!/bin/bash
#
# Custom Environment Variables
# For Tomcat
#
###########################################
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/
export PATH=${JAVA_HOME}/bin:${PATH}

################################################
#
# JAVA_OPTS
#  You could do all this in one export command
# But I am going to be long winded and explain
# why and add links
#
# Oracles notes
#  - https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html
#  - A good viusal
#     https://redstack.wordpress.com/2011/01/06/visualising-garbage-collection-in-the-jvm/
################################################

# -server
#   Selects the Java HotSpot Server VM.
#   The 64-bit version of the JDK supports only the Server VM,
#   so in that case the option is implicit.
#   .. so it's redundant in today's world but it makes me feel good
export JAVA_OPTS="-server"

# -Xms/Xmx
#   Xms Sets the initial size of the heap
#   Xmx Sets the maximum size of the heap
#   http://stackoverflow.com/questions/16087153/what-happens-when-we-set-xmx-and-xms-equal-size
#   http://crunchify.com/jvm-tuning-heapsize-stacksize-garbage-collection-fundamental/
export JAVA_OPTS="$JAVA_OPTS -Xms1024M -Xmx1024M"

# -NewSize/MaxNewSize
#   Sets the size of the young generation
#   Most newly created objects are made here
#   Objects that did not become unreachable and survive the young
#   Generation heap are copied to the Old Generation
#   see http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection
#   https://redstack.wordpress.com/2011/01/06/visualising-garbage-collection-in-the-jvm/
export JAVA_OPTS="$JAVA_OPTS -XX:NewSize=512m -XX:MaxNewSize=512m"

# -PermSize/MaxPermSize
#   Stores classes or interned character strings
#   http://stackoverflow.com/questions/12114174/what-does-xxmaxpermsize-do
#     Warning!!
#     Deprecated in Java 8 replaced with -XX:MetaspaceSize  !!
export JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -XX:MaxPermSize=256m"

# -UseConcMarkSweepGC
#   Also called the low latency GC since pausing time is very short
#   When this is enabled also enables
#      -XX:+UseParNewGC Potentially Speeds up you generation GC
#      by a factor equal to number of CPUs
#      (see http://stackoverflow.com/questions/2101518/difference-between-xxuseparallelgc-and-xxuseparnewgc)
#   http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection/
export JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"


# -XX:+CMSIncrementalMode
#
#   I am not going to set this one but it's worth mentioning.
#  It has been deprecated in Java 8.  It is useful when you only have 1 or 2
#  CPUs on a machine.  It helps reduce latency by doing smaller garbage colletions
#    see these site for more details
#  http://www.fixdeveloper.com/2014/03/jvm-tuning-cmsincrementalmode-overrides.html
#  http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#icms


# -CMSClassUnloadingEnabled
#    In an old school java program classes are forever.  But with
#  Mordern languages like Groovy create classes at runtime, every script
#  may create a few new classes.  With this set the PermGen Space will
#  be garbage collected.  Without this you have a memory leak.
#
#  Must also have UseConcMarkSweepGC set for this to work
#
# http://stackoverflow.com/questions/3334911/what-does-jvm-flag-cmsclassunloadingenabled-actually-do
export JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled "


# -DisableExplicitGC
#   Expicit calls to System.gc() are completely ignored
#
#  http://stackoverflow.com/questions/12847151/setting-xxdisableexplicitgc-in-production-what-could-go-wrong
export JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"

# -HeapDumpPath
#   Sets the file where the heap dump will write out its error
export JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=/10x13/logs/tomcat8/java_heapdump_pid_%p.log"

# -java.awt.headless
#   Basically tells the JVM not to load awt libraries
#  You a server not a desktop app, There is more to it than that
#  If you want to go into it see
#    https://blog.idrsolutions.com/2013/08/what-is-headless-mode-in-java/
#    http://www.oracle.com/technetwork/articles/javase/headless-136834.html
export JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"

# -java.security.egd
#  This one is a bit of a debate...
# If you don't set it will use /dev/random on startup
# which can block and make tomcat startup slower.
# But it's technically more secure... but no one has
# shown a way to break the results of urandom which is faster
#   for more details see
# http://www.2uo.de/myths-about-urandom/
export JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"

################################################
#  CATALINA_OPTS
#These are basically JAVA_OPTS but only used by tomcat and only run
#On tomcat start see
# http://stackoverflow.com/questions/11222365/catalina-opts-vs-java-opts-what-is-the-difference
# for more details
#
################################################

# -jmxremote...
#  Turn on jmxremote so you can use JConsole to monitor the machine
#  Remotely
#  See
#     https://tomcat.apache.org/tomcat-7.0-doc/monitoring.html
#     http://www.mkyong.com/tomcat/jconsole-jmx-remote-access-on-tomcat/
#     http://www.javaworld.com/article/2072322/from-jconsole-to-visualvm.html
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote"
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=9090"
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
#This gets the local IP address
IP_ADDR=`ip route get 8.8.8.8 | awk '{print $NF; exit}'`
export CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=$IP_ADDR"

export CATALINA_HOME=/10x13/apps/tomcat8
export CATALINA_OUT=/10x13/logs/tomcat8/catalina.out
export CATALINA_PID=/var/run/tomcat8/tomcat.pid

#Set the Jenkins home directory
#This is not the webapps directory but rather a location
#where Jenkins can store it's builds and archives
export JENKINS_HOME=/10x13/apps/jenkins




I listed several URLS to explain each JAVA_OPTS setting.  Here are a few of the better ones to read of the bunch.







Try it out


Now try it out!



   > sudo service tomcat8 start



Tail the log file


   > tail -f /10x13/logs/tomcat8/catalina.out





Looks like it started in 3 seconds.



Now open up the URL.  In my case its located at http://192.168.0.195:8080/




It's running  



Check the status


   > sudo service tomcat8 status







Check the version


   > sudo service tomcat8 version


 





Now stop it


   > sudo service tomcat8 stop











Final Tomcat settings


So far so good but there are a few more things we need to do with tomcat before we install Jenkins on it.

APR fix


Looking through the catalina logs I came across this error


01-Aug-2015 18:56:53.360 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib


See http://tomcat.apache.org/native-doc/ [11] for more details but here is how you fix it in Ubuntu 14.04

First grab some needed libraries


   > sudo apt-get install libapr1.0-dev libssl-dev


When I ran this I got this error

Package libapr1.0-dev is not available, but is referred to by another package.






Find the Native Source Release






Right click on it and copy link address



You need a few tools to compile this.  Install these.


   > sudo apt-get install libapr1 libaprutil1 libapr1-dev libssl-dev make


Download and build the tomcat-native

(this does not work)

   > cd
   > wget http://apache.mirrors.tds.net/tomcat/tomcat-connectors/native/1.1.33/source/tomcat-native-1.1.33-src.tar.gz
    > tar -xvzf tomcat-native-1.1.33-src.tar.gz
    > cd tomcat-native*/jni/native
    > ./configure --with-java-home=/usr/lib/jvm/java-7-oracle/jre/ --with-apr=/usr/bin/apr-1-config


I get this error

checking os_type directory... Cannot find jni_md.h in /usr/lib/jvm/java-7-oracle/jre//
configure: error: You should retry --with-os-type=SUBDIR





Poking around


   > find /usr/lib/jvm/ -iname jni_md.h



I can see its at /usr/lib/jvm/java-7-oracle/include/linux/jni_md.h



Adding --with-os-type which is really just a relative direction to the folder that has jni_md.h


   > ./configure --with-java-home=/usr/lib/jvm/java-7-oracle/jre/ --with-apr=/usr/bin/apr-1-config  --with-os-type=../include/linux





Worked


Make


   > make


jni.h: No such file or directory




Quick looks for the jni.h file


   > find /usr/lib/jvm/ -iname jni.h


It's at /usr/lib/jvm/java-7-oracle/include/jni.h





OK after some tweaking I think I have a procedure…
and here it is…


   > cd
   > wget http://apache.mirrors.tds.net/tomcat/tomcat-connectors/native/1.1.33/source/tomcat-native-1.1.33-src.tar.gz
    > tar -xvzf tomcat-native-1.1.33-src.tar.gz
    > cd tomcat-native*/jni/native
    > sudo ln -s /usr/lib/jvm/java-7-oracle/include/linux /usr/lib/jvm/java-7-oracle/jre/linux
    > sudo ln -s /usr/lib/jvm/java-7-oracle/include/linux/jni_md.h /usr/lib/jvm/java-7-oracle/include/jni_md.h
    > sudo ln -s /usr/lib/jvm/java-7-oracle/include/linux/jawt_md.h /usr/lib/jvm/java-7-oracle/include/jawt_md.h
    > ./configure --with-java-home=/usr/lib/jvm/java-7-oracle/ --with-apr=/usr/bin/apr-1-config  --with-os-type=include/linux
    > make
    > sudo make install
    > sudo ln -s /usr/local/apr/lib/libtcnative-1.so /usr/lib/libtcnative-1.so



Restart tomcat


   > sudo service tomcat8 restart


See if it really loaded


   > grep -n APR /10x13/logs/tomcat8/catalina.out





Finally working!!





Tomcat-users.xml


Edit
/10x13/apps/tomcat8/conf/tomcat-users.xml"


   > sudo su - tomcat -c "vi /10x13/apps/tomcat8/conf/tomcat-users.xml"


And update it to the following


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user name="admin" password="mypassword"
     roles="admin-gui,manager-gui" />
</tomcat-users>


This add a user called admin with the password "mypassword" with the following roles.





admin-gui
  Gives access to

manager-gui
   Gives access to the HTML interface

Restart tomcat


   > sudo service tomcat8 restart








Click on Manager App, login with you username and password.




If you see this your user settings are probably OK




server.xml


I found this example of a server.xml set up for Jenkins https://gist.github.com/jollychang/1294789 [13]  I am going to base mine on this one.

I am only going to be deploying Jenkins on this Tomcat Server and I want it to auto expand and install a new war file.


   > sudo su - tomcat -c "vi /10x13/apps/tomcat8/conf/server.xml"


And update it to the following


<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve"
               directory="/10x13/logs/tomcat8"
               prefix="localhost_access" suffix=".log"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>







Deploy Jenkins


Stop tomcat


   > sudo service tomcat8 stop


Head over to /10x13/apps/tomcat8/webapps


   > cd /10x13/apps/tomcat8/webapps


Remove docs, and examples


   > sudo rm -r docs
   > sudo rm -r examples







 

Select Long-Term Support Release





Right click on the link and copy link address.


Now use wget to download the WAR file to the webapps directory


   > sudo su - tomcat -c "wget http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war -P /10x13/apps/tomcat8/webapps/ "





Start tomcat


   > sudo service tomcat8 start





Open Jenkins





If you get this give it a minute and it should reload









Configuring Jenkins


First confirm the home director for Jenkins is /10x13/apps/Jenkins

The folder there should be populated.


   > ls -alh /10x13/apps/jenkins










Click Manage Jenkins





Configure System




There is the Jenkins Home Directory Looks good!






Set up Security




Click Manage Jenkins






Click Configure Global Security




 

Checkbox Enable Security


 




Select "Unix user/group database"


 




Click Test







 

Error!

User ‘tomcat’ needs to belong to group shadow to read /etc/shadow

Looks like I need to add the shadow group to the tomcat user.


   > sudo usermod -a -G shadow tomcat




Restart tomcat


   > sudo service tomcat8 restart




Get back to enable security in Jenkins… open

 


Select Unix, click Test and now you should see Success!


 



Now select how you want to Authorize users.   For simplicity I am going to select Logged-in users can do anything.

With this selected… Any user on your unix system can login to Jenkins using their unix password


 



Click Save.







 

You need to login if you want to do anything important.  Anonymous users can still browse and see everything…




 
Login






Jenkins is installed and running!

This setting is all well and good, but now any linux user on your box is also can administrate Jenkins.

Even on a really small team you probably don't want this…
If you want one or two Jenkins admins, a few users 'developers' who can kick off builds, and a few management types that will never kick off a build but want to look around a better option is to use Matrix Based security.


Setting up matrix based security


After logging in click on Manage Jenkins











Click on Configure Global Security






Select Matrix-based Security








Add your users.

Enter the name of your users and click Add






Now you have this big permission matrix you can set per user and anonymous.






For the Anon User I set it to Overall Read.






For admin I gave them everything.






For a developer I have these settings.  This user can't create or configure a job but they can run them.

Depending on your group you may want some developers in this position and some the ability to create jobs.


One group I have been in allowed anonymous users to run jobs.  Which was not really a problem until we started having Jenkins post job builds to a Slack room.  Then everyone wanted to know who ran the build so we updated  permissions so folks had to log in before they could kick off a build (which really is a good practice… not to assign blame but to have better information)








When you are done click Save!






A few cleanup items



Change URL


Since this machine will only be a Jenkins box I would like the root url to open Jenkin and not the tomcat default page.

There are more than a few ways to do this…

I could install nginx on this box and have

Localhost:80  --->   localhost:8080/jenkins


Or even reset Tomcat to listen on 9090 and have nginx listen on port 8080 and hava

Localhost:8080 --->  localhost:9090/jenkins


But that is a little overkill for this box. 


I could wipe out the ROOT directory in webapps and rename the Jenkins.war file to ROOT.war and have it expand into ROOT then


Would be Jenkins

Or I could add a redirect from the index.jsp file already in the ROOT directory.

Adding something like
<meta http-equiv="refresh" content="0;url=/somethingelse/index.jsp"/>

To that file



I think I will go the ROOT.war way.

Stop tomcat


   > sudo service tomcat8 stop


Delete the Jenkins and ROOT folder in webapps and rename the Jenkins.war file


   > cd /10x13/apps/tomcat8/webapps
   > sudo rm -r ROOT
   > sudo rm -r Jenkins
   > sudo mv jenkins.war ROOT.war






Start tomcat


   > sudo service tomcat8 start


Now open





The Jenkins data is in the JENKINS_HOME directory so it should remember all your settings and jobs J







Set up logrotate


I have a potential problem… 

The log file /10x13/logs/tomcat8/catalina.out
Will always grow bigger and never rotates out.  This could eat up too much disk space eventually.

Now since this machine is only a Jenkins box there probably won't be a really bit build up here.  But better safe than sorry.


Let's set up a logrotate


> sudo vi /etc/logrotate.d/tomcat


And add the following to the end


#Logrotate for Tomcat catalina.out logs
/10x13/logs/tomcat8/catalina.out {
    copytruncate 
    dateext
    dateformat %Y-%m-%d.
    extension out
    daily
    missingok
    rotate 30
    create 640 tomcat tomcat
}





This will rotate the catalina.out file and keep 30 days worth of logs around.  See http://wiki.apache.org/tomcat/FAQ/Logging#Q10 [15]

No need to restart anything next time cron calls logrotate it will read the updated file.



To test and make sure your logrotate file is OK run the following command


> sudo logrotate -d /etc/logrotate.conf




Looks good!


To see what logs have been rotated you can check /var/lib/logrotate/satus


> cat /var/lib/logrotate/status








After a few days here are my log files being rotated just fine J





Connect VisualVM


Just a last check… I want to make sure VisualVM can connect to tomcat just in case I need to debug it in the future.

To download the VisualVM head over to https://visualvm.java.net/ [16]




Click on Download





Download the Zip file (Windows) or the .dmg file (OS X)

Unzip it and go into the bin directory





Open up visualvm.exe






Click Run






From the menu bar select File -> Add JMX connection







Enter your tomcat server IP address with the port it is using for jmx

If you look at my setup you will see



Dcom.sun.management.jmxremote.port=9090"


It's listening on port 9090

Click OK





It should now display the remote server.


Double Click on it





Wahoo!  Now you know you can connect up to it to debug CPU and Memory issues.


That is it for this very long winded tutorial on Installing and setting up Jenkins on Tomcat8 on an Ubuntu 14.04 server.



References

[1]        How To Install Apache Tomcat 8 on Ubuntu 14.04
                Accessed 07/2015
[2]        Filesystem Hierarchy Standard
                Accessed 07/2015
[3]        Apache Tomcat 8 Download page
                Accessed 07/2015
[4]        Apache Tomcat 8 init script  valotas
                Accessed 07/2015
[5]        Apache Tomcat 8 init script rodolfo42
                Accessed 07/2015
[6]        Apache Tomcat 8 init script agorman
                Accessed 07/2015
[7]        Tomcat setenv.sh
                Accessed 07/2015
[8]        Tomcat setenv.sh         https://gist.github.com/hardyoyo/bad36a161e2b63e333d2
                Accessed 07/2015
[9]        Visualising Garbage Collection in the JVM     
            https://redstack.wordpress.com/2011/01/06/visualising-garbage-collection-in-the-jvm/
                Accessed 07/2015
[10]      Understanding Java Garbage Collection          https://gist.github.com/hardyoyo/bad36a161e2b63e333d2
                Accessed 07/2015
[11]      Apache Tomcat Native Library
            http://tomcat.apache.org/native-doc/
                Accessed 07/2015
[12]      Manager App HOW-TO
                Accessed 07/2015
[13]      tomcat config for jenkins
                Accessed 07/2015
[14]      Jenkins Matrix-based security
                Accessed 07/2015
[15]      How do I rotate catalina.out?
                Accessed 07/2015
[16]      VisualVM
            https://visualvm.java.net/
                Accessed 08/2015


1 comment:

  1. Awesome!! You got the best article on this topic. You're doing a great job.
    Thanks for sharing.
    http://www.flowerbrackets.com/java-garbage-collection/

    ReplyDelete