> zabbix安装教程 > Zabbix监控第三章

Zabbix监控第三章

Zabbix监控第三章

1.1.4安装操作
采用操作系统发行版Ubuntu 18.04.6 LTS,lnmp技术,基于zabbix相关配置操作如下

1.1.4.1,初始化操作相关指令

1
2
3
4
5
apt update -y
apt install ssh  vim net-tools wget  language-pack-zh-hans -y
sed  -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g'  /etc/ssh/sshd_config
service ssh restart
update-locale LANG=zh_CN.UTF-8

1.1.4.2,配置相关仓库二进制源

1
2
3
wget -c <a href="https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb">https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb</a>
dpkg -i zabbix-release_5.0-1+bionic_all.deb
apt update

1.1.4.3,安装zabbix相关组件

1
2
3
4
5
6
7
apt install -y zabbix-server-mysql \
zabbix-frontend-php \
zabbix-nginx-conf \
zabbix-agent \
zabbix-proxy-mysql \
zabbix-agent2 \
zabbix-java-gateway

1.1.4.4,创建数据库
MySQL环境5.7.38,数据库字符集utf-8必须是

1
2
3
4
5
6
7
8
mysql -uroot -h 10.10.2.51 -P 3306 -pxxxxxx
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'xxxxxx';
create user 'zabbix'@'%' identified by 'xxxx';
grant all privileges on zabbix.<em> to zabbix@localhost;
grant all privileges on zabbix.</em> to 'zabbix'@'%';
set global log_bin_trust_function_creators = 1;
quit;

1.1.4.5,导入数据库
官方那个5.0系列版本导入数据库存在一点问题,需要手工下载zabbix监控对应版本源代码,因为官方没有那个数据库备份文件包【/usr/share/doc/zabbix-server-mysql】,操作如下。

1
2
3
4
wget -c <a href="https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.41.tar.gz">https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.41.tar.gz</a>
tar -xvf zabbix-5.0.41.tar.gz
cd /root/zabbix-5.0.41/database/mysql
mysql -uroot -h 10.10.2.51 -P 3306 -pxxxxxx

Zabbix监控第三章

1
2
3
4
5
mysql -uroot -h 10.10.2.51 -P 3306 -pxxxxxx
use zabbix;
source  ./schema.sql  #数据库表
source  ./images.sql  #数据库框架
source  ./data.sql    #基础源数据

1.1.4.6,配置zabbix server 连接数据库文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd /etc/zabbix/
vim zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=10.10.2.51            #远程数据库连接地址
DBName=zabbix              #远程数据库名称
DBUser=zabbix               #远程数据库用户
DBPassword=zabbix1235812%   #远程数据库密码
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts   #执行脚本指令存放目录
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

1.1.4.7,配置Nginx-php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
cd /etc/nginx/sites-enabled  #第一步
vim default  #编辑默认的nginx配置文件
server {
listen 8080 default_server;  #调整端口80修改成8080
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server<em>name </em>;
location / {
try_files $uri $uri/ =404;
}
}</p>
<p>cd /etc/nginx/conf.d/ #第二步
vim zabbix.conf #编辑默认的zabbix.conf配置文件
server {
listen          80; #调整端口8080修改成80
root    /usr/share/zabbix;  #zabbix监控PHP网站代码发布目录
index   index.php;
location = /favicon.ico {
log_not_found   off;
}
location / {
try_files       $uri $uri/ =404;
}
location /assets {
access_log      off;
expires         10d;
}
location ~ /.ht {
deny            all;
}
location ~ /(api\/|conf[^.]|include|locale|vendor) {
deny            all;
return          404;
}
location ~ [^/].php(/|$) {
fastcgi_pass    unix:/var/run/php/zabbix.sock;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index   index.php;
fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;
include fastcgi_params;
fastcgi_param   QUERY_STRING    $query_string;
fastcgi_param   REQUEST_METHOD  $request_method;
fastcgi_param   CONTENT_TYPE    $content_type;
fastcgi_param   CONTENT_LENGTH  $content_length;
fastcgi_intercept_errors        on;
fastcgi_ignore_client_abort     off;
fastcgi_connect_timeout         60;
fastcgi_send_timeout            180;
fastcgi_read_timeout            180;
fastcgi_buffer_size             128k;
fastcgi_buffers                 4 256k;
fastcgi_busy_buffers_size       256k;
fastcgi_temp_file_write_size    256k;
}
}</p>
<p>cd /etc/php/7.2/fpm  #第三步
vim php.ini
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
disable_classes =
zend.enable_gc = On
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL &amp; ~E_DEPRECATED &amp; ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
html_errors = On
variables_order = &quot;GPCS&quot;
request_order = &quot;GP&quot;
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = &quot;text/html&quot;
default_charset = &quot;UTF-8&quot;
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60</p>
<p>[CLI Server]
cli_server.color = On</p>
<p>[Date]
date.timezone =Asia/Shanghai  #修改调整国家城市时区</p>
<p>[filter]
[iconv]
[imap]
[intl]
[sqlite3]
[Pcre]
[Pdo]</p>
<p>[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=</p>
<p>[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off</p>
<p>[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1</p>
<p>[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = &quot;%Y-%m-%d %H:%M:%S&quot;
ibase.dateformat = &quot;%Y-%m-%d&quot;
ibase.timeformat = &quot;%H:%M:%S&quot;</p>
<p>[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off</p>
<p>[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]</p>
<p>[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]</p>
<p>[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = &quot;a=href,area=href,frame=src,form=&quot;
session.sid_bits_per_character = 5</p>
<p>[Assertion]
zend.assertions = -1</p>
<p>[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off</p>
<p>[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir=&quot;/tmp&quot;
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5</p>
<p>[sysvshm]
[ldap]
ldap.max_links = -1</p>
<p>[dba]
[opcache]
[curl]
[openssl]</p>
<h1>启动服务</h1>
<p>service php7.2-fpm start
service nginx start
service zabbix-server start
service zabbix-agent start
netstat -lntp |grep -Ea &quot;zabbix|nginx&quot;

Zabbix监控第三章

1.1.4.8,配置安装可视化网页界面

访问http://ip地址/  如下图安装步骤

Zabbix监控第三章

Zabbix监控第三章

Zabbix监控第三章

Zabbix监控第三章Zabbix监控第三章Zabbix监控第三章Zabbix监控第三章Zabbix监控第三章

访问会出现一个欢迎到zabbix监控服务平台,下一步检查相关依赖配置环境,然后配置连接数据库地址相关信息,配置zabbix server 连接分布式IP,取项目监控名称,下一步确认没有问题在安装就成功,默认登入用户密码【Admin / zabbx】。

 

 

支付宝赞助
微信赞助