Elasticsearch & Kibana with Shield
 
官方网站:
 
 
环境:
kibana-4.5.0
elasticsearch-2.3.2
shield-2.3.2
license-2.3.2
 
 
前言:
Shield作为安全插件可以嵌入到ELK当中,商业授权,前30天免费
支持多种认证方式nativefileLDAPActive DirectoryPKI,详情见https://www.elastic.co/guide/en/shield/current/how-shield-works.html
这里以file,native为例
 
 
Elasticsearch with Shield
一.停止所有elasticsearch节点
说明:shield安装,卸载,升级都需要重启elasticsearch节点
 
二.安装shield插件(所有elasticsearch节点)
说明:shield版本必须和elasticsearch保持一致
在线安装

/opt/elasticsearch-2.3.2/bin/plugin install license

/opt/elasticsearch-2.3.2/bin/plugin install shield

或离线安装

/opt/elasticsearch-2.3.2/bin/plugin install file:///root/license-2.3.2.zip 
/opt/elasticsearch-2.3.2/bin/plugin install file:///root/shield-2.3.2.zip
 

[root@ela-master1 ~]# /opt/elasticsearch-2.3.2/bin/plugin install file:///root/license-2.3.2.zip

-> Installing from file:/root/license-2.3.2.zip...

Trying file:/root/license-2.3.2.zip ...

Downloading .DONE

Verifying file:/root/license-2.3.2.zip checksums if available ...

NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)

Installed license into /opt/elasticsearch-2.3.2/plugins/license

[root@ela-master1 ~]# /opt/elasticsearch-2.3.2/bin/plugin install file:///root/shield-2.3.2.zip

-> Installing from file:/root/shield-2.3.2.zip...

Trying file:/root/shield-2.3.2.zip ...

Downloading .......................DONE

Verifying file:/root/shield-2.3.2.zip checksums if available ...

NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)

Installed shield into /opt/elasticsearch-2.3.2/plugins/shield

 
注意:一旦shield安装成功,在elasticsearch重启后,对elasticsearch的任何操作都需要授权(用户名和密码),除非启用匿名用户https://www.elastic.co/guide/en/shield/current/anonymous-access.html
 
三.配置realm
A.配置file-realm(所有节点)
1.增加file-realm配置
cat >>/opt/elasticsearch-2.3.2/config/elasticsearch.yml <<HERE

shield.authc.realms.file1.type: file

shield.authc.realms.file1.order: 0

HERE

2.启动(或重启)elasticsearch

3.创建file based用户

https://www.elastic.co/guide/en/shield/current/defining-roles.html#valid-role-name

https://www.elastic.co/guide/en/shield/current/enable-basic-auth.html

/opt/elasticsearch-2.3.2/bin/shield/esusers useradd es_admin -p P@ssw0rd -r admin

/opt/elasticsearch-2.3.2/bin/shield/esusers useradd kibana -p P@ssw0rd -r kibana4_server

[root@ela-client ~]# /opt/elasticsearch-2.3.2/bin/shield/esusers list

es_admin       : admin

kibana         : kibana4_server

说明:这里创建了两个用户es_admin(用户名 es_admin, 密码P@ssw0rd, 角色admin)和kibana,用户角色定义可以参看shield配置文件/opt/elasticsearch-2.3.2/config/shield/roles.yml
4.file based用户同步到集群其它节点
注意:对于用户和角色的所有操作默认都存放在如下位置,因此集群中的所有节点都需要上面同样的操作,当然,也可以直接copy如下文件到其它节点的对应目录

/opt/elasticsearch-2.3.2/config/shield/users

/opt/elasticsearch-2.3.2/config/shield/users_roles

5.测试用户认证

[root@ela-client ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_cat/health?v'

epoch      timestamp cluster               status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent

1462705707 19:08:27  elasticsearch_cluster green           6         2     52  26    0    0       0             0                  -                100.0%

[root@ela-client ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_cat/indices?v'

health status index               pri rep docs.count docs.deleted store.size pri.store.size

green  open   shakespeare           5   1     111396            0     36.5mb         18.2mb

green  open   logstash-2015.05.20   5   1       4750            0     72.9mb         35.7mb

green  open   bank                  5   1       1000            0    890.5kb       447.9kb

green  open   .kibana               1   1          4            0     44.5kb        22.2kb

green  open   logstash-2015.05.18   5   1       4631            0     64.9mb         32.7mb

green  open   logstash-2015.05.19   5   1       4624            0     66.7mb           32mb

B.配置native-realm(所有节点)
默认情况下, native-realm已经被配置到了realm链里, 可以直接通过REST API来添加删除用户,修改用户密码及管理角色, 这也是官方推荐的认证方式
1.增加native-realm配置
cat >>/opt/elasticsearch-2.3.2/config/elasticsearch.yml <<HERE

shield.authc.realms.native1.type: native

shield.authc.realms.native1.order: 0

HERE

2.启动(或重启)elasticsearch

3.创建native用户

curl -u es_admin:P@ssw0rd -XPOST 'http://localhost:9200/_shield/user/fooadmin' -d '

{

"password" : "foo.123",

"roles" : [ "admin", "other_role1" ],

"full_name" : "Jlive Liu",

"email" : "iliujun_live@163.com",

"metadata" : {

"intelligence" : 7

}

}

'

说明:

1.新增native用户也需要认证,但启用了shield之后默认是没有native用户的,所以就需要借助file based用户来授权

2.native用户是存放在elasticsearch集群中,集群中的所有节点会自动同步

[root@ela-client ~]# curl -u es_admin:P@ssw0rd -XPOST 'http://localhost:9200/_shield/user/fooadmin' -d '

{

"password" : "foo.123",

"roles" : [ "admin", "other_role1" ],

"full_name" : "Jlive Liu",

"email" : "iliujun_live@163.com",

"metadata" : {

"intelligence" : 7

}

}

'

{"user":{"created":true}}

[root@ela-data1 ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_shield/user'

{"fooadmin":{"username":"fooadmin","roles":["admin","other_role1"],"full_name":"Jlive Liu","email":"iliujun_live@163.com","metadata":{"intelligence":7}}}

4.测试用户认证

[root@ela-master2 ~]# curl -u fooadmin:foo.123 'http://localhost:9200/_cat/health?v'

epoch      timestamp cluster               status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent

1462707192 19:33:12  elasticsearch_cluster green           6         2     54  27    0    0       0             0                  -                100.0%

Elasticsearch & Kibana with Shield的更多相关文章

  1. 安装logstash,elasticsearch,kibana三件套

    logstash,elasticsearch,kibana三件套 elk是指logstash,elasticsearch,kibana三件套,这三件套可以组成日志分析和监控工具 注意: 关于安装文档, ...

  2. 使用logstash+elasticsearch+kibana快速搭建日志平台

    日志的分析和监控在系统开发中占非常重要的地位,系统越复杂,日志的分析和监控就越重要,常见的需求有: * 根据关键字查询日志详情 * 监控系统的运行状况 * 统计分析,比如接口的调用次数.执行时间.成功 ...

  3. lagstash + elasticsearch + kibana 3 + kafka 日志管理系统部署 02

    因公司数据安全和分析的需要,故调研了一下 GlusterFS + lagstash + elasticsearch + kibana 3 + redis 整合在一起的日志管理应用: 安装,配置过程,使 ...

  4. 安装logstash,elasticsearch,kibana三件套(转)

    logstash,elasticsearch,kibana三件套 elk是指logstash,elasticsearch,kibana三件套,这三件套可以组成日志分析和监控工具 注意: 关于安装文档, ...

  5. ElasticSearch+Kibana 索引操作

    ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...

  6. logstash+ElasticSearch+Kibana VS Splunk

    logstash+ElasticSearch+Kibana VS Splunk 最近帮磊哥移植一套开源的日志管理软件,替代Splunk. Splunk是一个功能强大的日志管理工具,它不仅可以用多种方式 ...

  7. logstash+elasticsearch+kibana快速搭建日志平台

    使用logstash+elasticsearch+kibana快速搭建日志平台   日志的分析和监控在系统开发中占非常重要的地位,系统越复杂,日志的分析和监控就越重要,常见的需求有: 根据关键字查询日 ...

  8. Elasticsearch,Kibana,Logstash,NLog实现ASP.NET Core 分布式日志系统

    Elasticsearch - 简介 Elasticsearch 作为核心的部分,是一个具有强大索引功能的文档存储库,并且可以通过 REST API 来搜索数据.它使用 Java 编写,基于 Apac ...

  9. 快速搭建应用服务日志收集系统(Filebeat + ElasticSearch + kibana)

    快速搭建应用服务日志收集系统(Filebeat + ElasticSearch + kibana) 概要说明 需求场景,系统环境是CentOS,多个应用部署在多台服务器上,平时查看应用日志及排查问题十 ...

随机推荐

  1. SQLSTATE[HY000]: General error: 1366 Incorrect string value

    在Laravel项目的 storages/logs/Laravel.log看到的错误信息片段: SQLSTATE[HY000]: General error: 1366 Incorrect strin ...

  2. vs2013x64&&qt5.7.1编译osg3.4.0&&osgEarth2.7

    此文仅备忘: 1.安装VS2013_Cn_Ult 2.安装qt-opensource-windows-x86-msvc2013_64-5.7.1 设置环境变量QTDIR,并将其bin加入到path中. ...

  3. for循环和字典预习

    print("*" *8)for a in range(1,9): print(a,end="")#1-9的奇数print()for a in range(1, ...

  4. flink提交文件出现java.io.IOException:unable to close file because the last block does not have enough number of replicas异常

    当提交已经打包好的jar包时候,控制台出现以下的错误.

  5. 段错误 “段错误(segment fault)”、“非法操作,该内存地址不能read/write” 非法指针解引用造成的错误。

    [root@test after_fc_distributed]# ./ffmpeg-linux64-v3.3.1 -i "concat:mymp3tmp/test_0.mp3|mymp3t ...

  6. VS2010-MFC(常用控件:树形控件Tree Control 上)

    转自:http://www.jizhuomi.com/software/200.html 前面两节讲了列表视图控件List Control,这一节开始介绍一种特殊的列表--树形控件Tree Contr ...

  7. JAVA工具包_BeanUtils

    简介 大多数的java开发者通常在创建Java类的时候都会遵循JavaBean的命名模式,对类的属性生成getters方法和setters方法.通过调用相应的getXxx和setXxx方法,直接访问这 ...

  8. js比较常用的

    1. <a href="javascript:void(0);" id="div1_bu" >点击链接可以删除div2</a> 超链接的 ...

  9. MME、PGW、SGW和PCRF的介绍

    1.简介原文连接:https://blog.csdn.net/Rong_Toa/article/details/94983607 用户面和控制面板分离2.什么是HSS?HSS有什么主要功能?HSS与H ...

  10. jQuery鼠标拖曳改变div大小(模拟textarea右下角拖曳)

    jQuery.fn.extend({ drag: function() { $(document).off("mouseup.drag").on("mouseup.dra ...