打算入坑zabbix,嘗試部署是第一步,爲了簡單期間,選擇設備安裝Centos 7.5,採用docker方式開始部署最新的zabbix4.4php
能夠在github1上尋找對應的docker-compose配置,下面爲本身使用的,僅做參考java
version: '2' services: zabbix-server: image: zabbix/zabbix-server-pgsql:alpine-4.4-latest ports: - "10051:10051" volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro - ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro - ./zbx_env/var/lib/zabbix/mibs:/var/lib/zabbix/mibs:ro volumes_from: - zabbix-snmptraps:ro links: - pgsql-server:pgsql-server - zabbix-java-gateway:zabbix-java-gateway ulimits: nproc: 65535 nofile: soft: 20000 hard: 40000 mem_limit: 512m restart: always env_file: - .env_db_pgsql - .env_srv networks: - zabbix-net zabbix-web-nginx-pgsql: image: zabbix/zabbix-web-nginx-pgsql:alpine-4.4-latest ports: - "80:80" - "8000:80" - "8443:443" links: - pgsql-server:pgsql-server - zabbix-server:zabbix-server mem_limit: 512m volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - ./zbx_env/etc/ssl/nginx:/etc/ssl/nginx:ro - ./simkai.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf:ro env_file: - .env_db_pgsql - .env_web depends_on: - zabbix-server - pgsql-server networks: - zabbix-net zabbix-agent: image: zabbix/zabbix-agent2:latest ports: - "10050:10050" volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - ./zbx_env/etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro - ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro links: - zabbix-server:zabbix-server env_file: - .env_agent2 privileged: true pid: "host" networks: - zabbix-net zabbix-java-gateway: image: zabbix/zabbix-java-gateway:alpine-4.4-latest ports: - "10052:10052" env_file: - .env_java networks: - zabbix-net zabbix-snmptraps: image: zabbix/zabbix-snmptraps:alpine-4.4-latest ports: - "162:162/udp" volumes: - ./zbx_env/var/lib/zabbix/snmptraps:/var/lib/zabbix/snmptraps:rw networks: - zabbix-net pgsql-server: image: postgres:11 volumes: - ./zbx_env/var/lib/postgresql/data:/var/lib/postgresql/data env_file: - .env_db_pgsql restart: always networks: - zabbix-net networks: zabbix-net: ipam: config: - subnet: 172.16.66.0/24 gateway: 172.16.66.1
.env_srvnginx
# ZBX_LISTENIP= # ZBX_HISTORYSTORAGEURL=http://elasticsearch:9200/ # Available since 3.4.5 # ZBX_HISTORYSTORAGETYPES=uint,dbl,str,log,text # Available since 3.4.5 # ZBX_DEBUGLEVEL=3 # ZBX_STARTPOLLERS=5 # ZBX_IPMIPOLLERS=0 # ZBX_STARTPREPROCESSORS=3 # Available since 3.4.0 # ZBX_STARTPOLLERSUNREACHABLE=1 # ZBX_STARTTRAPPERS=5 # ZBX_STARTPINGERS=1 # ZBX_STARTDISCOVERERS=1 # ZBX_STARTHTTPPOLLERS=1 # ZBX_STARTTIMERS=1 # ZBX_STARTESCALATORS=1 # ZBX_STARTALERTERS=3 # Available since 3.4.0 ZBX_JAVAGATEWAY_ENABLE=true # ZBX_JAVAGATEWAY=zabbix-java-gateway # ZBX_JAVAGATEWAYPORT=10052 ZBX_STARTJAVAPOLLERS=5 ZBX_STARTVMWARECOLLECTORS=6 ZBX_VMWAREFREQUENCY=60 ZBX_VMWAREPERFFREQUENCY=60 ZBX_VMWARECACHESIZE=8M ZBX_VMWARETIMEOUT=10 ZBX_ENABLE_SNMP_TRAPS=true # ZBX_SOURCEIP= # ZBX_HOUSEKEEPINGFREQUENCY=1 # ZBX_MAXHOUSEKEEPERDELETE=5000 # ZBX_SENDERFREQUENCY=30 # ZBX_CACHESIZE=8M # ZBX_CACHEUPDATEFREQUENCY=60 # ZBX_STARTDBSYNCERS=4 # ZBX_HISTORYCACHESIZE=16M # ZBX_HISTORYINDEXCACHESIZE=4M # ZBX_TRENDCACHESIZE=4M # ZBX_VALUECACHESIZE=8M # ZBX_TIMEOUT=4 # ZBX_TRAPPERIMEOUT=300 # ZBX_UNREACHABLEPERIOD=45 # ZBX_UNAVAILABLEDELAY=60 # ZBX_UNREACHABLEDELAY=15 # ZBX_LOGSLOWQUERIES=3000 # ZBX_STARTPROXYPOLLERS=1 # ZBX_PROXYCONFIGFREQUENCY=3600 # ZBX_PROXYDATAFREQUENCY=1 # ZBX_LOADMODULE="dummy1.so,dummy2.so,dummy10.so" # ZBX_TLSCAFILE= # ZBX_TLSCRLFILE= # ZBX_TLSCERTFILE= # ZBX_TLSKEYFILE=
.env_webgit
ZBX_SERVER_HOST=zabbix-server ZBX_SERVER_PORT=10051 ZBX_SERVER_NAME=Composed installation # ZBX_HISTORYSTORAGEURL=http://elasticsearch:9200/ # Available since 3.4.5 # ZBX_HISTORYSTORAGETYPES=['uint', 'dbl', 'str', 'text', 'log'] # Available since 3.4.5 ZBX_MAXEXECUTIONTIME=600 ZBX_MEMORYLIMIT=128M ZBX_POSTMAXSIZE=16M ZBX_UPLOADMAXFILESIZE=2M ZBX_MAXINPUTTIME=300 # Timezone one of: http://php.net/manual/en/timezones.php PHP_TZ=Asia/Shanghai
.env_db_pgsqlgithub
DB_SERVER_HOST=pgsql-server DB_SERVER_PORT=5432 # POSTGRES_USER=zabbix POSTGRES_USER=zabbix # POSTGRES_PASSWORD=zabbix POSTGRES_PASSWORD=zabbix # POSTGRES_ROOT_PASSWORD= POSTGRES_ROOT_PASSWORD=root_pwd # POSTGRES_ALLOW_EMPTY_PASSWORD=false # POSTGRES_DATABASE=zabbix POSTGRES_DATABASE=zabbix
.env_agentweb
# ZBX_SOURCEIP= # ZBX_DEBUGLEVEL=3 # ZBX_ENABLEREMOTECOMMANDS=0 # ZBX_LOGREMOTECOMMANDS=0 ZBX_SERVER_HOST=zabbix-server # ZBX_PASSIVE_ALLOW=true # ZBX_PASSIVESERVERS= # ZBX_ACTIVE_ALLOW=true # ZBX_ACTIVESERVERS= # ZBX_LISTENIP= # ZBX_STARTAGENTS=3 ZBX_HOSTNAME=zabbix-server # ZBX_HOSTNAMEITEM=system.hostname # ZBX_METADATA= # ZBX_METADATAITEM= # ZBX_REFRESHACTIVECHECKS=120 # ZBX_BUFFERSEND=5 # ZBX_BUFFERSIZE=100 # ZBX_MAXLINESPERSECOND=20 # ZBX_ALIAS="" # ZBX_TIMEOUT=3 # ZBX_UNSAFEUSERPARAMETERS=0 # ZBX_LOADMODULE="dummy1.so,dummy2.so,dummy10.so" # ZBX_TLSCONNECT=unencrypted # ZBX_TLSACCEPT=unencrypted # ZBX_TLSCAFILE= # ZBX_TLSCRLFILE= # ZBX_TLSSERVERCERTISSUER= # ZBX_TLSSERVERCERTSUBJECT= # ZBX_TLSCERTFILE= # ZBX_TLSKEYFILE= # ZBX_TLSPSKIDENTITY= # ZBX_TLSPSKFILE=
在zabbix對應的dockerfile.yaml文件夾下,啓動容器sql
docker-compose up -d
關閉容器
docker-compose stop
配置中數據已經在本地持久化,能夠查看對應的./zbx_env/var/lib/postgresql/data
目錄,重啓容器不影響以前的配置.
查看容器docker
docker-compose ps
具體狀態數據庫
docker ps
查看日誌網絡
docker-compose logs zabbix-server
系統中自帶的DejaVuSans
字體在顯示中文時會顯示爲小方框,影響使用,須要替換字體便可。
zabbix在4.2版本開始更換了字體目錄,詳見/usr/share/zabbix/include/defines.inc.php
中
define('ZBX_FONTPATH', realpath('assets/fonts')); // where to search for font (GD > 2.0.18) define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name define('ZBX_GRAPH_LEGEND_HEIGHT', 120); // when graph height is less then this value, some legend will not show up
因爲默認文件中字體名爲DejaVuSans,只須要將docker-compose.yaml文件中web中加入字體文件的映射:
- ./zbx_env/etc/ssl/nginx:/etc/ssl/nginx:ro - ./simkai.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf:ro
simkai.ttf爲須要替換的字體,若是web已啓動,只須要重建web容器就可生效(刪除原容器,從新啓動,只刪除web容器不影響監控)。另修改yaml文件時留意空格縮進。
使用docker方式特別留意監控目標是172開頭的私有地址段,須要查看下是否docker的地址段一致,docker默認使用172開頭的16位掩碼的地址段,若是監控目標ip也屬於這個地址段,根據路由規則,就會在docker網絡中,根本沒法訪問外部的監控目標,須要更改docker網橋地址。
監控平臺最好選擇一臺性能不錯且穩定的機器,以前在測試環境中,選擇一臺品牌pc,內存4g,感受有些性能不足,因而打算擴展內存,增長一條DDR3 4g(主頻1600MHz),造成雙通道,開機識別正常。
以後,發現zabbix-server、pgsql等容器常常宕掉,沒有徵兆,自動重啓也異常,docker方式部署的ebk中kibana也異常沒法啓動,甚是詭異。想到增長過內存條,因而更換一條內存,不組成雙通道,重啓,發現機器運行流暢,docker容器也正常。