How to install and configure a Liferay cluster
This article is the second part from a serie of 2 articles about glassfish and liferay. I hope you will find this articles very useful. First article is here.
1. Be sure you have the DNS configuration working properly (or /etc/hosts)
2. Install a glassfish cluster (http://random-byte.blogspot.com/2008/08/how-to-install-and-configure-glassfish.html)
3. If you have some errors about jdbc\__TimePool (a bug in glassfish) when you are trying to set the target on the cluster just create another JDBC resource with a another name with the target on cluster (Read first part about his error: http://randombugs.wordpress.com/2008/08/26/how-to-install-and-configure-a-glassfish-cluster/)
4. Before deploying the Glassfish just get all the libs from liferay-dependeciens.zip (http://downloads.sourceforge.net/lportal/liferay-portal-dependencies-5.1.1.zip) and upload them on node0 domains/domain1/lib (unziped of-course)
5. Create a mysql database named lportal and set access and a password for it. After that just upload the create-mysql.sql file from http://downloads.sourceforge.net/lportal/liferay-portal-sql-5.1.1.zip
Glassfish cluster creation for Liferay:
lray@node0:~/glassfish$ asadmin create-node-agent –host node0 –port 4848 lr-agent-0
lray@node0:~/glassfish$ asadmin create-cluster –host node0 –port 4848 lr-cluster
lray@node0:~/glassfish$ asadmin create-instance –host node0 –port 4848 –nodeagent lr-agent-0 –cluster lr-cluster lr-instance-0
lray@node0:~/glassfish$ asadmin start-node-agent –syncinstances=true lr-agent-0
Add a new node on cluster:
lray@node1:~/glassfish$ asadmin create-node-agent –host node0 –port 4848 lr-agent-1
lray@node1:~/glassfish$ asadmin create-instance –host node0 –port 4848 –nodeagent lr-agent-1 –cluster lr-cluster lr-instance-1
lray@node1:~/glassfish$ asadmin start-node-agent –syncinstances=true lr-agent-1
Create LiferayPool database resource :
1. Go in Resources Menu in JDBC->Connection Pools, select Create New JDBC Connection Pool.
2. In the first screen, give it a name of LiferayPool, a Resource Type of javax.sql.ConnectionPoolDataSource, and select MySQL as the Database Vendor.
3. Click Next.
4. On the next page, scroll down to the Additional Properties section. Find the property called URL, and set its value to:
(if you have the mysql database on other server just replace localhost with your server)
5. Click Add Property, and add a property called user with a value of the user name to connect to the database.
6. Click Add Property again, and add a property called password with a value of the password to connect to the database.
7. Click Finish.
Now go on LiferayPool and try to ping the database.
I tried this with the latest version of mysql conector mysql-connector-java-5.1.6 and it seems is not working. Personally I get the connector from the bundle Glassfish-Liferay package and I put it on domains/domain1/lib
Create JavaMail Resource:
1. Under Resources, click JavaMail Sessions.
2. Click New.
3. Give the JavaMail Session a JNDI name of mail/MailSession, and fill out the rest of the form with the appropriate information for your mail server.
4. Click OK
Now just login on node0:4848 (http://node0:4848/) and on Cluster-> lr-cluster -> Applications -> Deploy to deploy your liferay-portal-5.1.1.war. Set the context to /, check availability and precompile jsp. (Deployment can’t take serveral good minutes on a good machine)
After a successfully deployment stop all the nodes.
Edit in /home/lray/liferay/jackrabbit/repository.xml and remove all cluster commented out code and comment the single instance code. Also set the url, user and password for mysql here !
Create a new file in domains/domain1/applications/j2ee-modules/liferay-portal/WEB-INF/classes named portal-ext.properties with the following content:
Start all nodes again.
You probably will get some errors about mysql and lucene server, but this errors are stoping after you just start to browse the LifeRay Portal.
When you start the node-agent with option –syncinstances=true probably you will get a OutOfMemory error. Try increasing the heap for that instance (and the same for the rest of instance deployments) in this way:
asadmin set domain.node-agent.nodeX.property.INSTANCE-SYNC-JVM-OPTIONS=”-Xmx256m”
where, in our case, nodeX is node0 or node1
You can do that only from node0 and not from other nodes.
Now it should be up and running, try to access it on http://node0:38080 and http://node1:38080
Good Luck !