ElasticSearch-安装及使用配置
基于ElasticSearch:8.6.2版本,以mac系统为主做的教程,其他系统的安装步骤也都大同小异!
ElasticSearch官方网站
ElasticSearch官方网站: https://www.elastic.co/cn/elasticsearch/
elastic官方网站: https://www.elastic.co/
ElasticSearch相关下载
官网比价慢,如果正好是mac电脑的可以直接在这下载 ,相关的软件
ElasticSearch8.6.2(mac)点击下载
提取码:e5m4
ElasticSearch在线下载教程
ElasticSearch
1、进入ElasticSearch官网点击”下载 Elasticsearch“
2、选择macos下载对应版本
ElasticSearch-Head前端管理工具下载
1.进入github搜索ElasticSearch-Head找到mobz/elasticsearch-head进入克隆即可
ElasticSearch-Head点击直接进入
ElasticSearch-安装
1.把下载好的elasticsearch-8.6.2-darwin-x86_64.tar.gz文件解压,进入到bin目录下双击elasticsearch即可运行,第一次运行等待出现以下内容即运行成功。
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
X-EUHYBVmtlmH4ZghJ3m
ℹ️ HTTP CA certificate SHA-256 fingerprint:
8e4624d6bb7da718ee98f99d1142d44e056a72d4b131be7289c8df6c29a1b534
ℹ️ Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjYuMiIsImFkciI6WyIxMC4zNy4xMjkuMjo5MjAwIl0sImZnciI6IjhlNDYyNGQ2YmI3ZGE3MThlZTk4Zjk5ZDExNDJkNDRlMDU2YTcyZDRiMTMxYmU3Mjg5YzhkZjZjMjlhMWI1MzQiLCJrZXkiOiJuWWdSam9ZQjgxNlpUcjZKektkRDpFYmJHMW9uX1FvdXowbTBQYWEyRkhBIn0=
ℹ️ Configure other nodes to join this cluster:
• On this node:
⁃ Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
⁃ Uncomment the transport.host setting at the end of config/elasticsearch.yml.
⁃ Restart Elasticsearch.
• On other nodes:
⁃ Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.
2、第一次一定要把上面的账号密码以及秘钥记住,否则下次不会再提示
3、运行成功后不要关闭窗口,默认地址为https://localhost:9200,进入后得到以下内容即启动成功!
{
"name" : "wwkdeMacBook-Pro.local",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "5dVFtZrGRiGcrKwEtYPcpA",
"version" : {
"number" : "8.6.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "2d58d0f136141f03239816a4e360a8d17b6d8f29",
"build_date" : "2023-02-13T09:35:20.314882762Z",
"build_snapshot" : false,
"lucene_version" : "9.4.2",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
4、启动成功后需要修改下配置,这里配置文件在config目录中的elasticsearch.yml文件。mac和windows可以直接用记事本或者编辑工具打开,linux可以用vi或vim进行编辑,
- 配置跨域,在文件中增加以下代码
#配置跨域 开启跨域
http.cors.enabled: true
#全部人都可以访问
http.cors.allow-origin: "*"
xpack.ml.enabled: false
- 关闭安全特性,在文件中修改以下代码,都改为false
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
这里要注意8.6.2之前版本不需要关闭安全特性,因为默认是关闭的。
5.配置修改完保存后重启ElasticSearch即可生效
配置ElasticSearch-Head
-
我们可以通过git克隆把项目从gitHub上克隆下来。
ElasticSearch-Head点击直接进入 -
克隆完成后,后端程序员可以用idea打开,前端程序员可以用VSDode打开
-
可以通过一下几个指令来进行安装及启动
Running with built in server
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
open http://localhost:9100/
这里注意最好使用cnpm来安装会快很多,用npm测试过很慢
- 安装淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
解决安装卡顿或无法安装:
# 注册模块镜像
npm set registry https://registry.npm.taobao.org
// node-gyp 编译依赖的 node 源码镜像
npm set disturl https://npm.taobao.org/dist
// 清空缓存
npm cache clean --force
// 安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
4.安装完成后可以用cnpm来安装
cnpm install
npm run start
完成后访问前端页面 http://localhost:9100
==显示继续监看只为绿色即可(上面如果不配置跨域的话会显示红色,就需要去配置下) ==