简介

官网-安装介绍 这里记载了各个软件包的安装方法,Linux Mac Windows……

本文记载的是在 CentOS 系统安装 Elasticsearch 7.0.0 版本的步骤。

安装 Java

之前写过一篇文章介绍了 Java 的安装,参考 Linux 安装 JDK

注意:只有配置了 JAVA_HOME 环境变量,安装 Elasticsearch 时才会采用系统已安装的 JDK。

$ env|grep JAVA
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

导入 Elasticsearch PGP Key

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

利用 RPM repository 安装

/etc/yum.repos.d/ 创建 elasticsearch.repo ,内容:

[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

然后输入如下命令即可安装:

sudo yum install elasticsearch

手动下载 RPM 包安装

有时候,我们的环境是无法连接外网的,这时候这种方式就可以用来解决这个问题:

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

安装结果:

# 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

配置 Elasticsearch

安装完成之后,配置文件在 /etc/elasticsearch/elasticsearch.yml

官网有更详细的配置介绍,本文仅搭建一个 master 节点的 Elasticsearch 服务,未搭建集群。

  • 集群的名称

通过 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"]

使用 systemd 命令运行 Elasticsearch

要将 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

官网也是有 Kibana 的各个版本的安装指导

手动下载 Kibana RPM 包安装

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

Kibana 配置

配置文件在 /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"

运行 Kibana 服务

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

FAQ

Kibana server is not ready yet

参考

最新文章

  1. OAF 中的EO 和VO
  2. 深入理解PHP内核(十三)类的结构和实现
  3. Java并发包源码学习之AQS框架(二)CLH lock queue和自旋锁
  4. 关于IE9中webdiriver使用autoit上传文件报错
  5. golang的序列与反序列化
  6. iOS 开发--转场动画
  7. Java通过代理类实现数据库DAO操作
  8. 一种轻量的openresty路由设计
  9. C#学习第二天
  10. javascript模式——Flyweight
  11. spring学习参考资料
  12. shell编程之sed
  13. python学习:递归列出目录里的文件
  14. kafka 集群
  15. 第十三届东北师范大学程序设计竞赛热身赛 C(exgcd+欧拉函数)
  16. postgresql 空间函数 随笔
  17. l^oo不可分的两个注意点
  18. 【LeetCode每天一题】Spiral Matrix(螺旋打印数组)
  19. JavaScript各种继承方式(四):原型式继承(prototypal inheritance)
  20. Jquery组织Form表单提交之Form submission canceled because the form is not connected

热门文章

  1. Servlet相关的几种乱码
  2. Tomcat的安装以及环境变量的配置
  3. em,rem,px的区别,以及实现原理?
  4. docker中mysql pxc集群
  5. ROS tf监听编写
  6. [LeetCode] 247. Strobogrammatic Number II 对称数II
  7. 【SSH进阶之路】Spring的AOP逐层深入——AOP的基本原理(六)
  8. 下载youtube视频到本地
  9. jenkins:新增节点是启动方式没有Launch agent by connecting it to the master
  10. 【视频开发】【计算机视觉】doppia编译之四:安装其他库、编译和运行doppia