How to: Basic Elasticsearch installation. (RHEL/SUSE)

Slavik

XenForo moderator
Staff member
Basic Elasticsearch Installation (RHEL / SUSE)

@Floren has an amazing repo for RHEL 6 and 7, the Elasticsearch RPM he provides is perfectly set up and currently I suggest using it.

The old manual setup guide can be found below.

Step 1) Install the Axivo Repo: https://www.axivo.com/resources/repository-setup.1/

Step 2) Install ElasticSearch: https://www.axivo.com/resources/elasticsearch-setup.11/




This guide is provided to show how to do a basic (vanilla get up and go) install of Elasticsearch (0.90.0 Beta 1), the Elasticsearch Service Wrapper and the required Java Runtime Environment (JRE) (1.7.0_17) on RHEL / SUSE. This guide will not cover running a dedicated Elasticsearch user.

For Debian/Ubuntu users, a guide can be found here.

This guide assumes the user has basic knowledge of SSH and prior to starting the steps below has logged in as root. This guide also assumes the user does not currently have any JRE installed. You can check if you have JRE installed by typing

Code:
java -version

As of writing, the current file locations for JRE are as follows:

32 bit
Code:
http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jre-7u17-linux-i586.rpm

64 bit
Code:
http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jre-7u17-linux-x64.rpm

The guide will be shown using the 64 bit install, however if you are using a 32 bit system, change the file names as appropriate.

Please note, whilst this is a simple and easy setup, I take no responsibility for any damages or losses that may occur to your system by following the steps below. If you are unsure at any stage, please ask for assistance or seek the help of a qualified Linux Systems Administrator.

Installing the JRE
Type the following commands into your SSH terminal.
Code:
cd /tmp
wget http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jre-7u17-linux-x64.rpm
rpm -ivh jre-7u17-linux-x64.rpm
java -version

Assuming everything was done correctly, you should get the following output.

Code:
# java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

Install Elasticsearch

Code:
cd /
curl -L -O -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.zip
unzip elasticsearch-0.90.0.Beta1.zip
mv elasticsearch-0.90.0.Beta1 elasticsearch

Install the Elasticsearch Service Wrapper

Code:
curl -L -k http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
mv *servicewrapper*/service elasticsearch/bin/
elasticsearch/bin/service/elasticsearch install
ln -s `readlink -f elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcelasticsearch
rcelasticsearch start

Assuming everything was done correctly, you should see the following output.

Code:
rcelasticsearch start
Starting ElasticSearch...
Waiting for ElasticSearch......
running: PID: xxxxx

Basic Configuration

You should do some basic configuration of Elasticsearch before installing the addon in XenForo.


1) Open up /elasticsearch/config/elasticsearch.yml and on line 32 edit

Code:
# cluster.name: elasticsearch

To

Code:
cluster.name: PUT-SOMETHING-UNIQUE-HERE

on line 199 edit

Code:
# network.host: 192.168.0.1

to

Code:
network.host: 127.0.0.1

On line 211 edit

Code:
# http.port: 9200

to

Code:
http.port: 9200

Save and Close


2) Open up /elasticsearch/bin/service/elasticsearch.conf on line 2 edit

Code:
set.default.ES_HEAP_SIZE=1024

To a number suitable for the size of your forum.

I reccomend approximately 1 GB for the HEAP_SIZE per 1 million posts on your forum.

1 Million Posts: 1024
2 Million Posts: 2048
3 Million Posts: 3072
4 Million Posts: 4096
etc

This will not mean the service will use all that available memory, however it will have it at its disposal if required.

So for example a 3 Million Post forum would edit

Code:
set.default.ES_HEAP_SIZE=1024

to

Code:
set.default.ES_HEAP_SIZE=3072



Save and Exit.


3) Optional - Move the Elasticsearch data directory.

Your linux install may be configured in such a way that your install partition is only a few Gb in size, and placing a large Elasticsearch index there is not ideal.

In which case you will want to move the index directory to a different, larger, location (in this example /var/elasticsearch)

Code:
cd /var
mkdir elasticsearch

Open up /elasticsearch/config/elasticsearch.yml on line 143 edit

Code:
# path.data: /path/to/data

to

Code:
path.data: /var/elasticsearch

Save and Exit

4) Restart the Elasticsearch Service

In SSH type

Code:
rcelasticsearch restart

You should get the following output

Code:
rcelasticsearch restart
Stopping ElasticSearch...
Stopped ElasticSearch.
Starting ElasticSearch...
Waiting for ElasticSearch......
running: PID: xxxxx

Elasticsearch is now runing with your updated config.



Install the XenForo Enhanced Search Addon

1) Turn your board off into maintainance mode*

2) Download the addon from your customer area at http://xenforo.com/customers/

3) Follow the instructions found at http://xenforo.com/help/enhanced-search/

4) Wait for your indexes to be rebuilt

5) Open your board.

6) Install the index pre-warmer.

As of 0.90.0 Beta an index pre-warmer is available. This keeps your search index "warm" in active memory so when a search is done, the access time latency is highly reduced.

Installing this is simple, in SSH simply run the following replacing the *INDEX NAME* with the name of your ES index.

Code:
curl -XPUT localhost:9200/*INDEX NAME*/_warmer/warmer_1 -d '{
    "query" : {
        "match_all" : {}
    }
}'

You should have the following returned

Code:
{"ok":true,"acknowledged":true}


*You may leave your board open during the re-index process.

Congratulations. Your board should now be running XenForo Enhanced Search.
 
Last edited:
There should be a scripts folder, I don't have the directory structure in front of me to tell you exactly where it is.
On fresh installation, there is no scripts folder so I created one under /elasticsearch/ and move the files into there.
Restart ES after disabling dynamic scripting doesn't seem to work.

Maybe the folder must be somewhere else.
 
On fresh installation, there is no scripts folder so I created one under /elasticsearch/ and move the files into there.
Restart ES after disabling dynamic scripting doesn't seem to work.

Maybe the folder must be somewhere else.

Top of my head it should be /config/scripts/script.mvel or /config/scripts/script.groovy
 
Code:
root@ehost [/tmp]# java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
root@ehost [/tmp]# cd /
root@ehost [/]# curl -L -O -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17.0M  100 17.0M    0     0  10.3M      0  0:00:01  0:00:01 --:--:-- 15.0M
root@ehost [/]# curl -L -O -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.3.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17.0M  100 17.0M    0     0  1977k      0  0:00:08  0:00:08 --:--:-- 1827k
root@ehost [/]# unzip elasticsearch-0.90.3.zip
Archive:  elasticsearch-0.90.3.zip
   creating: elasticsearch-0.90.3/
  inflating: elasticsearch-0.90.3/README.textile
  inflating: elasticsearch-0.90.3/LICENSE.txt
  inflating: elasticsearch-0.90.3/NOTICE.txt
   creating: elasticsearch-0.90.3/lib/
  inflating: elasticsearch-0.90.3/lib/lucene-core-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-codecs-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-analyzers-common-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-queries-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-memory-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-highlighter-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-queryparser-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-sandbox-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-suggest-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-misc-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-join-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-grouping-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/lucene-spatial-4.4.0.jar
  inflating: elasticsearch-0.90.3/lib/spatial4j-0.3.jar
  inflating: elasticsearch-0.90.3/lib/jts-1.12.jar
  inflating: elasticsearch-0.90.3/lib/log4j-1.2.17.jar
  inflating: elasticsearch-0.90.3/lib/jna-3.3.0.jar
  inflating: elasticsearch-0.90.3/lib/elasticsearch-0.90.3.jar
   creating: elasticsearch-0.90.3/bin/
  inflating: elasticsearch-0.90.3/bin/elasticsearch.bat
  inflating: elasticsearch-0.90.3/bin/plugin.bat
  inflating: elasticsearch-0.90.3/bin/elasticsearch
  inflating: elasticsearch-0.90.3/bin/elasticsearch.in.sh
  inflating: elasticsearch-0.90.3/bin/plugin
   creating: elasticsearch-0.90.3/lib/sigar/
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-amd64-freebsd-6.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-amd64-linux.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-amd64-solaris.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-ia64-linux.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-sparc-solaris.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-sparc64-solaris.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-universal-macosx.dylib
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-universal64-macosx.dylib
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-x86-freebsd-5.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-x86-freebsd-6.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-x86-linux.so
  inflating: elasticsearch-0.90.3/lib/sigar/libsigar-x86-solaris.so
  inflating: elasticsearch-0.90.3/lib/sigar/sigar-1.6.4.jar
  inflating: elasticsearch-0.90.3/lib/sigar/sigar-amd64-winnt.dll
  inflating: elasticsearch-0.90.3/lib/sigar/sigar-x86-winnt.dll
  inflating: elasticsearch-0.90.3/lib/sigar/sigar-x86-winnt.lib
   creating: elasticsearch-0.90.3/config/
  inflating: elasticsearch-0.90.3/config/elasticsearch.yml
  inflating: elasticsearch-0.90.3/config/logging.yml
root@ehost [/]# mv elasticsearch-0.90.3 elasticsearch
root@ehost [/]# mv elasticsearch-0.90.3 elasticsearch
mv: cannot stat `elasticsearch-0.90.3': No such file or directory
root@ehost [/]# curl -L -k http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0 1998k    0     0  1236k      0 --:--:--  0:00:01 --:--:-- 3180k
root@ehost [/]# mv *servicewrapper*/service elasticsearch/bin/
root@ehost [/]# elasticsearch/bin/service/elasticsearch install
Detected RHEL or Fedora:
The Elasticsearch daemon is already installed.
root@ehost [/]# elasticsearch/bin/service/elasticsearch reinstall
Unexpected command: reinstall

Usage: elasticsearch/bin/service/elasticsearch [ console | start | stop | restart | condrestart | status | install | remove | dump ]

Commands:
  console      Launch in the current console.
  start        Start in the background as a daemon process.
  stop         Stop if running as a daemon or in another console.
  restart      Stop if running and then start.
  condrestart  Restart only if already running.
  status       Query the current status.
  install      Install to start automatically when system boots.
  remove       Uninstall.
  dump         Request a Java thread dump if running.

root@ehost [/]# elasticsearch/bin/service/elasticsearch remove
Detected RHEL or Fedora:
Stopping Elasticsearch...
Elasticsearch was not running.
Removing Elasticsearch daemon...
root@ehost [/]# elasticsearch/bin/service/elasticsearch install
Detected RHEL or Fedora:
Installing the Elasticsearch daemon..
root@ehost [/]# ln -s `readlink -f elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcelasticsearch
ln: creating symbolic link `/usr/local/bin/rcelasticsearch': File exists
root@ehost [/]# rcelasticsearch start
-bash: rcelasticsearch: command not found
root@ehost [/]# ln -s `readlink -f elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcaelasticsearch
root@ehost [/]# rcaelasticsearch start
Starting Elasticsearch...
Waiting for Elasticsearch................................
WARNING: Elasticsearch may have failed to start.
root@ehost [/]#


still no joy?? Any ideas?
 
I have installed ElasticSearch and tried configuring it with the configurations provided. However, it looks like I get a warning when trying to start this:

WARNING: Elasticsearch may have failed to start.
 
Try to allocate at least 1GB of memory.
From my host:

"Your server already has 4GB of memory assigned to it. Are you referring to an extra gigabyte assigned to the Xenforo application? Did they provide any information on how to find a config file that specifies memory usage?"

Can you please advise?
 
From my host:

"Your server already has 4GB of memory assigned to it. Are you referring to an extra gigabyte assigned to the Xenforo application? Did they provide any information on how to find a config file that specifies memory usage?"

Can you please advise?
2) Open up /elasticsearch/bin/service/elasticsearch.conf on line 2 edit
Code:
et.default.ES_HEAP_SIZE=1024
 
Top Bottom