Automated Tomcat Management

1,118 views

Published on

How do you face Tomcat management issues in the deployment scenarios? Tomcat Control Center combined with Chef automation can help.

Published in: Internet
  • Be the first to comment

Automated Tomcat Management

  1. 1. (AUTOMATED) TOMCAT MANAGEMENT @ladislavGazo gazo@seges.sk
  2. 2. TOMCAT
  3. 3. STRUCTURE bincontrolscripts lib common libraries webappinstance context logs ...
  4. 4. PROBLEM? NO for development (or simple cases)
  5. 5. ADMIN'S PERSPECTIVE multiple servers multiple instances on aserver clustered environment Tomcat's lack of admin tools notwillingto payfor tcServer
  6. 6. TEMPLATE: common logging common libraries common resource naming(JNDI) VS. INSTANCE: custom WAR because of differentversions custom logs specific resources (e.g. in JNDI) various apps deployed on one server
  7. 7. getthe PID ENDLESS KILLING /opt/tomcat/bin/shutdown.sh thoughtitis killed :( psaux|grepcatal once itis fine but... even in DEVitis boring kill-9<da_PID> cd../logs mv*/mnt/backup/logs cd../bin ./startup.sh
  8. 8. ... AND WE FACED SUCH ISSUES
  9. 9. TOMCAT CONTROL CENTER
  10. 10. HTTPS://GITHUB.COM/SEGES/TOMCAT- CONTROL-CENTER
  11. 11. WHAT IS IT?
  12. 12. CONCEPT TEMPLATE and (MULTIPLE) INSTANCE(S) controlled from SINGLE POINT
  13. 13. [SMALL] SET OF SCRIPTS start (start_secured) stop_force restart_force backup_logs_restart_force status export_instance_info control-instances
  14. 14. CENTRAL RESOURCE CONTROL TomcatResources.py automaticallyupdates server.conf JNDI for each instance usingcentralCSVfiles setenv resource-db resource-mail resource-env resource-rmi ...
  15. 15. OH GOSH, CSV FILES? Yeah! ... and yeah!again, I can manage itin Excel:p
  16. 16. PROS lightweightand simple separate template and instances centralmanagement CONS so far onlyon BASH-enabled systems no Docker supportyet:) (notactuallyaminus) no GUI
  17. 17. HTTPS://GITHUB.COM/SEGES/CHEF- COOKBOOK-TCC
  18. 18. INSTALLS TCC PREPARES TEMPLATE(S) PREPARES INSTANCE(S) ENV (CAN) MONITOR WITH NEWRELIC
  19. 19. ... WISDOM ...
  20. 20. AUTOMATED TCC cd~/chef gitsubmoduleaddhttps://github.com/seges/chef-cookbook-tcc.gitsite-cookbooks/tcc gitsubmoduleaddhttps://github.com/escapestudios-cookbooks/newrelic.gitsite-cookbooks/
  21. 21. CREATE COOKBOOK OR RECIPE knifecookbookcreatemycookie
  22. 22. DEFINE DEFAULT ATTRIBUTES default.tcc.user="lgazo" default.tcc.home="/home/lgazo" default.tcc.location="/home/lgazo/opt/tcc"
  23. 23. DEFINE TCC TOMCAT TEMPLATE WITH DEPENDENCIES default['tcc']['templates']={ "synapso"=>{ "type"=>"tomcat7", "libs"=>[ { "repo"=>"maven", "artifact_id"=>"org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1" }, { "repo"=>"maven", "artifact_id"=>"com.sun.messaging.mq:imq:4.4" }, { "repo"=>"maven", "artifact_id"=>"javax.mail:mail:1.4.4" }, { "repo"=>"maven", "artifact_id"=>"org.postgresql:postgresql:9.3-1100-jdbc41" } ] } }
  24. 24. FINALLY DEFINE AN INSTANCE default['tcc']['instances']={ "syndev"=>{ "template"=>"synapso", "user"=>"lgazo" } }
  25. 25. AND TELL TCC COOKBOOK TO LOOK FOR TEMPLATES IN OUR COOKBOOK default['tcc']['template_cookbooks']="mycookie"
  26. 26. PREPARE DATABASE IF NEEDED include_recipe"database::postgresql" postgresql_connection_info={ :host =>'localhost', :port =>node['postgresql']['config']['port'], :username=>'postgres', :password=>node['postgresql']['password']['postgres'] } postgresql_database_user"synapso"do connectionpostgresql_connection_info passwordnode.postgresql.password.synapso action:create end postgresql_database"synapso"do connectionpostgresql_connection_info owner"synapso" action:create end postgresql_database"synapsousercancreateDB"do connection postgresql_connection_info sql"alterrole#{node.synapso.user}withcreatedb" action:query end
  27. 27. in aserver you can monitor itdirectly INCLUDE TCC include_recipe"tcc::default" include_recipe"tcc::templates" include_recipe"tcc::instances"<fontcolor="#333333"face="Lato,sans-serif"><spanstyle= </span></font> include_recipe"tcc::newrelic"
  28. 28. AND NOW THE CONFIGURATION OF INSTANCES into templates/default/tcc/templates/synapso/conf defaultenvironmentis named “_default” context.xml(incurrentversionitisnotChefenvironmentspecific) jmx.properties(incurrentversionitisnotChefenvironmentspecific) resources- connector.csv db.csv env.csv mail.csv rmi.csv setenv.csv
  29. 29. TCC MONITORING JMX portand access configured in: jmx.properties and setenv.csv NEWRELIC includerecipetcc::newrelic
  30. 30. QUESTIONS? @ladislavGazo gazo@seges.sk
  31. 31. THANK YOU... FOR... ATTENTION

×