Skip to content

Instantly share code, notes, and snippets.

@koduki
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koduki/17925c040b97fd2c59ce to your computer and use it in GitHub Desktop.
Save koduki/17925c040b97fd2c59ce to your computer and use it in GitHub Desktop.
How to create Glassfish Cluster with CLI(asadmin)

Prepare

  • Install Glassfish on AdminServer(172.17.0.5)
  • Create 'glassfish' user on ManagedServer(172.17.0.6)
  • Create 'glassfish:glassfish /opt/glassfish4' directory on ManagedServer(172.17.0.6)
  • Change SSH public key

Create Cluster

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-cluster sampleCluster01

Create Node Instance

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 install-node --installdir /opt/glassfish4 --sshuser glassfish 172.17.0.6
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-node-ssh --nodehost '172.17.0.6' --sshuser glassfish --installdir '/opt/glassfish4' node01-agent
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-instance --node node01-agent --cluster sampleCluster01 managed-server01

Modify JVM Options

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 delete-jvm-options --target sampleCluster02 "-XX\:MaxPermSize=192m"
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-jvm-options --target sampleCluster02 "-XX\:MaxPermSize=1024m"

Create JDBC

USER_NAME=docker
PASSWORD=password
URL='jdbc\:mysql\://db\:3306/testdb'
RESOURCE_NAME=jdbc/testdb
POOL_NAME=MySQLPool
DATASOURCE_NAME=com.mysql.jdbc.jdbc2.optional.MysqlDataSource

./asadmin start-domain
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-jdbc-connection-pool \
          --datasourceclassname ${DATASOURCE_NAME} --restype javax.sql.DataSource \
          --property user=${USER_NAME}:password=${PASSWORD}:url=${URL} ${POOL_NAME}

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 create-jdbc-resource \
          --connectionpoolid ${POOL_NAME} ${RESOURCE_NAME}

Modify Max HTTP Tread Pool Size

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 get 'configs.config.sampleCluster01-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=50'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 get 'configs.config.sampleCluster01-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size'

Modify HTTP Access Log

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.http-service.access-logging-enabled=true'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.http-service.access-log.write-interval-seconds=1'

Modify Monitoring Service

./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.jvm=LOW'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.thread-pool=LOW'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.jdbc-connection-pool=LOW'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.transaction-service=LOW'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 set 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.web-container=LOW'
./asadmin --user admin --passwordfile=pwdfile -I false --port 4848 get 'configs.config.sampleCluster01-config.monitoring-service.module-monitoring-levels.*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment