(Automated) Tomcat Management
@ladislavGazo
gazo@seges.sk
Tomcat
Structure
-
bin control scripts
- lib common libraries
- webapp instance context
- logs ...
Problem?
NO
for development
(or simple cases)
Admin's Perspective
- multiple servers
- multiple instances on a server
- clustered environment
- Tomcat's lack of admin tools
- not willing to pay for tcServer
Template:
- common logging
- common libraries
- common resource naming (JNDI)
vs.
Instance:
- custom WAR
- because of different versions
- custom logs
- specific resources (e.g. in JNDI)
- various apps deployed on one server
endless killing
/opt/tomcat/bin/shutdown.sh
thought it is killed :(
ps aux | grep catal
kill -9 <da_PID>
cd ../logs
mv * /mnt/backup/logs
cd ../bin
./startup.sh
once it is fine but... even in DEV it is boring
... and we faced such issues
Tomcat Control Center
https://github.com/seges/tomcat-control-center
What is it?
Concept
Template
and
(multiple) instance(s)
controlled from
Single point
[small] set of scripts
start
(start_secured)
stop_force
restart_force
backup_logs_restart_force
status
export_instance_info
control-instances
Central resource control
TomcatResources.py
automatically updates server.conf JNDI for each instance
using central CSV files
setenv
resource-db
resource-mail
resource-env
resource-rmi
...
oh gosh, CSV files?
Yeah!
... and yeah! again, I can manage it in Excel :p
Pros
- lightweight and simple
- separate template and instances
- central management
Cons
- so far only on BASH-enabled systems
- no Docker support yet :)
- (not actually a minus) no GUI
https://github.com/seges/chef-cookbook-tcc
Installs TCC
Prepares Template(s)
prepares Instance(s) Env
(can) monitor with NewRelic
... wisdom ...
Automated TCC
cd ~/chef
git submodule add https://github.com/seges/chef-cookbook-tcc.git site-cookbooks/tcc
git submodule add https://github.com/escapestudios-cookbooks/newrelic.git site-cookbooks/newrelic
create cookbook or recipe
knife cookbook create mycookie
define default attributes
default.tcc.user = "lgazo"
default.tcc.home = "/home/lgazo"
default.tcc.location = "/home/lgazo/opt/tcc"
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"
}
]
}
}
finally define an instance
default['tcc']['instances'] = {
"syndev" => {
"template" => "synapso",
"user" => "lgazo"
}
}
and tell TCC cookbook to look for templates in our cookbook
default['tcc']['template_cookbooks'] = "mycookie"
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
connection postgresql_connection_info
password node.postgresql.password.synapso
action :create
end
postgresql_database "synapso" do
connection postgresql_connection_info
owner "synapso"
action :create
end
postgresql_database "synapso user can create DB" do
connection postgresql_connection_info
sql "alter role #{node.synapso.user} with createdb"
action :query
end
Include TCC
include_recipe "tcc::default"
include_recipe "tcc::templates"
include_recipe "tcc::instances"
include_recipe "tcc::newrelic"
And now the configuration of instances
into templates/default/tcc/templates/synapso/conf
default environment is named “_default”
- context.xml (in current version it is not Chef environment specific)
- jmx.properties (in current version it is not Chef environment specific)
- resources-
- connector.csv
- db.csv
- env.csv
- mail.csv
- rmi.csv
- setenv.csv
TCC monitoring
JMX
port and access configured in:
- jmx.properties and
- setenv.csv
NewRelic
include recipe tcc::newrelic
Questions?
@ladislavGazo
gazo@seges.sk
Thank YOu... for...
ATTENTION
Automated Tomcat Management
By lgazo
Automated Tomcat Management
How do you face Tomcat management issues in the deployment scenarios? Tomcat Control Center combined with Chef automation can help.
- 883