Elasticsearch 安装head插件

18 阅读1分钟

使用的系统

root@asrock:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 26.04 LTS
Release:        26.04
Codename:       resolute

使用的Elasticsearch版本

{

-   "name": "asrock",

-   "cluster_name": "elasticsearch",

-   "cluster_uuid": "V-68emENTM26Hj6NzcmE0A",

-   "version": {

    -   "number": "8.19.19",
    -   "build_flavor": "default",
    -   "build_type": "tar",
    -   "build_hash": "0b6bd198d583b8566336c0db61afb70b346c6882",
    -   "build_date": "2026-07-15T22:15:58.852563788Z",
    -   "build_snapshot": false,
    -   "lucene_version": "9.12.2",
    -   "minimum_wire_compatibility_version": "7.17.0",
    -   "minimum_index_compatibility_version": "7.0.0"

    },

-   "tagline": "You Know, for Search"

}

安装node

启动head需要使用node运行

apt install nodejs npm 

启动head

下载安装

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install

修改监听所有的IP

添加一个hostname: "*"选项

image.png

启动

npm run start

设置Elasticsearch支持跨域

修改conf目录下的elasticsearch.yml文件,添加如下内容

http.cors.enabled: true 
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length

重新启动Elasticsearch

访问head

因为ES启用了密码,所以在head中访问的时候url要带上用户名和密码

image.png

我的请求链接是这个
https://192.168.0.7:9200/?auth_user=elastic&auth_password=NhpL_Q2qNxPoWWIPKi_%3D

点击连接后可以正常使用了

image.png

注意: 如果还是连接不上需要查看es是否可以访问https页面,因为我用的自签署证书。

image.png

参考文章