Elasticsearch 6 (install and basic configuration)

Sunka

Well-known member
This is tutorial for installing (not upgrading) elasticsearch 6 on centos.
If I am missing something, please post here.

Delete first old one if you have installed and install fresh new one elasticsearch v6
Code:
yum remove elasticsearch


Installing elasticsearch 6

Code:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Code:
nano /etc/yum.repos.d/elasticsearch.repo

insert this:
Code:
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

If you do not have java installed (at least v8), install it

Code:
yum -y install java-1.8.0-openjdk

Code:
yum -y install elasticsearch

Code:
nano /etc/elasticsearch/elasticsearch.yml
at the end of file add this:

Code:
cluster.name: CUSTOM NAME OF YOUR CLUSTER (same name should be inserted into your XenForo field in Admin Control Panel in field Elasticsearch Index Name)
network.host: localhost
http.port: 9200

set how much ram you will add for elasticsearch - 512 megabytes is set in example (both Xms and Xmx must have same value)

Code:
nano /etc/elasticsearch/jvm.options

Code:
-Xms512m
-Xmx512m


Code:
mkdir /etc/elasticsearch/scripts/

Code:
cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/

Code:
service elasticsearch start

Code:
systemctl daemon-reload

Code:
systemctl enable elasticsearch.service

Code:
systemctl start elasticsearch.service

test if everything OK (give 1-2 minute after restarting elasticsearch)

Code:
curl -XGET 'localhost:9200'

If everything OK, you will see something like this in your CLI
Code:
# curl -XGET 'localhost:9200'
{
  "name" : "xxxxxx",
  "cluster_name" : "xxxxx",
  "cluster_uuid" : "ZLDl3yghRIa6MBvRGLBPzg",
  "version" : {
    "number" : "6.0.0",
    "build_hash" : "8f0685b",
    "build_date" : "2017-11-10T18:41:22.859Z",
    "build_snapshot" : false,
    "lucene_version" : "7.0.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Minimum version of XenForo Enhanced Search you have installed for elasticsearch 6 is 1.1.8

After you installed elastic search, configure relevant options for enhanced search in your Xenforo ACP and rebuild index (all)

acpoption.webp


And how it looks in elasticsearch setup page in xenforo ACP

acp.webp
 
What is the purpose of this step?:

Code:
Code:
cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/

I don't see that being referenced anywhere after copying them. Thanks.
 
Also confused by cluster.name being the same as the index name in XF ES configuration. Isn't the hierarchy Cluster > Node > Index, therefore Cluster name and Index name are not the same thing?
 
What is the purpose of this step?:

Code:
Code:
cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/

I don't see that being referenced anywhere after copying them. Thanks.
Needed before. Do not know is it by default replaced with painless, so it is no hurt to copy it there
Also confused by cluster.name being the same as the index name in XF ES configuration. Isn't the hierarchy Cluster > Node > Index, therefore Cluster name and Index name are not the same thing?
You add cluster name as you want, so same name you want, add into elasticsearch configuration and then into xenforo.


Do what you want, I just wrote this basic tutorial so users with little knowledge about linux and sys administration (like me) can install and reinstall elasticsearch on their servers.
 
What is the purpose of this step?:

Code:
Code:
cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/

I don't see that being referenced anywhere after copying them. Thanks.
Did you ever get passed that part? The Elastic Search download from Xenforo doesn't have library/XenES, it only has src/addons/xfes. I'm getting stuck at the part above as no _scripts folder exists.
 
@Sunka Thanks for posting this, I was able to setup Elasticsearch on my new server.

Code:
nano /etc/elasticsearch/elasticsearch.yml
at the end of file add this:

Code:
cluster.name: CUSTOM NAME OF YOUR CLUSTER (same name should be inserted into your XenForo field in Admin Control Panel in field Elasticsearch Index Name)
network.host: localhost
http.port: 9200

If you do choose to use a cluster name, the name needs to be in lowercase when you enter it the XF search engine settings.
If you have multiple forums running using the same Elasticsearch install, you should leave this blank and let XF use your DB name.

191275
 
196046

is this the location ?

if i delete the entire folder, (after indices /var/lib/elasticsearch/nodes/0/indices/), will all the files be deleted so that i can recreate the index file ?
 
Yes, but why not recreate the indexes in XF and let elasticsearch remove that if needed?

Edit: if you want to delete it, you should use curl to do that:
Code:
curl -X DELETE "localhost:9200/yourindex"

To list all indexes use this:
Code:
curl -X GET "localhost:9200/_cat/indices?v"
 
Thanks a lot Nuno. can you tell me what are the best practises to configure Elastic search. Below is my present indexes

Documents: 287,683 (455.8 MB)
Index updates: 88
Searches: 2,644,165 (1 milliseconds average)
Allocated memory: 2.9 MB

I configured memory in Elasticsearch file to 1 gb. i see that sevrer is using 1.5 gb of Java memory every minute.
 
I'm not an ES expert, but if you have sufficient ram in the server, 1G for that index is enough.
You can see here an example and Mike's response here.
Usually 300MB for 1M posts

Yes, you'll have 1G for elasticsearch but Java requires a little more for cache, gc, etc.
 
Top Bottom