第一章 Elasticsearch及elasticsearch-head安装运行
文章目录
一、Elasticsearch
1.Elasticsearch下载
官网下载比较慢,https://mirrors.huaweicloud.com/elasticsearch/ 这个快,本文采用7.9.3版本,macOS系统
2.修改配置文件
vim config/elasticsearch.yml
network.host: 0.0.0.0 #设置ip地址,任意网络均可访问
# 开启跨域访问支持,默认为false
http.cors.enabled: true
# 跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: /.*/
cluster.name: my-application
cluster.initial_master_nodes: ["node-1"]
node.name: node-1
discovery.seed_hosts: ["host1", "host2"]
3.启动ES服务
cd bin
./elasticsearch 或 ./elasticsearch -d #后台启动
浏览器访问localhost:9200,见如下内容即启动成功,9200为默认端口
{
"name": "node-1",
"cluster_name": "my-application",
"cluster_uuid": "4EkkORIsSJCkhBePDoegWA",
"version": {
"number": "7.9.3",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "c4138e51121ef06a6404866cddc601906fe5c868",
"build_date": "2020-10-16T10:36:16.141335Z",
"build_snapshot": false,
"lucene_version": "8.6.2",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
二、elasticsearch-head
由于ES官方并没有为ES提供界面管理工具,仅仅是提供了后台的服务。elasticsearch-head是一个为ES开发的一个页
面客户端工具,其源码托管于GitHub,地址为:https://github.com/mobz/elasticsearch-head
本文利用docker安装
#拉取镜像
docker pull mobz/elasticsearch-head:5
创建容器
docker create --name elasticsearch-head -p 9100:9100 mobz/elasticsearch-head:5
#启动容器
docker start elasticsearch-head
浏览器访问http://localhost:9100/