官網-安裝介紹 這裏記載了各個軟件包的安裝方法,Linux Mac Windows……html
本文記載的是在 CentOS 系統安裝 Elasticsearch 7.0.0 版本的步驟。java
以前寫過一篇文章介紹了 Java 的安裝,參考 Linux 安裝 JDKnode
注意:只有配置了 JAVA_HOME
環境變量,安裝 Elasticsearch 時纔會採用系統已安裝的 JDK。linux
$ env|grep JAVA JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
在 /etc/yum.repos.d/
建立 elasticsearch.repo
,內容:git
[elasticsearch-7.x] 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
而後輸入以下命令便可安裝:github
sudo yum install elasticsearch
有時候,咱們的環境是沒法鏈接外網的,這時候這種方式就能夠用來解決這個問題:架構
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm.sha512 shasum -a 512 -c elasticsearch-7.0.0-x86_64.rpm.sha512 sudo rpm --install elasticsearch-7.0.0-x86_64.rpm
安裝結果:app
# root @ localhost in /data/SF/es [21:11:36] $ sudo rpm --install elasticsearch-7.0.0-x86_64.rpm Creating elasticsearch group... OK Creating elasticsearch user... OK ### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd sudo systemctl daemon-reload sudo systemctl enable elasticsearch.service ### You can start elasticsearch service by executing sudo systemctl start elasticsearch.service Created elasticsearch keystore in /etc/elasticsearch
安裝完成以後,配置文件在 /etc/elasticsearch/elasticsearch.yml
。curl
官網有更詳細的配置介紹,本文僅搭建一個 master 節點的 Elasticsearch 服務,未搭建集羣。jvm
經過 cluster.name
能夠設置集羣的名稱:
cluster.name: michael-application
經過 node.name
能夠配置每一個節點的名稱,集羣中每一個節點的名稱都不要相同:
node.name: es-node-1
咱們須要設定 Elasticsearch 運行綁定的 Host,默認是沒法公開訪問的,若是設置爲主機的公網 IP 或 0.0.0.0
就是能夠公開訪問的,這裏咱們能夠都設置爲公開訪問或者部分主機公開訪問,若是是公開訪問就配置爲:
network.host: 0.0.0.0
另外還能夠配置訪問的端口,默認是 9200
:
http.port: 9200
注意:這是指 http 端口,若是採用 REST API 對接 Elasticsearch,那麼就是採用的 http 協議。
配置集羣的主機地址,配置以後集羣的主機之間能夠自動發現:
discovery.seed_hosts: ["192.168.3.43"]
the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
必須至少配置 [discovery.seed_hosts,discovery.seed_providers,cluster.initial_master_nodes] 中的一個
總覽:
$ egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml cluster.name: michael-application node.name: es-node-1 path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: 0.0.0.0 http.host: 0.0.0.0 http.port: 9200 discovery.seed_hosts: ["192.168.3.43"] cluster.initial_master_nodes: ["es-node-1"]
要將 Elasticsearch 配置爲在系統啓動時自動啓動,請運行如下命令:
sudo /bin/systemctl daemon-reload sudo /bin/systemctl enable elasticsearch.service
運行和中止 Elasticsearch 命令:
sudo systemctl start elasticsearch.service sudo systemctl stop elasticsearch.service
啓用 systemd 日誌記錄後,可使用 journalctl
命令獲取日誌記錄信息:
sudo journalctl -f sudo journalctl --unit elasticsearch sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
查看 Elasticsearch 信息:
curl -XGE http://192.168.3.43:9200/?pretty
輸出:
{ "name": "es-node-1", "cluster_name": "michael-application", "cluster_uuid": "_na_", "version": { "number": "7.0.0", "build_flavor": "default", "build_type": "rpm", "build_hash": "b7e28a7", "build_date": "2019-04-05T22:55:32.697037Z", "build_snapshot": false, "lucene_version": "8.0.0", "minimum_wire_compatibility_version": "6.7.0", "minimum_index_compatibility_version": "6.0.0-beta1" }, "tagline": "You Know, for Search" }
nodes 字段裏面包含了每一個節點的詳細信息
官網也是有 Kibana 的各個版本的安裝指導
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.0.1-x86_64.rpm shasum -a 512 kibana-7.0.1-x86_64.rpm sudo rpm --install kibana-7.0.1-x86_64.rpm
配置文件在 /etc/kibana/kibana.yml
:
$ egrep -v "^#|^$" /etc/kibana/kibana.yml server.port: 5601 server.host: "0.0.0.0" elasticsearch.hosts: ["http://192.168.3.43:9200"] kibana.index: ".newkibana"
sudo systemctl daemon-reload sudo systemctl enable kibana.service sudo systemctl start kibana.service
這是訪問網址 http://192.168.3.43:5601/
能夠看到 Kinana 界面了
注:192.168.3.43
是我另一臺電腦的 IP