Configuring a Liferay cluster

From:http://blogs.aca-it.be/blogs/-/blogs/configuring-a-liferay-cluster


Introduction

Configuring a Liferay cluster is part experience and part black magic. There is some information that you can find online, there's some information you can only find out while working on it and then there are some things like how to configure ehcache to use unicast that you can only discover through blood, sweat and tears. This post will first describe how to set up a Liferay 6.1 cluster with Ehcache in multicast and in unicast mode.

To get clustering to work in Liferay you need to make sure that all of the subsystems below are configured correctly:

  • Database

  • Indexing

  • Media gallery

  • Quartz

  • Cluster Link

  • Ehcache

 

Database

The first subsystem that needs to be configured for clustering, the database, is also one of the easiest to configure correctly. You just need to point each node in the cluster to the same database, either by using the same JNDI datasource

jdbc.default.jndi.name=jdbc /liferay

or by using the same JDBC configuration directly in your portal-ext.properties on each node

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql: //dbserver :3306 /liferay_test ?useUnicode= true &characterEncoding=UTF-8&useFastDateParsing= false &autoReconnectForPools= true
jdbc.default.username=dbuser
jdbc.default.password=Y@r3FiL

 

Indexing

For Liferay 6.1 the only reliable way to cluster the indexing is to use SOLR. For this you'll need to do 2 things: set up a separate SOLR server (or use an existing one) and deploy a correctly configured solr-web.war from the Marketplace to all cluster nodes.

Depending on which Liferay flavor you're using, CE or EE, this will be an easy process or a little bit more difficult. If you're running Liferay EE, the process is pretty straightforward as for that version there are solr-web versions available for SOLR 3 and 4. For Liferay CE it's a bit more complicated as there's only a relatively old WAR available for SOLR 1.4, which you'll need to upgrade yourself if you want to use newer SOLR versions with Liferay CE.

For this blog we're assuming that a dedicated Liferay SOLR instance will be used (but an additional core in an existing SOLR will also work). To set up a SOLR, you can just follow the instructions on their site: https://wiki.apache.org/solr/SolrInstall. Once you have a default SOLR up and running, you'll need to add some configuration to it so Liferay can use it for indexing. This configuration is done by replacing the existing schema.xml with the Liferay SOLR schema.xml that you can find in the WEB-INF/conf directory of the solr-web.war you downloaded.

If you're running on Liferay 6.1 CE and want to use a newer SOLR version than 1.4, you'll also need to change the schema.xml and possibly also the solr-spring.xml a bit to get it working. The version of the schema.xml that worked for us is:

xml version = "1.0" ?>
< schema name = "liferay" version = "1.1" >
     < types >
         < fieldType name = "string" class = "solr.StrField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "boolean" class = "solr.BoolField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "integer" class = "solr.IntField" omitNorms = "true" />
         < fieldType name = "long" class = "solr.LongField" omitNorms = "true" />
         < fieldType name = "float" class = "solr.FloatField" omitNorms = "true" />
         < fieldType name = "double" class = "solr.DoubleField" omitNorms = "true" />
         < fieldType name = "sint" class = "solr.SortableIntField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "slong" class = "solr.SortableLongField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "sfloat" class = "solr.SortableFloatField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "sdouble" class = "solr.SortableDoubleField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "date" class = "solr.DateField" sortMissingLast = "true" omitNorms = "true" />
         < fieldType name = "text_ws" class = "solr.TextField" positionIncrementGap = "100" >
             < analyzer >
                 < tokenizer class = "solr.WhitespaceTokenizerFactory" />
             analyzer >
         fieldType >
         < fieldType name = "text" class = "solr.TextField" positionIncrementGap = "100" >
             < analyzer type = "index" >
                 < tokenizer class = "solr.WhitespaceTokenizerFactory" />
                 < filter class = "solr.StopFilterFactory" ignoreCase = "true" words = "stopwords.txt" />
                 < filter class = "solr.WordDelimiterFilterFactory" generateWordParts = "1" generateNumberParts = "1" catenateWords = "1" catenateNumbers = "1" catenateAll = "0" />
                 < filter class = "solr.LowerCaseFilterFactory" />
                 < filter class = "solr.RemoveDuplicatesTokenFilterFactory" />
             analyzer >
             < analyzer type = "query" >
                 < tokenizer class = "solr.WhitespaceTokenizerFactory" />
                 < filter class = "solr.SynonymFilterFactory" synonyms = "synonyms.txt" ignoreCase = "true" expand = "true" />
                 < filter class = "solr.StopFilterFactory" ignoreCase = "true" words = "stopwords.txt" />
                 < filter class = "solr.WordDelimiterFilterFactory" generateWordParts = "1" generateNumberParts = "1" catenateWords = "0" catenateNumbers = "0" catenateAll = "0" />
                 < filter class = "solr.LowerCaseFilterFactory" />
                 < filter class = "solr.RemoveDuplicatesTokenFilterFactory" />
             analyzer >
         fieldType >
         < fieldType name = "textTight" class = "solr.TextField" positionIncrementGap = "100" >
             < analyzer >
                 < tokenizer class = "solr.WhitespaceTokenizerFactory" />
                 < filter class = "solr.SynonymFilterFactory" synonyms = "synonyms.txt" ignoreCase = "true" expand = "false" />
                 < filter class = "solr.StopFilterFactory" ignoreCase = "true" words = "stopwords.txt" />
                 < filter class = "solr.WordDelimiterFilterFactory" generateWordParts = "0" generateNumberParts = "0" catenateWords = "1" catenateNumbers = "1" catenateAll = "0" />
                 < filter class = "solr.LowerCaseFilterFactory" />
                 < filter class = "solr.RemoveDuplicatesTokenFilterFactory" />
             analyzer >
         fieldType >
         < fieldType name = "alphaOnlySort" class = "solr.TextField" sortMissingLast = "true" omitNorms = "true" >
             < analyzer >
                 < tokenizer class = "solr.KeywordTokenizerFactory" />
                 < filter class = "solr.LowerCaseFilterFactory" />
                 < filter class = "solr.TrimFilterFactory" />
                 < filter class = "solr.PatternReplaceFilterFactory" pattern = "([^a-z])" replacement = "" replace = "all" />
             analyzer >
         fieldType >
         < fieldtype name = "ignored" stored = "false" indexed = "false" class = "solr.StrField" />
     types >
     < fields >
        
         < field name = "comments" type = "text" indexed = "true" stored = "true" />
         < field name = "content" type = "text" indexed = "true" stored = "true" />
         < field name = "description" type = "text" indexed = "true" stored = "true" />
         < field name = "entryClassPK" type = "text" indexed = "true" stored = "true" />
         < field name = "firstName" type = "text" indexed = "true" stored = "true" />
         < field name = "first-name" type = "text" indexed = "true" stored = "true" />
         < field name = "firstName_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "job-title" type = "text" indexed = "true" stored = "true" />
         < field name = "jobTitle_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "lastName" type = "text" indexed = "true" stored = "true" />
         < field name = "last-name" type = "text" indexed = "true" stored = "true" />
         < field name = "lastName_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "leftOrganizationId" type = "slong" indexed = "true" stored = "true" />
         < field name = "name" type = "text" indexed = "true" stored = "true" />
         < field name = "name_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "properties" type = "string" indexed = "true" stored = "true" />
         < field name = "rightOrganizationId" type = "slong" indexed = "true" stored = "true" />
         < field name = "screen-name" type = "text" indexed = "true" stored = "true" />
         < field name = "screenName_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "title" type = "text" indexed = "true" stored = "true" />
         < field name = "type" type = "text" indexed = "true" stored = "true" />
         < field name = "type_sortable" type = "string" indexed = "true" stored = "true" />
         < field name = "uid" type = "string" indexed = "true" stored = "true" />
         < field name = "url" type = "string" indexed = "true" stored = "true" />
         < field name = "userName" type = "string" indexed = "true" stored = "true" />
         < field name = "version" type = "string" indexed = "true" stored = "true" />
        
         < field name = "modified" type = "text" indexed = "true" stored = "true" />
        
         < dynamicField name = "*CategoryNames" type = "string" indexed = "true" multiValued = "true" stored = "true" />
         < dynamicField name = "*CategoryIds" type = "string" indexed = "true" multiValued = "true" stored = "true" />
         < dynamicField name = "expando/*" type = "text" indexed = "true" multiValued = "true" stored = "true" />
         < dynamicField name = "web_content/*" type = "text" indexed = "true" stored = "true" />
        
         < dynamicField name = "*" type = "string" indexed = "true" multiValued = "true" stored = "true" omitNorms = "false" />
     fields >
     < copyField source = "firstName" dest = "firstName_sortable" />
     < copyField source = "first-name" dest = "firstName_sortable" />
     < copyField source = "job-title" dest = "jobTitle_sortable" />
     < copyField source = "lastName" dest = "lastName_sortable" />
     < copyField source = "last-name" dest = "lastName_sortable" />
     < copyField source = "name" dest = "name_sortable" />
     < copyField source = "screen-name" dest = "screenName_sortable" />
     < copyField source = "type" dest = "type_sortable" />
     < uniqueKey >uid uniqueKey >
     < defaultSearchField >content defaultSearchField >
     < solrQueryParser defaultOperator = "OR" />
schema >

and for solr-spring.xml

xml version = "1.0" ?>
< beans
         default-destroy-method = "destroy"
         default-init-method = "afterPropertiesSet"
         xmlns = "
         xmlns:xsi = "
         xmlns:jee = "
         xmlns:util = "
         xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/jee  http://www.springframework.org/schema/jee/spring-jee.xsd
         http://www.springframework.org/schema/util  >
         
     < bean class = "com.liferay.portal.spring.context.PortletBeanFactoryPostProcessor" />
    
     < bean id = "com.liferay.portal.search.solr.server.BasicAuthSolrServer" class = "com.liferay.portal.search.solr.server.BasicAuthSolrServer" >
         < constructor-arg type = "java.lang.String" value = " />
     bean >
     < bean id = "com.liferay.portal.search.solr.SolrIndexSearcherImpl" class = "com.liferay.portal.search.solr.SolrIndexSearcherImpl" >
         < property name = "solrServer" ref = "com.liferay.portal.search.solr.server.BasicAuthSolrServer" />
         < property name = "swallowException" value = "true" />
     bean >
     < bean id = "com.liferay.portal.search.solr.SolrIndexWriterImpl" class = "com.liferay.portal.search.solr.SolrIndexWriterImpl" >
         < property name = "commit" value = "true" />

你可能感兴趣的:(Liferay)