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

 

 

2 comments :

  1. If the state police you have an interest in have an immediate search program readily available you will get your records polk county mugshots really rapidly, nevertheless instantaneous search is not readily available in all states. The benefit of using a site that utilizes the postponed search method to acquiring records is that they typically offer you more info.

    ReplyDelete

Recent Posts

Recent Posts Widget

Popular Posts