Monday, July 27, 2009

liferay-clustering

Running Liferay in a clustered environment consists of 6 steps.

1. Preparations and getting things ready.
2. Connecting to a remote MySQL database.
3. Running 2 or More "IDENTICAL" Liferay tomcat instances on 2 Or more physical machines.
4. Making one machine as "Apache Web Server"
5. Connecting apache with tomcat using apache module "mod_jk"
6. Configuring mod_jk for clustering for both load-balancing and fail-over.
7. Verifying whether clustering is working fine.

=================================================================================

1. Preparations and getting things ready.

Select 4 physical machines (servers) in your LAN network. Each should have an internal IP address.

Just ping between the 4 machines and confirm that the pinging is successful.

Make sure none of the machines have fire wall running.

1 machine we'll use as Database server (Either windows or Linux) on which MySQL is installed and running
2 machines will be made as clustered servers on which identical verions of liferay is up running.
1 machine will be the apache http server which will be exposed to the outside world. Let this be a windows machine.
In the later part of this exercise we'll see how to run apache on a Linux server.

Note down the IP address of IP addresses of all four machines.

Machine 1 (MySQL) - [IP Address 1]
Machine 2-a (Liferay 1) - [IP Address 2]
Machine 2-b (Liferay 2) - [IP Address 3]
Machine 3 (Apache server with mod_jk) [IP Address 4]

----------------------------------------------------------------------------------------------
2. Connecting to a remote MySQL database.
----------------------------------------------------------------------------------------------

On the machine where mysql is running, open mysql prompt by typing "mysql -u root -proot mysql" from the command window.

Run these following scripts. Before running dont forget to modify the [IP Address X].

create database lportal2 character set utf8;

-- Giving access to the first Liferay machine (2-a)
---------------------------------------------------

insert into db (
Host
,Db
,User
,Select_priv
,Insert_priv
,Update_priv
,Delete_priv
,Create_priv
,Drop_priv
,Grant_priv
,References_priv
,Index_priv
,Alter_priv
,Create_tmp_table_priv
,Lock_tables_priv
,Create_view_priv
,Show_view_priv
,Create_routine_priv
,Alter_routine_priv
,Execute_priv
)
values (
"[IP Address 2]"
,"lportal2"
,"root"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"N"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"N"
,"N"
);

GRANT ALL ON lportal2.* TO root@'[IP Address 2]' IDENTIFIED BY 'root';

-- Giving access to the second Liferay machine (2-b)
-- --------------------------------------------------

insert into db (
Host
,Db
,User
,Select_priv
,Insert_priv
,Update_priv
,Delete_priv
,Create_priv
,Drop_priv
,Grant_priv
,References_priv
,Index_priv
,Alter_priv
,Create_tmp_table_priv
,Lock_tables_priv
,Create_view_priv
,Show_view_priv
,Create_routine_priv
,Alter_routine_priv
,Execute_priv
)
values (
"[IP Address 3]"
,"lportal2"
,"root"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"N"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"Y"
,"N"
,"N"
);

GRANT ALL ON lportal2.* TO root@'[IP Address 3]' IDENTIFIED BY 'root';

Important:

Once you have run the above scripts, pls dont forget to restart your MySQL.

Verification:

Now open the command window in the 2 machines where liferay is running and enter the command,

mysql -h [IP Address 1] -u root -proot lportal2;

This should successully get entry to the mysql prompt.

Do the similar thing on the other machine where Liferay is running and confirm that is it also connecting to
the remote Mysql database server.

1 comment :

Anonymous said...

Good Post Arun.