Fork me on GitHub
Suzf  Blog

How-to Install elasticsearch with RPM on CentOS7

License: Attribution-NonCommercial-ShareAlike 4.0 International

本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。


The RPM for Elasticsearch can be downloaded from our website or from our RPM repository. It can be used to install Elasticsearch on any RPM-based system such as OpenSuSE, SLES,
Centos, Red Hat, and Oracle Enterprise.
The latest stable version of Elasticsearch can be found on the Download Elasticsearch page. Other versions can be found on the Past Releases page.
RPM install is not supported on distributions with old versions of RPM, such as SLES 11 and CentOS 5. Please see Install Elasticsearch with .zip or .tar.gz instead. Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Install Java

# wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""
# rpm -Uvh jdk-8u65-linux-x64.rpm
# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Import the Elasticsearch PGP Key

Download and install the public signing key:
rpm --import

Installing from the RPM repository

cat > /etc/yum.repos.d/elasticsearch.repo << EOF
name=Elasticsearch repository for 5.x packages

yum install elasticsearch

Running Elasticsearch with systemd

To configure Elasticsearch to start automatically when the system boots up, run the following commands:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
Elasticsearch can be started and stopped as follows:
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
When systemd logging is enabled, the logging information are available using the journalctl commands: To tail the journal:
sudo journalctl -f
To list journal entries for the elasticsearch service:
sudo journalctl --unit elasticsearch
To list journal entries for the elasticsearch service starting from a given time:
sudo journalctl --unit elasticsearch --since  "2016-10-30 18:17:16"
Check man journalctl or for more command line options.

Checking that Elasticsearch is running

You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost:
# ss -ntlp | grep 9200
LISTEN     0      128       ::ffff:                    :::*                   users:(("java",pid=1287,fd=130))
LISTEN     0      128        ::1:9200                    :::*                   users:(("java",pid=1287,fd=128))
# curl -XGET ''
  "name" : "ZlbJlUp",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "pm-y-OxIT2qFutEF4cxRUQ",
  "version" : {
    "number" : "5.3.0",
    "build_hash" : "3adb13b",
    "build_date" : "2017-03-23T03:31:50.652Z",
    "build_snapshot" : false,
    "lucene_version" : "6.4.1"
  "tagline" : "You Know, for Search"

「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」

Suzf Blog

(๑>ڡ<)☆ 谢谢 ~