一、升级 cURL

注:先升级 cURL,然后在安装 Zabbix Server,否则报如下错误:

 

cannot initialize history storage: cURL library support >= 7.28.0 is required for Elasticsearch history backend

开始升级 cURL:

[root@jrgc ~]# uname -r2.6.32-642.el6.x86_64[root@jrgc docs]# curl --versioncurl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftpFeatures: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz[root@jrgc ~]# rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpmRetrieving http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpmwarning: /var/tmp/rpm-tmp.1lrKA3: Header V3 DSA/SHA1 Signature, key ID b56a8bac: NOKEYPreparing...                ########################################### [100%]   1:city-fan.org-release   ########################################### [100%][root@jrgc ~ ]# yum upgrade libcurlLoaded plugins: fastestmirror, securitySetting up Upgrade ProcessLoading mirror speeds from cached hostfile* city-fan.org: nervion.us.escity-fan.org                                                                                                  | 2.9 kB     00:00     city-fan.org/primary_db                                                                                       | 459 kB     00:15     Resolving Dependencies--> Running transaction check---> Package libcurl.x86_64 0:7.19.7-53.el6_9 will be updated--> Processing Dependency: libcurl = 7.19.7-53.el6_9 for package: curl-7.19.7-53.el6_9.x86_64--> Processing Dependency: libcurl = 7.19.7-53.el6_9 for package: libcurl-devel-7.19.7-53.el6_9.x86_64---> Package libcurl.x86_64 0:7.57.0-1.0.cf.rhel6 will be an update--> Processing Dependency: libssh2(x86-64) >= 1.8.0 for package: libcurl-7.57.0-1.0.cf.rhel6.x86_64--> Processing Dependency: c-ares(x86-64) >= 1.13.0 for package: libcurl-7.57.0-1.0.cf.rhel6.x86_64--> Processing Dependency: libnghttp2.so.14()(64bit) for package: libcurl-7.57.0-1.0.cf.rhel6.x86_64--> Running transaction check---> Package c-ares.x86_64 0:1.10.0-3.el6 will be updated---> Package c-ares.x86_64 0:1.13.0-3.0.cf.rhel6 will be an update---> Package curl.x86_64 0:7.19.7-53.el6_9 will be updated---> Package curl.x86_64 0:7.57.0-1.0.cf.rhel6 will be an update--> Processing Dependency: libmetalink.so.3()(64bit) for package: curl-7.57.0-1.0.cf.rhel6.x86_64---> Package libcurl-devel.x86_64 0:7.19.7-53.el6_9 will be updated---> Package libcurl-devel.x86_64 0:7.57.0-1.0.cf.rhel6 will be an updateepel/filelists_db                                                                                             | 7.8 MB     00:00     city-fan.org/filelists_db                                                                                     | 334 kB     00:20     --> Processing Dependency: libssh2-devel for package: libcurl-devel-7.57.0-1.0.cf.rhel6.x86_64---> Package libnghttp2.x86_64 0:1.6.0-1.el6.1 will be installed---> Package libssh2.x86_64 0:1.4.2-2.el6_7.1 will be updated---> Package libssh2.x86_64 0:1.8.0-5.0.cf.rhel6 will be an update--> Running transaction check---> Package libmetalink.x86_64 0:0.1.3-4.rhel6 will be installed---> Package libssh2-devel.x86_64 0:1.8.0-5.0.cf.rhel6 will be installed--> Finished Dependency ResolutionDependencies Resolved=====================================================================================================================================Package                         Arch                     Version                               Repository                      Size=====================================================================================================================================Updating:libcurl                         x86_64                   7.57.0-1.0.cf.rhel6                   city-fan.org                   427 kInstalling for dependencies:libmetalink                     x86_64                   0.1.3-4.rhel6                         city-fan.org                    24 klibnghttp2                      x86_64                   1.6.0-1.el6.1                         epel                            56 klibssh2-devel                   x86_64                   1.8.0-5.0.cf.rhel6                    city-fan.org                    73 kUpdating for dependencies:c-ares                          x86_64                   1.13.0-3.0.cf.rhel6                   city-fan.org                    97 kcurl                            x86_64                   7.57.0-1.0.cf.rhel6                   city-fan.org                   494 klibcurl-devel                   x86_64                   7.57.0-1.0.cf.rhel6                   city-fan.org                   946 klibssh2                         x86_64                   1.8.0-5.0.cf.rhel6                    city-fan.org                    99 kTransaction Summary=====================================================================================================================================Install       3 Package(s)Upgrade       5 Package(s)Total download size: 2.2 MIs this ok [y/N]: yDownloading Packages:(1/8): c-ares-1.13.0-3.0.cf.rhel6.x86_64.rpm                                                                  |  97 kB     00:06     (2/8): curl-7.57.0-1.0.cf.rhel6.x86_64.rpm                                                                    | 494 kB     00:27     (3/8): libcurl-7.57.0-1.0.cf.rhel6.x86_64.rpm                                                                 | 427 kB     00:26     (4/8): libcurl-devel-7.57.0-1.0.cf.rhel6.x86_64.rpm                                                           | 946 kB     00:56     (5/8): libmetalink-0.1.3-4.rhel6.x86_64.rpm                                                                   |  24 kB     00:01     (6/8): libnghttp2-1.6.0-1.el6.1.x86_64.rpm                                                                    |  56 kB     00:00     (7/8): libssh2-1.8.0-5.0.cf.rhel6.x86_64.rpm                                                                  |  99 kB     00:04     (8/8): libssh2-devel-1.8.0-5.0.cf.rhel6.x86_64.rpm                                                            |  73 kB     00:05     -------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                 17 kB/s | 2.2 MB     02:12     warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID b56a8bac: NOKEYRetrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-city-fan.orgImporting GPG key 0xB56A8BAC:Userid : city-fan.org software librarian 
Package: city-fan.org-release-1-13.rhel6.noarch (installed)From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-city-fan.orgIs this ok [y/N]: yRunning rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum.  Updating   : libssh2-1.8.0-5.0.cf.rhel6.x86_64                                                                                1/13  Installing : libssh2-devel-1.8.0-5.0.cf.rhel6.x86_64                                                                          2/13  Updating   : c-ares-1.13.0-3.0.cf.rhel6.x86_64                                                                                3/13  Installing : libmetalink-0.1.3-4.rhel6.x86_64                                                                                 4/13  Installing : libnghttp2-1.6.0-1.el6.1.x86_64                                                                                  5/13  Updating   : libcurl-7.57.0-1.0.cf.rhel6.x86_64                                                                               6/13  Updating   : libcurl-devel-7.57.0-1.0.cf.rhel6.x86_64                                                                         7/13  Updating   : curl-7.57.0-1.0.cf.rhel6.x86_64                                                                                  8/13  Cleanup    : libcurl-devel-7.19.7-53.el6_9.x86_64                                                                             9/13  Cleanup    : curl-7.19.7-53.el6_9.x86_64                                                                                     10/13  Cleanup    : libcurl-7.19.7-53.el6_9.x86_64                                                                                  11/13  Cleanup    : libssh2-1.4.2-2.el6_7.1.x86_64                                                                                  12/13  Cleanup    : c-ares-1.10.0-3.el6.x86_64                                                                                      13/13  Verifying  : libnghttp2-1.6.0-1.el6.1.x86_64                                                                                  1/13  Verifying  : libcurl-devel-7.57.0-1.0.cf.rhel6.x86_64                                                                         2/13  Verifying  : libmetalink-0.1.3-4.rhel6.x86_64                                                                                 3/13  Verifying  : libssh2-1.8.0-5.0.cf.rhel6.x86_64                                                                                4/13  Verifying  : libcurl-7.57.0-1.0.cf.rhel6.x86_64                                                                               5/13  Verifying  : libssh2-devel-1.8.0-5.0.cf.rhel6.x86_64                                                                          6/13  Verifying  : curl-7.57.0-1.0.cf.rhel6.x86_64                                                                                  7/13  Verifying  : c-ares-1.13.0-3.0.cf.rhel6.x86_64                                                                                8/13  Verifying  : libssh2-1.4.2-2.el6_7.1.x86_64                                                                                   9/13  Verifying  : libcurl-devel-7.19.7-53.el6_9.x86_64                                                                            10/13  Verifying  : libcurl-7.19.7-53.el6_9.x86_64                                                                                  11/13  Verifying  : curl-7.19.7-53.el6_9.x86_64                                                                                     12/13  Verifying  : c-ares-1.10.0-3.el6.x86_64                                                                                      13/13Dependency Installed:  libmetalink.x86_64 0:0.1.3-4.rhel6        libnghttp2.x86_64 0:1.6.0-1.el6.1        libssh2-devel.x86_64 0:1.8.0-5.0.cf.rhel6       Updated:  libcurl.x86_64 0:7.57.0-1.0.cf.rhel6                                                                                               Dependency Updated:  c-ares.x86_64 0:1.13.0-3.0.cf.rhel6       curl.x86_64 0:7.57.0-1.0.cf.rhel6       libcurl-devel.x86_64 0:7.57.0-1.0.cf.rhel6        libssh2.x86_64 0:1.8.0-5.0.cf.rhel6      Complete![root@jrgc~]# curl --version                   curl 7.57.0 (x86_64-pc-linux-gnu) libcurl/7.57.0 OpenSSL/1.0.1e zlib/1.2.3Release-Date: 2017-11-29Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftpFeatures: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets HTTPS-proxy

新网址,访问要往下拉,就可以看见所需软件包,同时需要随时关注。

yumrsync.jpg

升级 Zabbix

见 Zabbix 3.2 升级到 Zabbix 3.4.6

二、编辑配置 Zabbix 3.4.6 相关配置文件

Zabbix Web 配置历史数据读 Elasticsearch[root@jrgc ~]# rm -rf /app/product/nginx/html/zabbix/conf/{zabbix.conf.php,zabbix.conf.php.example}[root@jrgc ~]# cp /opt/software/zabbix-3.4.6/frontends/php/conf/zabbix.conf.php.example /app/product/nginx/html/zabbix/conf/[root@jrgc ~]# cd /app/product/nginx/html/zabbix/conf[root@jrgc conf]# cp zabbix.conf.php.example zabbix.conf.php[root@jrgc conf]# lsmaintenance.inc.php  zabbix.conf.php  zabbix.conf.php.example[root@jrgc conf]# vim zabbix.conf.php
 'http://192.168.29.21:9200 ',    'text' => 'http://192.168.29.22:9200 '];$HISTORY['types'] = ['uint', 'text'];Zabbix Server 配置支持 Elasticsearch[root@jrgc etc]# vim zabbix_server.conf### Option: HistoryStorageURL#       History storage HTTP[S] URL.## Mandatory: no# Default:HistoryStorageURL=http://192.168.29.21:9200### Option: HistoryStorageTypes#       Comma separated list of value types to be sent to the history storage.## Mandatory: no# Default:HistoryStorageTypes=uint,dbl,str,log,text停止 Zabbix Server[root@jrgc ~]# /etc/init.d/zabbix_server stopShutting down zabbix_server:                                     [  OK  ]

Elasticsearch 支持的监控项类型:uint,dbl,str,log,text

监控项数据类型|数据库表|对应 Elasticsearch 类型:

监控项数据类型
数据库表
对应Elasticsearch类型
Numeric(unsigned) history_uint uint
Numeric(float)
history dbl
Character
history_str
str
Log
history_log
log
Text
history_text
text

三、编辑 Elasticsearch 文件

[root@jrgc ~]# cd /opt/software/zabbix-3.4.6/database/elasticsearch/[root@jrgc elasticsearch]# lltotal 4-rw-r--r-- 1 1001 1001 3142 Jan 15 17:11 elasticsearch.map[root@jrgc elasticsearch]# more elasticsearch.map# uint mapping{   "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"            }         }      }   }}# dbl mapping{   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "type" : "double"            }         }      }   }}# str mapping{   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }}# text mapping{   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }}# log mapping{   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }}[root@jrgc ~]# curl -XPUT http://192.168.29.21:9200/uint -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"            }         }      }   }}'{"acknowledged":true,"shards_acknowledged":true}[root@jrgc ~]# curl -XPUT http://192.168.29.21:9200/dbl -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" : "double"            }         }      }   }}'{"acknowledged":true,"shards_acknowledged":true}[root@jrgc elasticsearch]# curl -XPUT http://192.168.29.21:9200/log -d ' {   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }} '{"acknowledged":true,"shards_acknowledged":true}[root@jrgc ~]# curl -XPUT http://192.168.29.21:9200/text -d ' {   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }} '{"acknowledged":true,"shards_acknowledged":true}[root@jrgc ~]# curl -XPUT http://192.168.29.21:9200/str -d ' {   "settings" : {      "index" : {         "number_of_replicas" : 1,         "number_of_shards" : 5      }   },   "mappings" : {      "values" : {         "properties" : {            "itemid" : {               "type" : "long"            },            "clock" : {               "format" : "epoch_second",               "type" : "date"            },            "value" : {               "fields" : {                  "analyzed" : {                     "index" : true,                     "type" : "text",                     "analyzer" : "standard"                  }               },               "index" : false,               "type" : "text"            }         }      }   }} '{"acknowledged":true,"shards_acknowledged":true}[root@jrgc ~]# /etc/init.d/zabbix_server startStarting zabbix_server:                                    [  OK  ]

四、测试

创建索引

Image.pngImage1.pngImage2.pngImage3.pngImage4.pngImage5.png

五、参考: