Elasticsearch 5

A thing to be wary of is that v5 wont handle indexes made initially in in v1.x, so even if you have been running v2.x for a year or so, but started off with v1.x, you will need to reindex.
 
This is tutorial for installing (not upgrading) elasticsearch 5 on centos.
If I am missing something, please post here.
Without help from @eva2000 and @Xon this tutorial could not be alive.

I tried to upgrade first from 2.4 version, but ended up with strange errors, so I delete (yum remove elasticsearch) and install fresh new one.
Because of something, if you remove old one and than install new one elasticsearch, change cluster name to new one, do not use old one (you have to change it also in ACP)

Code:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Code:
nano /etc/yum.repos.d/elasticsearch.repo
insert this:
Code:
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
Code:
yum -y install java-1.8.0-openjdk
Code:
yum -y install elasticsearch
Code:
curl -XPUT 'http://localhost:9200/_template/default' -d'{
  "template": "*",
  "settings": {
    "number_of_shards": "1",
    "number_of_replicas": "0"
  }
}'
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 ontrol Panel)
network.host: 127.0.0.1
http.port: 9200

set how much ram you will add for elasticsearch - 512 megabytes is set in example (botx 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'
 
I Upgraded elasticsearch 5 on centos 7 with this steps.

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

Open /etc/yum.repos.d/elasticsearch.repo

Add this:

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

Then Run:

Code:
yum update

That will Upgraded elasticsearch 5 from elasticsearch 2.x and donot need change any setting for this Upgrading.
 

Attachments

  • ScreenShot00206.webp
    ScreenShot00206.webp
    14.1 KB · Views: 18
Nop.
Upgrade than rebuild index.
But replicas setting and shard setting and memory setting are not the same in version 5.
I first try to upgrade than rebuild, but elasticsearch can not start because of error. So I decide to remove and do clean install.

This will setup replicas and shard for version 5
Code:
curl -XPUT 'http://localhost:9200/_template/default' -d'{
  "template": "*",
  "settings": {
    "number_of_shards": "1",
    "number_of_replicas": "0"
  }
}'

but this will only apply the next time you delete your index.

@Xon also wrote this command to change live indexes
Code:
curl -XPUT 'http://localhost:9200/_settings?preserve_existing=true' -d '{
  "index.number_of_replicas" : "0"
}'

It is for replicas settings, but do not know how to do that for shards too, and is it necessary at all?

if your search working, probably is better to leave as is. You will see will be problem show up when you restart elasticsearh, I think.
 
@Sunka You shouldn't need to reshard. Also, if you actually have a replica, then you should keep number_of_replicas at 1. If you didn't have a replica server before, Elasticsearch would still start, but its status would never be green; it would stay at yellow.

As a general rule, Elasticsearch works best with a minimum of 3 servers, and always an odd number. (Physically separate servers, not just separate VMs or containers on the same machine.) If you only have 1, then you have no redundancy (number_of_replicas = 0), so your data can easily be lost. If you only have 2, you can run into a split-brain scenario.
 
Elasticsearch 5.0.1 is out there.
Change log

Code:
# yum update
Loaded plugins: fastestmirror, priorities
base                                                     | 3.6 kB     00:00     
centos-sclo-rh                                           | 2.9 kB     00:00     
centos-sclo-sclo                                         | 2.9 kB     00:00     
elasticsearch-5.x                                        | 1.3 kB     00:00     
epel/x86_64/metalink                                     |  20 kB     00:00     
epel                                                     | 4.3 kB     00:00     
extras                                                   | 3.4 kB     00:00     
mariadb                                                  | 2.9 kB     00:00     
rpmforge                                                 | 1.9 kB     00:00     
updates                                                  | 3.4 kB     00:00     
varnish-4.1                                              |  951 B     00:00     
elasticsearch-5.x/primary                                  | 9.2 kB   00:01     
Loading mirror speeds from cached hostfile
 * base: ftp.hosteurope.de
 * epel: mirror.de.leaseweb.net
 * extras: ftp.hosteurope.de
 * rpmforge: mirror.de.leaseweb.net
 * updates: ftp.hosteurope.de
elasticsearch-5.x                                                         20/20
233 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.noarch 0:5.0.0-1 will be updated
---> Package elasticsearch.noarch 0:5.0.1-1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch         Version         Repository               Size
================================================================================
Updating:
 elasticsearch       noarch       5.0.1-1         elasticsearch-5.x        31 M

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 31 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for elasticsearch-5.x
elasticsearch-5.0.1.rpm                                    |  31 MB   00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : elasticsearch-5.0.1-1.noarch                                 1/2
warning: /etc/elasticsearch/elasticsearch.yml created as /etc/elasticsearch/elasticsearch.yml.rpmnew
  Cleanup    : elasticsearch-5.0.0-1.noarch                                 2/2
  Verifying  : elasticsearch-5.0.1-1.noarch                                 1/2
  Verifying  : elasticsearch-5.0.0-1.noarch                                 2/2

Updated:
  elasticsearch.noarch 0:5.0.1-1                                               

Complete!

# systemctl daemon-reload

# service elasticsearch restart
Restarting elasticsearch (via systemctl):                  [  OK  ]

# curl -XGET '127.0.0.1:9200'
{
  "name" : "-QxWHO2",
  "cluster_name" : "xxx",
  "cluster_uuid" : "xxxxxxxx",
  "version" : {
    "number" : "5.0.1",
    "build_hash" : "080bb47",
    "build_date" : "2016-11-11T22:08:49.812Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.1"
  },
  "tagline" : "You Know, for Search"
}
 
Elasticsearch 5.0.2 is out there
Release notes

Code:
# yum update
Loaded plugins: fastestmirror, priorities
base                                                                      | 3.6 kB  00:00:00    
centos-sclo-rh                                                            | 2.9 kB  00:00:00    
centos-sclo-sclo                                                          | 2.9 kB  00:00:00    
elasticsearch-5.x                                                         | 1.3 kB  00:00:00    
epel/x86_64/metalink                                                      |  24 kB  00:00:00    
epel                                                                      | 4.3 kB  00:00:00    
extras                                                                    | 3.4 kB  00:00:00    
mariadb                                                                   | 2.9 kB  00:00:00    
rpmforge                                                                  | 1.9 kB  00:00:00    
updates                                                                   | 3.4 kB  00:00:00    
varnish-4.1                                                               |  951 B  00:00:00    
(1/11): base/7/x86_64/group_gz                                            | 155 kB  00:00:00    
(2/11): epel/x86_64/group_gz                                              | 170 kB  00:00:00    
(3/11): epel/x86_64/updateinfo                                            | 677 kB  00:00:00    
(4/11): epel/x86_64/primary_db                                            | 4.4 MB  00:00:00    
(5/11): centos-sclo-sclo/x86_64/primary_db                                | 117 kB  00:00:00    
(6/11): extras/7/x86_64/primary_db                                        | 166 kB  00:00:00    
(7/11): updates/7/x86_64/primary_db                                       | 9.1 MB  00:00:00    
(8/11): centos-sclo-rh/x86_64/primary_db                                  | 1.8 MB  00:00:00    
(9/11): mariadb/primary_db                                                |  18 kB  00:00:00    
(10/11): elasticsearch-5.x/primary                                        |  13 kB  00:00:00    
(11/11): base/7/x86_64/primary_db                                         | 5.3 MB  00:00:00    
(1/2): rpmforge/primary_db                                                | 125 kB  00:00:00    
(2/2): varnish-4.1/x86_64/primary                                         | 9.0 kB  00:00:00    
Determining fastest mirrors
 * base: ftp.hosteurope.de
 * epel: mirror.de.leaseweb.net
 * extras: ftp.hosteurope.de
 * rpmforge: mirror.de.leaseweb.net
 * updates: ftp.hosteurope.de
elasticsearch-5.x                                                                          30/30
varnish-4.1                                                                                29/29
230 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.noarch 0:5.0.1-1 will be updated
---> Package elasticsearch.noarch 0:5.0.2-1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package                 Arch             Version              Repository                   Size
=================================================================================================
Updating:
 elasticsearch           noarch           5.0.2-1              elasticsearch-5.x            31 M

Transaction Summary
=================================================================================================
Upgrade  1 Package

Total download size: 31 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for elasticsearch-5.x
elasticsearch-5.0.2.rpm                                                   |  31 MB  00:00:02    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : elasticsearch-5.0.2-1.noarch                                                  1/2
warning: /etc/elasticsearch/jvm.options created as /etc/elasticsearch/jvm.options.rpmnew
  Cleanup    : elasticsearch-5.0.1-1.noarch                                                  2/2
  Verifying  : elasticsearch-5.0.2-1.noarch                                                  1/2
  Verifying  : elasticsearch-5.0.1-1.noarch                                                  2/2

Updated:
  elasticsearch.noarch 0:5.0.2-1                                                                

Complete!

# systemctl daemon-reload

# service elasticsearch restart
Restarting elasticsearch (via systemctl):                  [  OK  ]

# curl -XGET '127.0.0.1:9200'
{
  "name" : "-QxWHO2",
  "cluster_name" : "xxx",
  "cluster_uuid" : "xxxxxxx",
  "version" : {
    "number" : "5.0.2",
    "build_hash" : "f6b4951",
    "build_date" : "2016-11-24T10:07:18.101Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.1"
  },
  "tagline" : "You Know, for Search"
}
 
Back
Top Bottom