标签:时间 网络 mys options 多语言 等等 lamp uil rect
Linux下常用的系统监控软件有Nagios、Cacti、Zabbix、Monit等,这些开源的软件,可以帮助我们更好的管理机器,在第一时间内发现,并警告系统维护人员。今天开始研究下Zabbix,使用Zabbix的目的,是为了能够更好的监控mysql数据库服务器,并且能够生成图形报表,虽然Nagios也能够生成图形报表,但没有Zabbix这么强大。
首先,我们先来介绍下Zabblx:
一.Zabbix简介
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix由zabbix server与可选组件zabbix agent两部门组成。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视。
zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
zabbix的主要特点:
Zabbix主要功能:
环境 | IP | 需要的应用 |
---|---|---|
服务端 | 192.168.24.168 | LAMP zabbix-serverzabbix-agent |
因为zabbix是由PHP语言开发的,所以要先部署LAMP架构 来支持php网页
安装依赖包
[root@linfan ~]# yum -y install net-snmp-devel libevent-devel
下载zabbix
[root@linfan ~]# cd /usr/src/
[root@linfan src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
解压
[root@linfan src]# tar xf zabbix-3.4.12.tar.gz
[root@linfan src]# ls
apr-1.6.3 apr-util-1.6.1.tar.bz2 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz zabbix-3.4.12
apr-1.6.3.tar.bz2 debug php-7.2.8 zabbix-3.4.12.tar.gz
apr-util-1.6.1 kernels php-7.2.8.tar.xz
创建zabbix用户和组
[root@linfan ~]# groupadd -r zabbix
[root@linfan ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
配置zabbix数据库
root@linfan ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
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@localhost identified by ‘linfan123‘;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> grant all privileges on zabbix.* to zabbix@127.0.0.1 identified by ‘linfan123‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for zabbix@localhost;
+------------------------------------------------------------+
| Grants for zabbix@localhost |
+------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘zabbix‘@‘localhost‘ |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO ‘zabbix‘@‘localhost‘ |
+------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> show grants for zabbix@127.0.0.1;
+------------------------------------------------------------+
| Grants for zabbix@127.0.0.1 |
+------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘zabbix‘@‘127.0.0.1‘ |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO ‘zabbix‘@‘127.0.0.1‘ |
+------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> quit
Bye
[root@linfan ~]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@linfan mysql]# ls
data.sql images.sql schema.sql
//倒着追加
[root@linfan mysql]# mysql -uzabbix -plinfan123 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@linfan mysql]# mysql -uzabbix -plinfan123 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@linfan mysql]# mysql -uzabbix -plinfan123 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
编译安装zabbix
[root@linfan ~]# cd /usr/src/zabbix-3.4.12
[root@linfan zabbix-3.4.12]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@linfan zabbix-3.4.12]# make install
修改服务端配置文件
设置数据库信息
[root@linfan ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d
[root@linfan ~]# vim /usr/local/etc/zabbix_server.conf
...
...
DBUser=zabbix
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=linfan123 搜索‘DBPassword=‘在后面添加设置的zabbix连接密码并取消#号注释
启动zabbix_server和zabbix_agentd服务
[root@linfan ~]# zabbix_server
[root@linfan ~]# ss -natl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@linfan ~]# zabbix_agentd
[root@linfan ~]# ss -natl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
修改/etc/php.ini的配置并重启php-fpm
[root@linfan ~]# sed -ri ‘s/(post_max_size =).*/\1 16M/g‘ /etc/php.ini
[root@linfan ~]# sed -ri ‘s/(max_execution_time =).*/\1 300/g‘ /etc/php.ini
[root@linfan ~]# sed -ri ‘s/(max_input_time =).*/\1 300/g‘ /etc/php.ini
[root@linfan ~]# sed -i ‘/;date.timezone/a date.timezone = Asia/Shanghai ‘ /etc/php.ini
[root@linfan ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@linfan ~]# cd /usr/src/zabbix-3.4.12
[root@linfan zabbix-3.4.12]# ls
aclocal.m4 ChangeLog config.log configure.ac frontends m4 man README
AUTHORS compile config.status COPYING include Makefile misc sass
bin conf config.sub database INSTALL Makefile.am missing src
build config.guess configure depcomp install-sh Makefile.in NEWS upgrades
[root@linfan zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[root@linfan zabbix-3.4.12]# cp -r frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@linfan zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs
配置apache虚拟主机
在配置文件末尾添加如下内容:
[root@linfan ~]# vim /etc/httpd24/httpd.conf
...
...
</IfModule>
<VirtualHost 192.168.24.168:80>
ServerName zabbix.doudou.com
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
设置zabbix/conf目录的权限,让zabbix有权生成配置文件zabbix.conf.php
[root@linfan ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@linfan ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwxrwx. 2 apache apache 81 Jul 30 19:41 /usr/local/apache/htdocs/zabbix/conf
重启apache
[root@linfan ~]# apachectl -t
Syntax OK
[root@linfan ~]# apachectl stop
[root@linfan ~]# apachectl start
[root@linfan ~]# ss -nalt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@linfan ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf
[root@linfan ~]# ll /usr/local/apache/htdocs/zabbix/conf -d
drwxr-xr-x. 2 apache apache 104 Aug 21 15:37 /usr/local/apache/htdocs/zabbix/conf
标签:时间 网络 mys options 多语言 等等 lamp uil rect
原文地址:http://blog.51cto.com/13858192/2162469