标签:start debug 4.0 my.cnf mysqld schema level 输入 src
pwd
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/tmp/mysql.sock
2】、[root@201 src]#bash my.cnf #安装mysql
[root@201 src]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::3306 :::*
4、mysql数据库做授权:
[root@201 src]#mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on zabbix.* to zabbix@"172.18.%.%" identified by ‘12345‘ ;
Query OK, 0 rows affected (0.01 sec)
5、在150server主机远程连接mysql数据库:
[root@150 ~]#mysql -uzabbix -h172.18.9.201 -p"<123gxy>"; #注意:此时-p中的<123gxy>才是密码。
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| zabbix | # zabbix用户已被成功创建!!
+--------------------+
3 rows in set (0.01 sec)
6、[root@150 zabbix]#vim zabbix_server.conf
ListenPort=10051
DebugLevel=3
DBHost=172.18.9.201
DBName=zabbix
DBUser=zabbix
DBPassword=123gxy
HistoryCacheSize=16M
HistoryIndexCacheSize=4M
CacheSize=8M
Timeout=30 #默认是4s,建议设置最长时长30s。
7、开启zabbix-server,并查看端口,但是无端口:因为数据库没有初始化。
8、该步骤为准备工作,按此顺序执行操作,我们在开头就已安装好了,所以不做展示:
[root@150 zabbix]#yum install yum-utils
[root@150 zabbix]#yum-config-manager --enable rhel-7-server-optional-rpms
Loaded plugins: fastestmirror, langpacks #开启数据库!
[root@150 yum.repos.d]#yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
9、创建数据库:
1】、先查看201主机的zabbix数据库为空:
[root@201 ~]#mysql
mysql> use zabbix;
Database changed
mysql> show tables;
Empty set (0.00 sec)
2】、将数据导入mysql数据库:
[root@150 ~]#zcat /usr/share/doc/zabbix-server-mysql-4.0.6/create.sql.gz |mysql -uzabbix -h172.18.9.201 -p"<123gxy>" zabbix #注意:库名、密码错误均失败。
3】、此时在201数据库主机的mysql> show tables;中,已导入数据:
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
+----------------------------+
144 rows in set (0.03 sec)
4】、[root@150 src]#systemctl restart httpd zabbix-server zabbix-agent
[root@150 src]#ss -ntl #此时,10051端口已开启!
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :10051 :*
注意:(我在此处遇到了zabbix密码输入错误,150主机给zabbix用户grant授权问题,)
此时,访问页面:
10、[root@150 zabbix]#vim /etc/php.ini
date.timezone =Aisa/shanghai
[root@150 conf.d]#vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai #注意,此处的php.ini与zabbix.conf文件的date.timezone 都需要更改才行。
11、[root@150 conf.d]#systemctl restart zabbix-server httpd zabbix-agent 并访问zabbix页面:
我们在网页配置好的zabbix的信息如下:
12、各配置均完成后,点击登录,会出现如下界面:
13、设置开机自启zabbix-agent;并访问页面:
[root@150 conf.d]#systemctl restart zabbix-agent
[root@150 conf.d]#systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
14、在150server主机上安装上zabbix-agent包。150主机的“/etc/zabbix/zabbix_agentd.conf”中:Hostname=Zabbix server,此时去172.18.9.150/zabbix/php 官网网页进行配置即可。
如何监控其他主机:
1】、在201mysql主机安装上zabbix-agent包其中的“/etc/zabbix/zabbix_agentd.conf”中:Hostname=172.18.9.201 #用IP地址来做区分。
15、修改该文件,内容如下:
[root@201 ~]#grep -v "#" /etc/zabbix/zabbix_agentd.conf|grep -v "^$"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.18.9.150
ServerActive=127.0.0.1
Hostname=172.18.9.201
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@201 ~]#systemctl restart zabbix-agent
[root@201 ~]#systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
16、访问网页:#此时150mysql数据库主机的监控已实现连接:
为了方便在网页页面查看,我们将字体改为中文:
先在电脑的控制面板上选择一款字体,
在150server主机:[root@150 ~]#cd /usr/share/zabbix/fonts
[root@150 fonts]#ll
total 10332
lrwxrwxrwx. 1 root root 33 Apr 15 22:33 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 10578152 Aug 9 2018 simfang.ttf
[root@150 zabbix]#vim include/defines.inc.php
把该文件中的graphfont改为simfang。
load averge:
一、创建主动模式的数据库:在201mysql主机:
mysql> create database zabbix_proxy_active character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on zabbix_proxy_active.* to zabbix_active@"172.18.%.%" identified by ‘123456‘;
Query OK, 0 rows affected (0.05 sec)
二、将源码包上传至家目录:主/被模式都是同一个包
[root@200 ~]#ls zabbix-proxy-mysql-4.0.6-1.el7.x86_64.rpm
[root@200 ~]#yum install zabbix-proxy-mysql-4.0.6-1.el7.x86_64.rpm
在201mysql主机:创建被动模式:
mysql> create database zabbix_proxy_passive character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on zabbix_proxy_passive.* to zabbix_passive@"172.18.%.%" identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
三、配置该文件:[root@200 ~]#grep -v "#" /etc/zabbix/zabbix_proxy.conf |grep -v "^$"
ProxyMode=0
Server=172.18.9.150
ServerPort=10051
Hostname=huayi_proxy_active
ListenPort=10051
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBHost=172.18.9.201
DBName= zabbix_proxy_active
DBUser=zabbix_active
DBPassword=123456
ProxyLocalBuffer=720
ProxyOfflineBuffer=720
HeartbeatFrequency=60
ConfigFrequency=60
DataSenderFrequency=5
StartPollers=20
JavaGateway=172.18.9.150
StartJavaPollers=10
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=16M
HistoryCacheSize=16M
Timeout=30
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
四、查看200主机的初始化脚本在何方:
[root@200 ~]#rpm -qpl zabbix-proxy-mysql-4.0.6-1.el7.x86_64.rpm
/usr/share/doc/zabbix-proxy-mysql-4.0.6/schema.sql.gz #该包即是初始化脚本
五、这时,我们要安装mysql,通过mysql命令来把脚本执行:
[root@200 ~]#yum install -y mysql
[root@200 ~]#mysql -uzabbix_active -h172.18.9.201 -p123456 #在zabbix_active:200主机上远程连接201mysql数据库:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 251
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MySQL [(none)]> show databases;
+---------------------+
| Database |
+---------------------+
| information_schema |
| test |
| zabbix_proxy_active |
+---------------------+
3 rows in set (0.00 sec)
六、把该sql.gz脚本传给mysql,并做初始化:
[root@200 ~]#zcat /usr/share/doc/zabbix-proxy-mysql-4.0.6/schema.sql.gz |mysql -uzabbix_active -h172.18.9.201 -p123456 zabbix_proxy_active
七、在201mysql数据库主机查询:
mysql> use zabbix_proxy_active
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------------------+
| Tables_in_zabbix_proxy_active |
+-------------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
+-------------------------------+
144 rows in set (0.00 sec) #此时,mysql数据库已经同步导入了paroxy_active的数据了!!
八、[root@150 src]#vim /etc/zabbix/zabbix_agentd.conf
ServerActive=172.18.9.200 该IP要指向proxy的地址,不能指向server的IP。
九、在200zabbix-proxy主机开启该proxy应用:
[root@200 ~]#systemctl start zabbix-proxy
[root@200 ~]#systemctl enable zabbix-proxy
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-proxy.service to /usr/lib/systemd/system/zabbix-proxy.service.
监控页面出现此页面就是proxy的主动模式成功开启了!
标签:start debug 4.0 my.cnf mysqld schema level 输入 src
原文地址:https://blog.51cto.com/14128387/2381114