This tutorial will guide you through a GlassFish 2.1.1 Cluster with two instances on the same machine. We are going to use the CLI interface to make our life simpler.
[Whenever you encounter the \ symbol in one of the commands, it means that the command continues on the following line. So you have to copy both lines (including the \ symbol) at your terminal.]
After a successful installation of glassfish with cluster profile (setup-cluster.xml), as explained on the download page:
https://glassfish.dev.java.net/downloads/v2.1.1-final.html
Go to directory ${GF_HOME}/bin and delete default domain domain1 (or you can just ignore it).
asadmin delete-domain domain1
and create a new domain with adminport 4000, name das :
asadmin create-domain --adminport 4000 --profile cluster das
Use the following credentials (or your own, just make sure to make the changes on the password file later on)
Admin user : admin
Admin pass : admin111
Master pass : admin111
We are going to use a password file inside ${GF_HOME}/bin in order to make the steps quicker with the following three lines :
AS_ADMIN_ADMINPASSWORD=admin111
AS_ADMIN_PASSWORD=admin111
AS_ADMIN_MASTERPASSWORD=admin111
You should better change the file preferences so that no one else can view this file except the GF admin:
chmod 600 passwords
First step is to start the new domain:
asadmin start-domain --user admin --passwordfile passwords das
Create the first node agent, connecting on DAS at 4000 port, (and then start it):
asadmin create-node-agent --user admin --port 4000 \
--passwordfile passwords agent1
asadmin start-node-agent --user admin --passwordfile passwords agent1
Create the cluster farm named cl1 (connecting on DAS at 4000 port) that will group both of the clustered instances:
asadmin create-cluster --user admin --passwordfile passwords \
--port 4000 cl1
Create the first instance (gf1 on http port 9080) and the second instance (gf2 on http port 9090) that communicate to the domain (DAS on port 4000) through the node agent (agent1) and reference our cluster (cl1):
asadmin create-instance --user admin --passwordfile passwords \
--port 4000 --nodeagent agent1 --systemproperties \
HTTP_LISTENER_PORT=9080 --cluster cl1 gf1
and
asadmin create-instance --user admin --passwordfile passwords \
--port 4000 --nodeagent agent1 --systemproperties \
HTTP_LISTENER_PORT=9090 --cluster cl1 gf2
Last step is to start the cluster and the instances with the following command:
asadmin start-cluster --user admin --port 4000 \
--passwordfile passwords cl1
Now when you point your browser to http://localhost:4000/ and login as admin/admin111 you will see on your left the "Clusters" Task, with cl1 child. And cl1 will have two children gf1 and gf2. To deploy an application to the cluster, all you need to do is remove the target "server" and add the target "cl1" (either at deployment or after deployment).
You will also see the "Node Agents" Task that has the agent1 node agent.
Here are the startup commands :
asadmin start-domain --user admin --passwordfile passwords das
asadmin start-node-agent --user admin --passwordfile passwords agent1
asadmin start-cluster --port 4000 --passwordfile passwords cl1
and the shutdown commands:
asadmin stop-cluster --user admin --passwordfile passwords cl1
asadmin stop-node-agent agent1
asadmin stop-domain das
p.s.
Here are all the commands one after another in order to run them as a script:
[Whenever you encounter the \ symbol in one of the commands, it means that the command continues on the following line. So you have to copy both lines (including the \ symbol) at your terminal.]
After a successful installation of glassfish with cluster profile (setup-cluster.xml), as explained on the download page:
https://glassfish.dev.java.net/downloads/v2.1.1-final.html
Go to directory ${GF_HOME}/bin and delete default domain domain1 (or you can just ignore it).
asadmin delete-domain domain1
and create a new domain with adminport 4000, name das :
asadmin create-domain --adminport 4000 --profile cluster das
Use the following credentials (or your own, just make sure to make the changes on the password file later on)
Admin user : admin
Admin pass : admin111
Master pass : admin111
We are going to use a password file inside ${GF_HOME}/bin in order to make the steps quicker with the following three lines :
AS_ADMIN_ADMINPASSWORD=admin111
AS_ADMIN_PASSWORD=admin111
AS_ADMIN_MASTERPASSWORD=admin111
You should better change the file preferences so that no one else can view this file except the GF admin:
chmod 600 passwords
First step is to start the new domain:
asadmin start-domain --user admin --passwordfile passwords das
Create the first node agent, connecting on DAS at 4000 port, (and then start it):
asadmin create-node-agent --user admin --port 4000 \
--passwordfile passwords agent1
asadmin start-node-agent --user admin --passwordfile passwords agent1
Create the cluster farm named cl1 (connecting on DAS at 4000 port) that will group both of the clustered instances:
asadmin create-cluster --user admin --passwordfile passwords \
--port 4000 cl1
Create the first instance (gf1 on http port 9080) and the second instance (gf2 on http port 9090) that communicate to the domain (DAS on port 4000) through the node agent (agent1) and reference our cluster (cl1):
asadmin create-instance --user admin --passwordfile passwords \
--port 4000 --nodeagent agent1 --systemproperties \
HTTP_LISTENER_PORT=9080 --cluster cl1 gf1
and
asadmin create-instance --user admin --passwordfile passwords \
--port 4000 --nodeagent agent1 --systemproperties \
HTTP_LISTENER_PORT=9090 --cluster cl1 gf2
Last step is to start the cluster and the instances with the following command:
asadmin start-cluster --user admin --port 4000 \
--passwordfile passwords cl1
Now when you point your browser to http://localhost:4000/ and login as admin/admin111 you will see on your left the "Clusters" Task, with cl1 child. And cl1 will have two children gf1 and gf2. To deploy an application to the cluster, all you need to do is remove the target "server" and add the target "cl1" (either at deployment or after deployment).
You will also see the "Node Agents" Task that has the agent1 node agent.
Here are the startup commands :
asadmin start-domain --user admin --passwordfile passwords das
asadmin start-node-agent --user admin --passwordfile passwords agent1
asadmin start-cluster --port 4000 --passwordfile passwords cl1
and the shutdown commands:
asadmin stop-cluster --user admin --passwordfile passwords cl1
asadmin stop-node-agent agent1
asadmin stop-domain das
p.s.
Here are all the commands one after another in order to run them as a script:
asadmin create-node-agent --user admin --port 4000 --passwordfile passwords agent1
asadmin start-node-agent --user admin --passwordfile passwords agent1
asadmin create-cluster --user admin --passwordfile passwords --port 4000 cl1
asadmin create-instance --user admin --passwordfile passwords --port 4000 \
--nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9080 --cluster cl1 gf1
--nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9080 --cluster cl1 gf1
asadmin create-instance --user admin --passwordfile passwords --port 4000 \
--nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9090 --cluster cl1 gf2
--nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9090 --cluster cl1 gf2
asadmin start-cluster --user admin --port 4000 --passwordfile passwords cl1
And the shutdown-delete commands in order to clean up your installation.
asadmin stop-cluster --user admin --passwordfile passwords cl1
asadmin stop-node-agent agent1
asadmin delete-instance --user admin --passwordfile passwords --port 4000 gf1
asadmin delete-instance --user admin --passwordfile passwords --port 4000 gf2
asadmin delete-instance --user admin --passwordfile passwords --port 4000 gf2
asadmin delete-cluster --port 4000 --user admin --passwordfile passwords cl1
asadmin delete-node-agent agent1
asadmin delete-node-agent-config --port 4000 --user admin --passwordfile passwords agent1
asadmin stop-domain das
asadmin delete-domain das
p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.
p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.
No comments:
Post a Comment