官网:https://www.elastic.co/guide/en/elasticsearch/reference/5.6/rpm.html
Download and install the public signing key:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Installing from the RPM repository
add the repository file /etc/yum.repos.d/elasticsearch.repo
with the following contents
[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
install Elasticsearch :
sudo 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
These commands provide no feedback as to whether Elasticsearch was started successfully or not. Instead, this information will be written in the log files located in /var/log/elasticsearch/
.
By default the Elasticsearch service doesn’t log information in the systemd
journal. To enable journalctl
logging, the --quiet
option must be removed from the ExecStart
command line in the elasticsearch.service
file.
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"
Checking that Elasticsearch is running
You can test that your Elasticsearch node is running by sending an HTTP request to port 9200
on localhost
:
curl -X get localhost:9200
which should give you a response something like this:
{ "name" : "Cp8oag6", "cluster_name" : "elasticsearch", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "5.6.8", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "6.6.1" }, "tagline" : "You Know, for Search" }
配置文件:
[root@localhost elasticsearch]# pwd /etc/elasticsearch [root@localhost elasticsearch]# ll total 16 -rw-rw----. 1 root elasticsearch 2875 Apr 7 09:58 elasticsearch.yml -rw-rw----. 1 root elasticsearch 3068 Apr 7 10:10 jvm.options -rw-rw----. 1 root elasticsearch 4456 Feb 17 00:48 log4j2.properties drwxr-x---. 2 root elasticsearch 6 Feb 17 00:48 scripts
NOTE1:通过ip:9200无法访问
解决方案:修改elasticsearch.yml文件的network.host属性
NOTE2:elasticsearch因内存不足启动失败
解决方案:修改jvm.options文件的-Xms和-Xmx值(Xms和Xmx值应该一样)