Установка Oracle GlassFish 4.1

Качаем:

wget http://dlc.sun.com.edgesuite.net/glassfish/4.1/release/glassfish-4.1.zip

cd /usr/local
unzip glassfish-4.1.zip

Выставим владельца и группу, под которыми будет работать gf

chown -R user.Users glassfish4


Стартуем GF
cd /usr/local/glassfish4/bin/;
./asadmin start-domain domain1

Задаем пароль, т.к. по-умолчанию пустой
./asadmin change-admin-password

Разрешаем https
./asadmin enable-secure-admin

Для применения изменений, рестартанем домен
./asadmin restart-domain domain1

Создаем domain2
./asadmin create-domain --adminport 59649 domain2

./asadmin --port 59649 enable-secure-admin



# ставим JDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html

rpm -Uv jdk-7u9-linux-x64.rpm

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
/usr/sbin/alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000
/usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
/usr/sbin/alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000

# правим окружение
$ cat /etc/environment
JAVA_HOME=/usr/java/latest
export JAVA_HOME

# export DAS certificate
keytool -export -rfc -alias s1as -keystore /opt/glassfish3/glassfish/domains/domain1/config/keystore.jks -file /opt/glassfish.crt -storepass changeit


1. добавляем репу nginx

rpm -Uhv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

2. ставим

yum install -y nginx

3. Создаем /etc/nginx/conf.d/gf.conf
===
server {
    listen 80;
    #access_log  /var/log/nginx/host.access.log  main;

    #root /opt/glassfish3/glassfish/domains/domain1/applications/hello;
    #index index.jsp;

location / {
    proxy_pass http://my_cluster;
}

location /hello/ {
    proxy_pass http://my_cluster;
    proxy_redirect  http://my_cluster http://localhost/hello/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

upstream my_cluster {
    ip_hash;

    server 172.21.10.229:28080 weight=3 max_fails=5 fail_timeout=15s;
    server 172.21.10.231:28080 weight=2 max_fails=5 fail_timeout=5s;
    server 172.21.10.232:28080 weight=1 max_fails=5 fail_timeout=5s;
}
===

4. sudo /etc/init.d/nginx start

5. качаем GF opensource edition
wget http://dlc.sun.com.edgesuite.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip
unzip glassfish-3.1.2.2.zip

6. создаем кластер
cd /home/glassfish/glassfish3/bin
./asadmin create-domain ClusterDAS
cd ../glassfish/domains/ClusterDAS/config/
keytool -delete -alias gtecybertrust5ca -keystore cacerts.jks
cd /opt/glassfish-3.1.2.2/bin/
./asadmin start-domain ClusterDAS




cd /opt/glassfish-3.1.2.2/bin/
./asadmin create-domain ClusterDAS
cd ../glassfish/domains/ClusterDAS/config/
keytool -delete -alias gtecybertrust5ca -keystore cacerts.jks
cd /opt/glassfish-3.1.2.2/bin/
./asadmin start-domain ClusterDAS
##test using admin port and browser
##slim/trim down ClusterDAS
./asadmin delete-http-listener http-listener-1
./asadmin delete-http-listener http-listener-2
./asadmin delete-virtual-server server



cd /opt/glassfish3/glassfish/domains/domain1/config
/usr/java/jdk1.7.0_60/bin/keytool -delete -alias gtecybertrust5ca -keystore cacerts.jks -storepass changeit



cd /opt/glassfish3/bin/
./asadmin setup-ssh 172.21.10.231
./asadmin setup-ssh 172.21.10.232
./asadmin install-node --installdir /opt/glassfish3/ 172.21.10.231
./asadmin install-node --installdir /opt/glassfish3/ 172.21.10.232
./asadmin start-domain domain1
./asadmin enable-secure-admin
./asadmin --user admin change-admin-password
./asadmin restart-domain domain1
./asadmin create-cluster mycluster
./asadmin create-node-ssh --nodehost 172.21.10.231 --installdir /opt/glassfish3 node01
./asadmin create-node-ssh --nodehost 172.21.10.232 --installdir /opt/glassfish3 node02
./asadmin create-instance --node node01 --cluster mycluster n01-i01
./asadmin create-instance --node node02 --cluster mycluster n02-i01
./asadmin create-local-instance --cluster mycluster n00-i01
./asadmin start-cluster mycluster

Приложения для деплоя:
https://glassfish.dev.java.net/downloads/quickstart/hello.war

Работа с кластером
==================
./asadmin start-cluster mycluster
./asadmin stop-cluster mycluster

Работа с инстансами
===================
./asadmin start-instance n01-i01
./asadmin stop-instance n01-i01
./asadmin restart-instance n01-i01



JMS Cluster MQ
==============

./asadmin delete-jms-host default_JMS_host
./asadmin delete-jms-host --target mycluster default_JMS_host
./asadmin create-jms-host --target mycluster --mqhost centos-test1 --mqport 6769 --mquser admin --mqpassword admin broker1
./asadmin create-jms-host --target mycluster --mqhost centos-test2 --mqport 6770 --mquser admin --mqpassword admin broker2
./asadmin create-jms-host --target mycluster --mqhost centos-test3 --mqport 6771 --mquser admin --mqpassword admin broker3

/opt/glassfish3/mq/bin/imqbrokerd
change:
_def_jvm_args="-Xms192m -Xmx192m -Xss256k"

/opt/glassfish3/mq/bin/imqbrokerd -tty -name brokerm -port 6772 -cluster centos-test1:6769,centos-test2:6770,centos-test2:6772,centos-test3:6771 -D"imq.cluster.masterbroker=centos-test2:6772"

./asadmin create-jms-resource --target mycluster --restype javax.jms.QueueConnectionFactory jms/MyQcf1
./asadmin create-jms-resource --target mycluster --restype javax.jms.Queue --property imqDestinationName=MyQueue1 jms/MyQueue1

Создать JMS Physical destination
==========================

./asadmin create-jmsdest --desttype queue --property maxNumMsgs=20000:maxBytesPerMsg=5k:limitBehavior=REMOVE_OLDEST:maxNumProducers=100:localDeliveryPreferred=true:validateXMLSchemaEnabled=true PhysicalQueue


connection failover
===================