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. MySQL数据库之DML(数据操作语言)

    对表记录的增删改 1.MySQL之DML创建数据表user create table user( id int unsigned not null auto_increment primary key ...

  2. CSIC_716_20191112【闭包函数和装饰器】

    闭包函数 什么是闭包函数:闭包函数是函数嵌套.函数对象.名称空间和作用域的集合体. 闭包函数必须在函数内部定义,闭包函数可以引用外层函数的名字. # _*_ coding: gbk _*_ # @Au ...

  3. Java带头节点单链表的增删合并以及是否有环

    带头节点单链表 1.优势: 1)当链表为空时,指针指向头结点,不会发生null指针异常 2)方便特殊操作(删除第一个有效节点或者插入一个节点在表头) 3)单链表加上头结点之后,无论单链表是否为空,头指 ...

  4. sql语句之分组

    对聚合函数的结果进行筛选用having,不能用where

  5. PHP curl采集

    if (function_exists('curl_init')) { //检查函数是否存在 $url = "http://***.com/"; $ch = curl_init() ...

  6. 思维构造——cf1090D

    /* 只要找到两个没有关系的点即可 */ #include<bits/stdc++.h> using namespace std; #define maxn 100005 long lon ...

  7. Python机器学习的步骤

    原文出处: kdnuggets   译文出处:数据工匠 开始.这是最容易令人丧失斗志的两个字.迈出第一步通常最艰难.当可以选择的方向太多时,就更让人两腿发软了. 从哪里开始? 本文旨在通过七个步骤,使 ...

  8. day 66 Django基础二之URL路由系统

    Django基础二之URL路由系统   本节目录 一 URL配置 二 正则表达式详解 三 分组命名匹配 四 命名URL(别名)和URL反向解析 五 命名空间模式 一 URL配置 Django 1.11 ...

  9. Java程序员必备的10个大数据框架!

    作者:java妞妞 blog.csdn.net/javaniuniu/article/details/71250316 当今IT开发人员面对的最大挑战就是复杂性,硬件越来越复杂,OS越来越复杂,编程语 ...

  10. Java学习之程序运行机制

    Java的运行机制是:先编译,后解释. 典型的编译型编程语言是:C和C++. eg:用c语言编写的*.c文件编译生成*.h文件,通过链接将*.h文件链接成*.exe文件,然后就可以运行,编译型的高级语 ...