Showing posts with label liferay cluster. Show all posts
Showing posts with label liferay cluster. Show all posts

Tuesday, July 27, 2021

Configure Remote Elasticsearch Cluster in Liferay Cluster

Liferay 7.x is using Elasticsearch and it’s embedded in the bundle. When we start Liferay then embedded elastic instance also will start.



Development environments, this embedded search is ok but for production environments we must need external Elasticsearch cluster.

 


If we are building Liferay cluster then all instances should connect with same Elasticsearch cluster. So, we must have some external/remote Elasticsearch.

 


This Article Demonstrate configure the remote Elasticsearch in Liferay.

 


From Liferay DXP 7.3 and CE 7.3 GA4+ Elasticsearch connector is included in the bundle and previous versions are required Elasticsearch Connector which is available in Liferay Market Place.

 


This Demonstration is using Liferay 7.4 GA2, So Elastic connector already included in the latest Liferay portal bundle.

 


Software Stack



 

Elasticsearch-7.13.3

Liferay-ce-portal-7.4.1-ga2

 

 

 


 

Following are the steps to configure the External/Remote Elasticsearch for Liferay.

 


  • Install Elastic Cluster
  • Install Liferay Cluster.
  • Configure Elasticsearch in Liferay

 


 

Install Elastic Cluster

 


Follow the below article to install Elasticsearch Cluster

 


http://www.liferaysavvy.com/2021/07/install-elastic-search-cluster.html

 



Install Liferay Cluster

 


Follow the below article to install Liferay Cluster

 


http://www.liferaysavvy.com/2021/07/liferay-portal-apache-webserver.html



 

Configure Elasticsearch in Liferay

 


There is two ways we can configure Elasticsearch in Liferay.

 


  • From Control Panel
  • Using OSGi config file

 


From Control Panel



Login to Liferay Portal as Administrator. Access Liferay Cluster or Any one the node in the cluster.


 

Access direct Liferay node using Host and Port


Example:


 

http://localhost:8090/

 

 


Global Menu --> Control Panel --> Configuration --> System Settings

 




 



 

 

 

 

System Setting --> Click on Search


 



 

 

Provide ElasticSearch7 Configuration as follows.



Step:1

 


Click on Elasticsearch Connections and Provide Connection Id and Cluster Host names. Click + Button to add multiple Elasticsearch hosts in the cluster.

 


 

http://localhost:9200

 

http://localhost:9201

 

http://localhost:9202

 

 

 


 







 

Save the configuration Elasticsearch connection Id will be created. There are many configuration properties available and based on requirement provide required properties.

 

 



 


 

Step: 2



Click on Elasticsearch7 Settings and Enable Production mode and Select Elasticsearch Connection ID that we already created in the previous step. Save the configuration.

 

 




 


Default search index is liferay-* so we can see in the Elasticsearch that the indexes will be created.


Use below URL to confirm that indexes are created.



 

http://localhost:9200/_cat/indices?v

 

 






Elasticsearch connector configuration is stored in Database So these settings available for all Liferay Nodes in the cluster.

 


Just restart all Liferay Nodes in the cluster so that all Liferay Nodes will be connecting to Remote Elasticsearch cluster and indexes will be created in the Elasticsearch cluster. We can also use Reindex control panel feature to index all search values in Elasticsearch cluster.

 


 

Using OSGi config file

 



We can also use OSGi configuration file option to connect Liferay cluster with Remote Elasticsearch.


Create following configuration files and place in “osgi/config” directory in each Liferay instance.

 

 

Create “com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConnectionConfiguration.config” file and add following properties

 


 

 

active="true"

authenticationEnabled="false"

connectionId="RemoteElasticSearchCluster"

httpSSLEnabled="false"

networkHostAddresses=[ \

  "http://localhost:9200", \

  "http://localhost:9201", \

  "http://localhost:9202", \

  ]

proxyHost=""

proxyPort="0"

proxyUserName=""

truststorePath="/path/to/localhost.p12"

truststoreType="pkcs12"

username="elastic"

 

 

 

 






 


Create “com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config” file and add following properties.


 

additionalConfigurations=""

additionalIndexConfigurations=""

additionalTypeMappings=""

authenticationEnabled="false"

bootstrapMlockAll="false"

clusterName="LiferayElasticsearchCluster"

discoveryZenPingUnicastHostsPort="9300-9400"

embeddedHttpPort="9201"

httpCORSAllowOrigin="/https?:\\/\\/localhost(:[0-9]+)?/"

httpCORSConfigurations=""

httpCORSEnabled="true"

httpSSLEnabled="false"

indexNamePrefix="liferay-"

indexNumberOfReplicas=""

indexNumberOfShards=""

logExceptionsOnly="true"

networkBindHost=""

networkHost=""

networkHostAddresses=[ \

  "", \

  ]

networkPublishHost=""

nodeName=""

operationMode="REMOTE"

overrideTypeMappings=""

productionModeEnabled="true"

proxyHost=""

proxyPort="0"

proxyUserName=""

remoteClusterConnectionId="RemoteElasticSearchCluster"

restClientLoggerLevel="ERROR"

sidecarDebug="false"

sidecarDebugSettings="-agentlib:jdwp\=transport\=dt_socket,address\=8001,server\=y,suspend\=y,quiet\=y"

sidecarHeartbeatInterval="10000"

sidecarHome="elasticsearch7"

sidecarHttpPort=""

sidecarJVMOptions=[ \

  "-Xms1g", \

  "-Xmx1g", \

  "-XX:+AlwaysPreTouch", \

  ]

sidecarShutdownTimeout="10000"

trackTotalHits="true"

transportTcpPort=""

truststorePath="/path/to/localhost.p12"

truststoreType="pkcs12"

username="elastic"

 

 

 


 



 

 


Liferay Node1


 



 

Liferay Node2

 




 

 

 

Once place the configuration files in all Liferay Nodes osgi/config location, Restart all Liferay instances.

 

 

 

 

Author

 

 

Monday, July 26, 2021

Liferay Portal Monitoring with Prometheus and Grafana

Grafana is popular open-source solution for monitoring applications. It will provide graphical dashboards to build monitoring visualization.

 


Any graphical view required data or metrics, so metrics data will be provided by Prometheus.

 


Prometheus is another monitoring tools to pull data from different application with help of JMX Exporter Agent.

 


Grafana is ability to connect Prometheus to pull metrics data and it will be represented as graphical view. We can build nice dashboards to show metrics data in different graphical view in the Grafana web UI.







Prerequisite



Setup a Liferay Cluster



http://www.liferaysavvy.com/2021/07/liferay-portal-apache-webserver.html

 




Following are steps to Demonstrate Liferay Cluster Monitoring.

 


  • Setup Prometheus for Liferay Cluster
  • Install Grafana
  • Configure Prometheus Data source in Grafana
  • Create Liferay Cluster Dashboard

 



Setup Prometheus for Liferay Cluster



Follow the below article to setup Prometheus for Liferay cluster.



http://www.liferaysavvy.com/2021/07/liferay-portal-monitoring-with.html

 


After configured JMX Exporter for Liferay Portal, Start all servers in the cluster.

 




Install Grafana

 


Follow the below article to install Grafana on windows.

 

http://www.liferaysavvy.com/2021/07/grafana-installation-on-windows.html

 




Configure Prometheus Data source in Grafana



Now it’s time to configure Prometheus Data source in Grafana. Prometheus already have metrics data which is pulled from Liferay portal server with help of JMX exporter Java agent. That is already covered in the previous step.

 


Access Grafana Web UI with following URL

 


 

 

http://localhost:3000/

 

 

 


Home page click on Setting and Under Configuration click on “Data sources

 




 

Click on Add Data source.

 





 

Select Prometheus Data source in the List.

 





 

Provide Prometheus URL where its running. Default port is 9090. Once provided required information click on Test &Save.  Grafana successfully connected to Prometheus data source.

 


 

http://localhost:9090/

 

 




 





Create Liferay Cluster Dashboard



Grafana home page click on Dashboard icon and Click on Manage

 




 

There are free available Grafana dashboards for Tomcat. Creating Grafana dashboard is very easy and it’s just need to import Dashboard JSON file.

 


Go to following URL and get Grafana Tomcat dashboard file to local.

 

https://github.com/LiferaySavvy/liferay-monitoring-prometheus/blob/master/tomcat-dashboard_rev10.json

 

 

OR

 

https://grafana.com/api/dashboards/8704/revisions/10/download

 


Import “tomcat-dashboard_rev10.json” file into Grafana dashboard.

 


Click on import button.

 




 


Click on Upload JSON file button and Select “tomcat-dashboard_rev10.json” file from local drive.





 

Once selected file, click on import then Dashboard will be imported into Grafana.

 




 

 



 

 


Go to Dashboards in the Grafana home page and select Tomcat Dashboard.

 




 

We Can see Dashboard with many panels and all metrics will be represented as Graphs.

 


Dashboard Screen: 1

 




 

 


We can edit Dashboard based on metrics provided by Prometheus or JMX Exporter.

 


We can see all Metrics with following JMX URL’s and these metrics attribute keys are matching in Grafana Dashboard JSON file. This is how Grafana build dashboards based on JMX Metrics.

 


 

 

http://localhost:7171/metrics

 

http://localhost:7272/metrics

 

 

 




Author

 

Recent Posts

Recent Posts Widget

Popular Posts