海量日志系统ElasticSearch插件管理
elasticsearch-head
elasticsearch-head是集群管理、数据可视化、增删改查、查询语句可视化工具。从ES5版本后安装方式和ES2以上的版本有很大的不同,在ES2中可以直接在bin目录下执行plugin install xxxx 来进行安装,但是在ES5中这种安装方式变了,要想在ES5中安装Elasticsearch Head必须要安装NodeJs,然后通过NodeJS来启动Head。
官网地址:https://github.com/mobz/elasticsearch-head
elasticsearch-head安装
第1步: 下载相关软件并上传到服务器
官网有安装说明,可以通过git安装,也可以下载zip包解压安装
下载相应的软件包,并拷贝到ES集群的一个节点上(我这里拷贝到es02这台,也就是es01上)
nodejs下载页面: https://nodejs.org/en/download/
第2步: 安装nodejs
[root@es01 ~]# tar xf node-v10.15.0-linux-x64.tar.xz -C /usr/local/
[root@es01 ~]# mv /usr/local/node-v10.15.0-linux-x64/ /usr/local/nodejs/
[root@es01 ~]# ls /usr/local/nodejs/bin/npm
/usr/local/nodejs/bin/npm 确认有此命令
[root@es01 ~]# ln -s /usr/local/nodejs/bin/npm /bin/npm
[root@es01 ~]# ln -s /usr/local/nodejs/bin/node /bin/node
第3步: 安装es-head
安装方法1(需要网速好):
[root@es01 ~]# git clone git://github.com/mobz/elasticsearch-head.git
[root@es01 ~]# cd elasticsearch-head
先使用npm安装grunt
npm(node package manager):node包管理工具,类似yum
Grunt是基于Node.js的项目构建工具
[root@es01 elasticsearch-head]# npm install -g grunt-cli
安装时间较久,还会在网上下载phantomjs包
[root@es01 elasticsearch-head]# npm install
安装可能有很多错误,我这里出现了下面的错误(重点是注意红色的ERR!,黄色的WARN不用管)
解决方法:
[root@es01 elasticsearch-head]# npm install phantomjs-prebuilt@2.1.16 --ignore-script
此命令执行后不用再返回去执行npm install了,直接开始启动
[root@es01 elasticsearch-head]# nohup npm run start &
安装方法二 : (==网速特别慢导致安装时间过长的话可以尝试以下方法==)
git clone慢的话就使用下载好的zip压缩包解压安装
[root@es01 ~]# unzip elasticsearch-head-master.zip -d /usr/local/
[root@es01 ~]# mv /usr/local/elasticsearch-head-master/ /usr/local/es-head/
[root@es01 ~]# cd /usr/local/es-head/
[root@es01 es-head]# npm install -g grunt-cli --registry=http://registry.npm.taobao.org
[root@es01 es-head]# npm install --registry=http://registry.npm.taobao.org
当安装出现下载phantomjs软件包特别慢的时候,可以ctrl+c取消,拷贝下载好的phantomjs包到特定位置再重新安装
[root@es01 es-head]# cp phantomjs-2.1.1-linux-x86_64.tar.bz2 /tmp/phantomjs/
注意:phantomjs请改成自己的绝对路径
[root@es01 es-head]# npm install --registry=http://registry.npm.taobao.org
[root@es01 es-head]# nohup npm run start &
==注意: 运行nohup npm run start &
必须要先cd到es-head的目录==
第4步:浏览器访问
浏览器访问http://es-head节点IP:9100
,并在下面的地址里把localhost改为es-head节点IP(浏览器与es-head不是同一节点就要做)
第5步: 修改ES集群配置文件,并重启服务
[root@vm1 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: elk-cluster
node.name: es01
node.master: false
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["es01", "es02"]
http.cors.enabled: true
http.cors.allow-origin: "*" 加上最后这两句
[root@es01 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#"
cluster.name: elk-cluster
node.name: es02
node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["es01", "es02"]
http.cors.enabled: true
http.cors.allow-origin: "*" 加上最后这两句
[root@vm1 ~]# systemctl restart elasticsearch
[root@es01 ~]# systemctl restart elasticsearch
第6步: 再次连接就可以看到信息了
插件安装:
浏览器--》扩展--》管理扩展--》
新建个索引试试 删除此索引
es-head查询验证
总结
创建索引
功能:指定分片、副本数及映射规则。
示例:PUT /<index_name>,可定义 settings(如分片数)和 mappings(字段类型)。
修改索引配置
动态参数:如副本数、刷新间隔等,可通过 PUT /<index_name>/_settings 调整。
静态参数:如初始分片数,仅能在创建时设置2。
删除索引
命令:DELETE /<index_name>,直接移除整个索引及其数据。
判断索引状态
存在性检测:HEAD /<index_name>,返回成功表示存在。
- 点赞
- 收藏
- 关注作者
评论(0)