Alfresco Performance tuning by setting JVM memory parameters

Since last couple of days I was working on Alfresco's JVM tuning. I faced below issues when it was configured previously.
  • OldGen space was utilized completely
  • Per Survivor Space was too utilized completely
  • Full GC was taking time which leads to stop application responding for time being
My previous JVM settings were as given below:

export JAVA_OPTS="-Xms2048m -Xmx4096m -Xss1024k -XX:MaxPermSize=512m -XX:NewSize=1024m -XX:+UseConcMarkSweepGC -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djava.awt.headless=true -Dalfresco.home=/opt/alfresco4 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dsun.security.ssl.allowUnsafeRenegotiation=true -Djava.net.preferIPv4Stack=true"

After making changes in few parameters, I got below settings which works perfectly fine. I had to increase memory allocation and tune other parameters.

export JAVA_OPTS="-Xms4096m -Xmx8192m -XX:MaxPermSize=512m -XX:NewSize=3072m -XX:+UseConcMarkSweepGC -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djava.awt.headless=true -Dalfresco.home=/opt/alfresco4 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dsun.security.ssl.allowUnsafeRenegotiation=true -Djava.net.preferIPv4Stack=true"

I have taken screenshot from VisualVM.

Heap Memory and CPU Usage:

OldGen and Eden Space usage:


Linux Terminal Shortcuts

Writing long commands every time becomes tedious and time consuming too. Here I am going to list down some shortcuts which will help you to save time while using Linux terminal.

Ctrl+left & Ctrl+right

Hitting Ctrl and the left or right arrow keys jumps between arguments in your command. So, if you had a typo in the middle of the command, you could jump to it quickly with Ctrl and a few taps of the left arrow key.

Tab

This shortcut key is often used. When using bash you need to just type few characters and then pressing tab will auto complete command or file/directory name.

Ctrl + U or Ctrl + C
This shortcut will clear command written on shell.

Ctrl + R
This command also most often used. When you hit Ctrl plus R it will open up history, as you type character it will display all previous command matches with character you typed.

If you want to go through all command one by one which matches with the character you entered then press Ctrl + Shift + R.

Alt + BackSpace

This shortcut will remove the word from its current position.

!
This shortcut also used to repeat previous command. Instead of pressing Ctrl + R, you can type ! then characters to repeat from history.

You can see in below image. If I want to run "pkill skype", I have written "!pk" and the hit enter. This will run "pkill skype" command.



Microsoft SQL Server 2008 Database Mirroring

Scenario:

We have below two server's details. Both servers are in workgroup. Need to setup database mirroring using certificate based authentication. This is going to be Active-Passive mirroring. So at a time only one server(Active) server will serve Database, another DB server(passive) will not be usable as it will be in synchronization stat.

The Active DB server will be called as “Principal” server and Passive DB server will be called as “Mirror” server.

DB Servers:
Active DB IP: 10.36.100.54
Passive DB IP: 10.36.100.53
DB name: liferayprod

Prerequisites
Keep port 5022 open between two Database servers

Database Backup and Restore Procedure
(1) First take Database backup from Principal server. Follow below steps to take database backup.

(2) Select “Backup Type” full and click on Ok button.
(3) Now we need to backup transaction logs.

(4) Now go to location where you have backup database. Copy liferayprod.bak file from that location to Mirror Database.
(5) Now perform below steps on Mirror database to restore database.
(6) Create database, give name “Liferayprod”. Now do right click on that database, click on Task-> Restore → Database.
(7) Now locate database file. Do check mark as shown in figure.
(8) Now click on “Options”. Select below two options as shown in figure. Click on “Ok” button.
(9) Once restore complete, you will see database's status as shown in below figure.

Database Mirroring Queries on Principal and Mirror server

Perform below steps on Principal server:

On Active server open Query browser and fire below queries one by one. Follow the instructions given 


Before running below query create c:\certificate directory in server. If required, need to give full permission to "Everyone".

Before running below query, copy mirror server's certificate from mirror server to principal server's c:\certificate directory. 


Now wait for 10 mins before applying below query. As first time it takes time to synchronization.


Perform below steps in Mirror server:

On Passive server open Query browser and fire below queries one by one. 
Before running below query create c:\certificate directory in server. If required, need to give full permission to "Everyone".



Before running below query, copy  Principal server's certificate from principal server to mirror server's c:\certificate directory. 



Now wait for 10 mins before applying below query. As first time it takes time to synchronization.


Varify Mirroring Status

(1) Once you run queries for mirroring, DB mirroring should be started. On the mirror server you should see below mentioned status.
(2) At the principal server, you should be able to see below mentioned status.
(3) We can check mirroring status as shown in below figure. Right click on Database → Tasks → Launch Database mirroring Monitor.

Manual Failover

If you want to do manual Failover then use below query. Which will make Principal database as Mirror Database and Mirror Database->Principal database.


You will need to do manual Fail over when both databases are not connected with each other. There could be the reason like, database server it self is down or may be blocked port. So in that case you can remove database server's mirroring function. Then database will act like standalone database server. Later on you can configure mirroring once you are able to fix connectivity issue. You can use below command to remove database from mirroring.


To bring the mirror online manually after dropping mirroring, issue the following command (you can’t do it while it is still mirrored).




Note: At the time of reconfiguration, you may need to delete “master key” and endpoint through below query.

→ On Mirror server follow below steps.


→ On principal Server follow below steps.