zabbix 4.0.1部署

一,zabbix部署需要lamp环境:

1,apache安装

yum install httpd libxml2-devel net-snmp-devel libcurl-devel

常见问题:启动apache的时候,会有输出如下:

Could not reliably determine the server's ully qualified domain name, using 127.0.0.1 for ServerName

这个问题是因为不确认主机名是否正确。

处理方法:1),可以不做任何处理;2)指定ServerName x.x.x.x:port

启动并加开机自启: /etc/init.d/httpd start &&chkconfig httpd on

2, Mysql安装

建议安装MySQL5.6 centos6 默认安装mysql是5.1 不是很稳定 性能也没有MySQL5.6好

下载rpm源及安装:

#rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

###### yum install -y mysql-server mysql-devel

vim /etc/my.cnf

default-storage-engine = innodb

innodb_file_per_table

collation-server = utf8_general_ci

init-connect = 'SET NAMES utf8'

character-set-server = utf8

启动数据库

#service mysqld start

MySQL安全设置:

###### mysql_secure_installation

Enter current password for root (enter for none): #直接回车

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] y #设置root密码 选择Y 或者回车

New password: #设置root密码

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

Remove anonymous users? [Y/n] y 是否删除匿名用户 选择y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y 是否禁止用户登陆root 远程 选择Y 为了安全考虑

... Success!

Remove test database and access to it? [Y/n] y 删除test数据库 选择y

- Dropping test database...

Reload privilege tables now? [Y/n] y 是否重新加载刷新表空间 选择Y 是

... Success!

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

Cleaning up...

3,创建zabbix数据库

###### mysql -uroot -p

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;

mysql> show create database zabbix;

+----------+----------------------------------------------------------------------------------+

| Database | Create Database |

+----------+----------------------------------------------------------------------------------+

| zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ |

+----------+----------------------------------------------------------------------------------+

1 row in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';

Query OK, 0 rows affected (0.04 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| zabbix |

+--------------------+

4 rows in set (0.00 sec)

启动服务:/etc/init.d/mysqld start && chkconfig mysqld on

安装错误,卸载重装

3,安装PHP

zabbix3.0以上版本 对于PHP要求是5.4版本以上 默认CentOS6.几 默认是5.3 好像

rpm下载及yum安装php5.6

```
###### rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

###### yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml
```

(#yum -y install php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64)

php56w-ldap

配置php.ini

vim /etc/php.ini

date.timezone = Asia/Shanghai

post_max_size = 32M

max_execution_time = 300

max_input_time = 300

always_populate_raw_post_data = -1

最后如果zabbix界面报错 php 没有检测通过 改参数之后 需要重启mysql httpd 和zabbix-server

安装php的时候 如果出错,就 先yum clean all 然后再安装

4,安装zabbix,以4.0举例

```
# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

###### yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

###### zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

###### mkdir /var/www/html/zabbix &&cp -r /usr/share/zabbix/* /var/www/html/zabbix
```

######

编辑zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

StartPollers=10

StartPollersUnreachable=10

StartDiscoverers=10

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

ListenIP=127.0.0.1

CacheSize=2M

StartDBSyncers=1

HistoryIndexCacheSize=2M

TrendCacheSize=2M

ValueCacheSize=2M

Timeout=10

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=1000

根据服务器配置变更参数

编辑zabbix_agent.conf

Server=

Hostname=

ps:Hostname不写取默认值

启动服务:service zabbix-server start && service zabbix-agent start

chkconfig zabbix-server on && chkconfig zabbix-agent on

5,配置web页面

常见问题:数据库连接失败

解决方法:rpm -qa|grep zabbix,如果有postsql包,卸载,重启server正常

6,中文乱码

cd /var/www/html/zabbix/fonts/

上传字体文件

simkai.ttf

vim ../include/defines.inc.php

define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name

刷新生效

7,grafana可视化监控

https://blog.csdn.net/linux_s2018/article/details/80395492

原文地址:https://www.cnblogs.com/wts-home/p/15399200.html