Sunteți pe pagina 1din 7

How to install SOLR

Based on: hybris 5.1

Viewed: 64

Introduction
SOLR in embedded mode
Architecture
SOLR in standalone mode
Architecture
Installation procedure
SOLR side
hybris side
SOLR in cluster mode
Architecture
Installation procedure
SOLR side
hybris side
References / Links

Introduction
To install SOLR in other server than hybris platform is not necessary to download it. Indeed, a customized SOLR version is provided by hybris
platform. This article will show in first step how to install a standalone SOLR with hybris in localhost and in second step how to create a SOLR
cluster.

SOLR in embedded mode


Architecture

+---------+ +---------------+
| +--HTTP:9001----+ hybris / SOLR |
| Client | +---------------+
| Browser | | Front |
| | | |
+---------+ +---------------+

This mode is provided by default with hybris. The SOLR instance is running into hybris platform. No setting is necessary.

SOLR in standalone mode


Architecture

+---------+ +--------+ +----------+


| +--HTTP:9001----+ hybris +---HTTP:8983---+ SOLR |
| Client | +--------+ +----------+
| Browser | | Front | |Standalone|
| | | | | |
+---------+ +--------+ +----------+

In this configuration SOLR is running out of hybris platform. The SOLR instance gets his own JVM. This SOLR will in charge to index document
and to response at each search request from hybris in same time.
Installation procedure

SOLR side

1. Copy SOLR binary from hybris platform to a dedicated SOLR space.


cp -r /hybris/bin/ext-commerce/solrfacetsearch/resources/solr/server/ /solr/server-standalone/
2. Update listening PORT (If necessary)
vim /solr/server-standalone/etc/jetty.xml

<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.bio.SocketConnector">
<Call class="java.lang.System" name="setProperty">
<Arg>log4j.configuration</Arg>
<Arg>etc/log4j.properties</Arg>
</Call>
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port"
default="8983"/></Set>
<Set name="maxIdleTime">50000</Set>
<Set name="lowResourceMaxIdleTime">1500</Set>
<Set name="statsOn">false</Set>
</New>
</Arg>
</Call>

3. Start SOLR standalone server


cd /solr/server-standalone
chmod +x start.sh
./start.sh
4. Check installation in SOLR administration panel
http://localhost:8983/solr

hybris side

1. Create a new SOLR Server Configuration object


Go in HAC > Impex Import
Run this kind of script

$serverConfigName=standaloneSolrServerConfig

# Create the solr server configuration


INSERT_UPDATE SolrServerConfig;name[unique=true];mode(code);embeddedMaster
;$serverConfigName;standalone;false

INSERT_UPDATE
SolrEndpointUrl;solrServerConfig(name)[unique=true];url[unique=true];master
[unique=true,default=false]
;$serverConfigName;http://localhost:8983/solr;true

2. Make the link in HMC with Facet Search Configuration object


3. Re-Generate the index on remote SOLR server with Index operation wizard panel

4. Check the indexation processing in SOLR logs

solr/server-standalone/logs/solr.log
10274889 [qtp1977522556-11] INFO org.apache.solr.core.CoreContainer Creating
SolrCore 'master_powertools_Product' using instanceDir: ./.
10274890 [qtp1977522556-11] INFO org.apache.solr.core.SolrResourceLoader new
SolrResourceLoader for directory: '././'

5. Test and check the change in B2C or B2B website


B2B website: http://localhost:9001/yb2bacceleratorstorefront/?site=powertools

SOLR in cluster mode


Architecture
+---------+ +--------+ +----------+
| +--HTTP:9001----+ hybris +---HTTP:8983-->+ SOLR |
| Client | +--------+ +----------+
| Browser | | Front | | Master |
| | | | | |
+---------+ +---+----+ +----+-----+
| ^
| |
| HTTP:8983
| |
| +----+-----+
+------HTTP:8984---->+ SOLR |
+----------+
| Slave |
| |
+----------+

In this architecture, we've two SOLR nodes. One instance is dedicated to index document (Master). And the other instance is dedicated to
response at any search request from hybris. Besides having the advantage of a clear distribution of load between indexing and searching, this
model offers the advantage to get a high availability. Indeed if one of SOLR is down, hybris will re-route the search requests toward the second
one.

To synchronize the index between Master and Slave, the Slave node will request frequently the Master node to figure out if the index has
changed.

Installation procedure

SOLR side

1. Copy SOLR binary from hybris platform to a dedicated SOLR space.


cp -r /hybris/ext-commerce/solrfacetsearch/resources/solr/server/ /solr/server-master/
cp -r /hybris/ext-commerce/solrfacetsearch/resources/solr/server/ /solr/server-slave/
2. Update listening PORT (If necessary)
vim /solr/server-master/etc/jetty.xml

<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.bio.SocketConnector">
<Call class="java.lang.System" name="setProperty">
<Arg>log4j.configuration</Arg>
<Arg>etc/log4j.properties</Arg>
</Call>
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port"
default="8983"/></Set>
<Set name="maxIdleTime">50000</Set>
<Set name="lowResourceMaxIdleTime">1500</Set>
<Set name="statsOn">false</Set>
</New>
</Arg>
</Call>

vim /solr/server-slave/etc/jetty.xml
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.bio.SocketConnector">
<Call class="java.lang.System" name="setProperty">
<Arg>log4j.configuration</Arg>
<Arg>etc/log4j.properties</Arg>
</Call>
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port"
default="8984"/></Set>
<Set name="maxIdleTime">50000</Set>
<Set name="lowResourceMaxIdleTime">1500</Set>
<Set name="statsOn">false</Set>
</New>
</Arg>
</Call>

3. Assign SOLR as a Master


vim /solr/server-master/conf/solrconfig.xml

<requestHandler name="/replication" class="solr.ReplicationHandler" >


<!--
To enable simple master/slave replication, uncomment one of the
sections below, depending on whether this solr instance should be
the "master" or a "slave". If this instance is a "slave" you will
also need to fill in the masterUrl to point to a real machine.
-->

<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="confFiles">schema.xml,stopwords.txt</str>
</lst>

<!--
<lst name="slave">
<str name="masterUrl">http://your-master-hostname:8983/solr</str>
<str name="pollInterval">00:00:60</str>
</lst>
-->
</requestHandler>

4. Assign SOLR as a Slave


vim /solr/server-slave/conf/solrconfig.xml
<requestHandler name="/replication" class="solr.ReplicationHandler" >
<!--
To enable simple master/slave replication, uncomment one of the
sections below, depending on whether this solr instance should be
the "master" or a "slave". If this instance is a "slave" you will
also need to fill in the masterUrl to point to a real machine.
-->
<!--
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="confFiles">schema.xml,stopwords.txt</str>
</lst>
-->

<lst name="slave">
<str
name="masterUrl">http://localhost:8983/solr/master_powertools_Product/repli
cation</str>
<str name="pollInterval">00:00:60</str>
</lst>

</requestHandler>

warning
Make sure the URL replication point is on the right SOLR core.

hybris side

1. Create a new SOLR Server Configuration object


Go in HAC > Impex Import
Run this kind of script

$serverConfigName=clusterSolrServerConfig

# Create the solr server configuration


INSERT_UPDATE SolrServerConfig;name[unique=true];mode(code);embeddedMaster
;$serverConfigName;standalone;false

INSERT_UPDATE
SolrEndpointUrl;solrServerConfig(name)[unique=true];url[unique=true];master
[unique=true,default=false]
;$serverConfigName;http://localhost:8983/solr;true
;$serverConfigName;http://localhost:8984/solr;false

2. Make the link in HMC with Facet Search Configuration object


3. Re-Generate the index on remote SOLR server with Index operation wizard panel

4. Check the indexation processing in SOLR logs

solr/server-master/logs/solr.log
10274889 [qtp1977522556-11] INFO org.apache.solr.core.CoreContainer Creating
SolrCore 'master_powertools_Product' using instanceDir: ./.
10274890 [qtp1977522556-11] INFO org.apache.solr.core.SolrResourceLoader new
SolrResourceLoader for directory: '././'

5. Test and check the change in B2C or B2B website


B2B website: http://localhost:9001/yb2bacceleratorstorefront/?site=powertools

References / Links
http://lucene.apache.org/solr/4_5_0/tutorial.html

http://wiki.apache.org/solr/SolrReplication

Solr Replication Mechanism

Standalone Solr and cluster

SolrFacetSearch - Installation Guide

Solr package and instalation

S-ar putea să vă placă și