今天没事折腾了一下,整体难度不大。希望对你有用。
首先安装es和kibana
下载:https://www.elastic.co/downloads/elasticsearch
1、安装ES
tar zxvf elasticsearch-6.4.0.tar.gz
cp -rf elasticsearch-6.4.0 /opt/elasticsearch
useradd elastic -d /opt/elasticsearch
chown -R elastic:elastic /opt/elasticsearch
编辑/etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
命令行执行
sysctl -p
编辑 /etc/security/limits.conf,追加以下内容;
* soft nofile 65536
* hard nofile 131072
编辑 /opt/elasticsearch/config/elasticsearch.yml
cluster.name: es-log
node.name: node-1
path.data: /opt/elasticsearch/data
path.logs: /opt/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"
启动ES,查看9200端口是否启动
2、安装kibana
cp -rf kibana-6.4.0-linux-x86_64 /opt/kibana
后到kibana安装目录的config下,编辑kibana.yml配置文件,添加如下配置:
server.port: 5601
server.host: "
你的ip
"
elasticsearch.url: "http://
你的ip
:9200"
kibana.index: ".kibana"
启动kibana,查看5601端口
首先安装zabbix
安装过程略,可以会遇到一些问题,比如:
22988:20181012:151559.821 cannot initialize history storage: cURL library support >= 7.28.0 is required for Elasticsearch history backend
需要升级libcurl
rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-2-1.rhel6.noarch.rpm
yum upgrade curl libcurl libcurl-devel
大部分lib库的问题,安装对应的devel就可以
配置:
首先配置zabbix在es里的索引
在zabbix-3.4.14/database/elasticsearch/找到elasticsearch.map文件,按照一下命令依次创建uint、dbl、log、str、text索引
uint列子:
curl -X PUT \
http://192.168.50.50:9200/uint \
-H 'content-type:application/json' \
-d '{
"settings" : {
"index" : {
"number_of_replicas" : 1,
"number_of_shards" : 5
}
},
"mappings" : {
"values" : {
"properties" : {
"itemid" : {
"type" : "long"
},
"clock" : {
"format" : "epoch_second",
"type" : "date"
},
"value" : {
"type" : "long"
}
}
}
}
}'
配置zabbix server配置文件,在原来配置最后面添加
HistoryStorageURL=http://
你的ip
:9200
HistoryStorageTypes=uint,dbl,str,log,text
在zabbix的php前端配置里修改为:
global $DB; -->
global $DB, $HISTORY;
添加
$HISTORY['url'] = 'http://
你的ip
:9200';
$HISTORY['types'] = ['uint', 'dbl', 'str', 'text', 'log'];
在kibana里给uint、dbl、str、text、log创建index pattern。
在kibana和zabbix latest data里查看数据是否正确。
kibana需要做一些设置,为了让数字看起来正常点,修改这个