kibana for MySQL_Kibana 5.x 加强安全

此文之前,假定读者已经一次完成了Kibana和elasticsearch的安装。参考官方文档,安装后默认配置已经可以连通kibana和es。

系统: centos7

内容: 增加authentication & enable ssl

elastic 技术栈 的另外一个重要的角色是x-pack.

5c7c0daaec41db9efc41c3b1c91f0912.png

ES安装xpack插件

参考安装xpack

Run bin/elasticsearch-plugin install from ES_HOME on each node in your cluster:

bin/elasticsearch-plugin install x-pack

Kibana 安装xpack 插件

Install X-Pack into Kibana by running bin/kibana-plugin in your Kibana installation directory.

bin/kibana-plugin install x-pack

依次启动elasticsearch 和kibana

修改用户elastic 和 kibana的密码

X-Pack security provides a built-in elastic superuser you can use to start setting things up. The default password for the elastic user is changeme.

curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -d '{

"password" : "elasticpassword"

}'

curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/kibana/_password' -d '{

"password" : "kibanapassword"

}'

CURL授权

在访问需要授权的页面时,可通过-u选项提供用户名和密码进行授权。 通常的做法是在命令行只输入用户名,之后会提示输入密码,这样可以保证在查看历史记录时不会将密码泄露

Enable Kibana SSL

# SSL for outgoing requests from the Kibana Server (PEM formatted)

server.ssl.key: /path/to/your/server.key

server.ssl.cert: /path/to/your/server.crt

修改了超级用户的密码,enable ssl后,就可以放心的去使用kibana的Dev Tools 或者chrome插件(sense)进行大部分API 的操作。 (在此之前需要ssh到服务器通过curl来操作以保证安全)

创建用户logstash_writer

官方参考

上面步骤完成后会发现logstash推送给es报错了。因为现在ES需要用户名和密码了。 这里我们需要创建一个用户拥有write, delete, and create_index的权限。

[2016-12-23T20:42:19,350][WARN][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>#<:http:0x17b5a1bd url:http:>, :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :error=>"Got response code '401' contact Elasticsearch at URL 'http://localhost:9200/'"}

[2016-12-23T20:42:20,132][WARN][logstash.shutdownwatcher] {}

先创建一个role:logstash_writer

POST _xpack/security/role/logstash_writer

{

"cluster": ["manage_index_templates", "monitor"],

"indices": [

{

"names": [ "logstash-*","business-index-*"],

"privileges": ["write","delete","create_index"]

}

]

}

再创建一个用户:logstash_internal拥有Role:logstash_writer

POST /_xpack/security/user/logstash_internal

{

"password" : "changeme",

"roles" : [ "logstash_writer"],

"full_name" : "Internal Logstash User"

}

上面的操作也可以通过Kibana的Management UI来操作

配置logstash.conf

output {

elasticsearch {

...

user => logstash_internal

password => changeme

}

logstash, elasticsearch, kibana 如果在同一网络,而暴露出去的只有kibana的话,logstash和elasticsearch 之前是无需授权的。可以参考Enabling Anonymous Access 另外,logstash和elasticsearch之间如果需要授权,会不会有性能的影响?

给Kibana用户加上index的读的权限

Kibana安装xpack后默认就需要登录了。也可以用超级用户elastic登录

登录后打开DevTools进行ES API的操作。

修改后停掉kibana服务。修改kibana的配置:

Once you change the password, you need to specify it with the elasticsearch.password property in kibana.yml:

elasticsearch.password: "s0m3th1ngs3cr3t"

坑 (Tricky Part)

/etc/logstash/conf.d 下不要有多余的文件。比如logstash.conf.bak, 似乎logstash会读这个文件夹下的不止logstash.conf这个文件配置。logstash.conf.bak 会导致死循环一样的重启。elastic community

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值