Sunka
Well-known member
How To Install Elasticsearch 7.x for Xenforo
This is tutorial for installing (not upgrading) elasticsearch 7 on centos.
If I am missing something, please post here.
Delete first old one if you have installed and install fresh new one elasticsearch v7
Code:
yum remove elasticsearch
Installing elasticsearch 7
Code:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Code:
nano /etc/yum.repos.d/elasticsearch.repo
Code:
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
Java v11 is what you want to install. You can have both version (v.8 and v.11) but I removed v8 and installed v11
Code:
yum remove java-1.8.0-openjdk
Code:
yum -y install java-11-openjdk
Code:
yum install --enablerepo=elasticsearch elasticsearch
Code:
nano /etc/elasticsearch/elasticsearch.yml
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
node.name: ANOTHER CUSTOM NAME
cluster.initial_master_nodes: ANOTHER CUSTOM NAME (same as line above, and use all lowercase)
Also, in same above template change/modify the path -Djava.io.tmpdir=
Code:
-Djava.io.tmpdir=/home/elasticsearch
Then (thanks @rdan )
Code:
mkdir /home/elasticsearch
and
Code:
chown -R elasticsearch:elasticsearch /home/elasticsearch/
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:
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'
Code:
# curl -XGET 'localhost:9200'
{
"name" : "xxxx",
"cluster_name" : "xxxxx",
"cluster_uuid" : "4nAffvfpSGG-RE4ou1ttFA",
"version" : {
"number" : "7.6.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
"build_date" : "2020-02-06T00:09:00.449973Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Also, just in case run command and choose Java 11 (if it will list more than 1 java version):
Code:
alternatives --config java
Also, it is better that you not use shard replica if Elasticsearch is on same server.
So for make by default no replica shards, run this command
Code:
curl -XPUT "localhost:9200/_template/all" -H'Content-Type: application/json' -d'
{
"template": "*",
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
}
}
'
To see if you have unassigned replica shards run:
Code:
curl -s -XGET http://localhost:9200/_cat/shards | fgrep UNASSIGNED
To delete unassigned replica shards run:
Code:
curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "http://localhost:9200/{}"
Then deleted the index. After that go to ElasticSearch Setup in Xenforo ACP then rebuilt the index without deleting.
Minimum version of XenForo Enhanced Search you have installed for elasticsearch 7 is 2.0 I think!
After you installed elastic search, configure relevant options for enhanced search in your Xenforo ACP and rebuild index (all).
It is better and faster to rebuild index through cli. So:
Trunucate old index first (if you have it):
Code:
cd /PATH/TO/YOUR/XENFERO/INSTALL/public/
// SOMETHING LIKE: cd /home/nginx/domains/your_domain.com/public/
Rebuild search with trunucating index before that
Code:
php cmd.php xf-rebuild:search --truncate
Code:
php cmd.php xf-rebuild:search
And how it looks in elasticsearch setup page in xenforo ACP