安装环境:虚拟机 Esxi6.
操作系统:CentOs7.5
IP地址:172.?.?.?
CPU:Architecture: x86_64/Intel(R) Xeon(R) CPU [email protected] 8核
内存:8G
数据库:Mariadb-5.5.64
Apache:httpd-2.4.6-90
PHP-fpm:5.4.16-46
Zabbix-server:4.4.1
安装步骤:
1、安装数据库
yum install mariadb mariadb-server mariadb-devel –y
systemctl enable mariadb;systemctl start mariadb
2、安装Apache
yum install httpd –y
systemctl enable httpd;systemctl start httpd
3、安装PHP
yum install php php-fpm php-mysql -y php-mysql安装有问题,但是跳过这个的安装好像并不影响
systemctl enable php-fpm;systemctl start php-fpm
4、关闭防火墙和Seliunx
firewall-cmd --set-default-zone=trusted
vim /etc/selinux/config
修改为
SELINUX=permissive
5、安装必要的依赖包
yum install gcc gcc-c++ libevent-devel php-bcmath php-gd php-xml php-mbstring -y
6、创建操作系统用户zabbix
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
7、下载源码安装包,上传到/home/zabbix/
8、解压安装包
tar -zxvf zabbix-4.4.1.tar.gz
9、选择编译参数
执行./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc
注.执行之前,先安装以下包
说明:参数对应需要安装包
--with-net-snmp --- net-snmap-devel
--with-libcurl --- libcurl-devel curl-devel
--with-libxml2 --- libxml2-devel
--with-openipmi --- OpenIPMI-devel
--with-unixodbc --- unixODBC-devel
yum install net-snmap-devel libcurl-devel curl-devel libxml2-devel OpenIPMI-devel unixODBC-devel –y
执行结果检查
10、编译安装
make install
11、复制php脚本到apache根目录下
建议首先创建zabbix目录
mkdir mkdir /var/www/html/zabbix/
cp -r /home/zabbix/zabbix-4.4.1/frontends/php/* /var/www/html/zabbix/
为PHP脚本添加权限,最好按照要求添加,比较安全
chmod -R 777 /var/www/html/(httpd整个根目录赋权限,否则可能会出现权限不足的情况)
12、登陆mariadb,创建zabbix用户
[root@zabbix-server-1 zabbix]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbixdb character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on zabbixdb.* to zabbix@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
13、按顺序导入zabbix基础数据库
mysql -uzabbix -pzabbix zabbixdb < /home/zabbix/zabbix-4.4.1/database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbixdb < /home/zabbix/zabbix-4.4.1/database/mysql/images.sql
mysql -uzabbix -pzabbix zabbixdb < /home/zabbix/zabbix-4.4.1/database/mysql/data.sql
14、修改PHP参数,使之符合zabbix要求
vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
15、重启前端服务器
systemctl restart httpd php-fpm
16、配置网页端服务器
打开firefox,输入http://172.?.?.?/zabbix
17、启动zabbix-server
a.复制和修改启动脚本
cp /home/zabbix/zabbix-4.4.1/misc/init.d/fedora/core/* /etc/init.d/
b.复权
chmod o+x zabbix_agentd zabbix_serve
c.将安装目录修改为—prefix设置的目录
vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
d.修改zabbix配置文件,填写数据库信息。(前端页面是告诉php脚本从哪个数据库获得信息展示,这里告诉后端程序将收集的信息写入哪个数据库)
vim /usr/local/etc/zabbix_server.conf
DBName=zabbixdb
DBUser=zabbix
DBPassword=zabbix
e.启动并检查端口,端口状态不正常,则没有正常启动
/etc/init.d/zabbix_server status
netstat -utanlp | grep 10051
f.排错
MariaDB [(none)]> GRANT ALL ON zabbixdb.* TO 'zabbix'@'localhost' identified by 'zabbix';
MariaDB [(none)]> flush privileges;
还是不可以
MariaDB [mysql]> select * from user \G;
MariaDB [mysql]> select Password from user where user = 'zabbix';
+-------------------------------------------+
| Password |
+-------------------------------------------+
| *DEEF4D7D88CD046ECA02A80393B7780A63E7E789 |
+-------------------------------------------+
1 row in set (0.00 sec)
可以看到密码不是zabbix修改密码:
生成一个新密码MD5,zabbix是密码
# echo -n zabbix | openssl md5
(stdin)= 5fce1b3e34b520afeffb37ce08c7cd66
MariaDB [mysql]> update user set password='5fce1b3e34b520afeffb37ce08c7cd66' where user = 'zabbix';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> select Password from user where user = 'zabbix';
+----------------------------------+
| Password |
+----------------------------------+
| 5fce1b3e34b520afeffb37ce08c7cd66 |
+----------------------------------+
1 row in set (0.00 sec)
没有可以登陆zabbix用户。
MariaDB [(none)]> CREATE USER 'zabbix' IDENTIFIED BY 'zabbix';
MariaDB [(none)]> GRANT ALL ON zabbixdb.* TO 'zabbix'@'localhost' identified by 'zabbix';
MariaDB [mysql]> flush privileges;
[root@zabbix-server-1 init.d]# /etc/init.d/zabbix_server stop
[root@zabbix-server-1 init.d]# /etc/init.d/zabbix_server start
18、配置客户端
19、添加host
20、未完待续。。。