Article ElasticSearch 7 on CentOS

  • Thread starter
  • Staff member
XenForo Enhanced Search depends on ElasticSearch 2.0+. Installing and configuring ElasticSearch to work with XF can be a hassle, so I've created a short guide to install it on CentOS 7. With some modifications, the guide should probably work on other versions of CentOS/Fedora/Redhat and derivative distribution.

All commands assume that you are root or that you run commands with sudo.

Let's add the ElasticSearch yum-repository so that you can easily get updates and bug fixes via yum update.

First, install the ElasticSearch GPG key:
Bash:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Then create a yum repository for ElasticSearch 7:
Bash:
cat > /etc/yum.repos.d/elasticsearch.repo <<EOF
[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
EOF
Then run the installation:
Code:
yum install elasticsearch
By default on CentOS 7, SELinux runs in enforcing mode. Therefore, we need to tell SELinux that the web server (Apache, Nginx, etc.) should be allowed to talk to ElasticSearch over TCP:
Bash:
setsebool httpd_can_network_connect on -P
It's good practice to create a password for ElasticSearch, so let's do this: you'll be prompted for passwords for 4 or so users. Write down these passwords! You will need the elastic user password when setting up advanced search in the XenForo control panel.
Bash:
echo "xpack.security.enabled: true" > /etc/elasticsearch/elasticsearch.yml
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
We configure the domain to work only on the local host. Add (or edit) the network.host parameter in the /etc/elasticsearch/elasticsearch.yml file:
Bash:
network.host: 127.0.0.1
The last step is to set up ElasticSearch to start on server boot and also to start it right now:
Bash:
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service
You can now verify that ElasticSearch is up and running as expected with the command:
Bash:
curl -u elastic -X GET "localhost:9200/?pretty"
...which should produce output similar to this (except that the version number is 7):
Code:
{
"name" : "Cp8oag6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : {
"number" : "6.8.10",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "7.7.3",
"minimum_wire_compatibility_version" : "1.2.3",
"minimum_index_compatibility_version" : "1.2.3"
},
"tagline" : "You Know, for Search"
}


See also:
 
  • Tags
    elasticsearch enhanced search xenforo enhanced search теги centos
  • Top