Centos快速搭建Zabbix
2021/09/04 19:51 投稿

下载地址:https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=red_hat_enterprise_linux&os_version=7&db=mysql&ws=apache
[root@www abc]# yum install httpd -y   //安装apache2
[root@www abc]# wget -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm  //

下载数据库
[root@www abc]# rpm -ivh mysql57-community-release-el7-10.noarch.rpm //安装数据库
[root@www abc]# yum install mysql-community-server -y //安装数据库服务
[root@www abc]# grep “password” /var/log/mysqld.log  //查看root的密码
[root@www abc]# mysql -u root -p  //登录数据库
mysql> alter user ‘root’@’localhost’ identified by ‘123’;  //修改密码root密码
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;  //刷新权限
Query OK, 0 rows affected (0.00 sec)
[root@www abc]# wget http://mirror.webtatic.com/yum/el7/epel-release.rpm  //下载epel-release
[root@www abc]# wget http://mirror.webtatic.com/yum/el7/webtatic-release.rpm //下载webtatic-release
[root@www abc]# rpm -ivh epel-release.rpm webtatic-release.rpm //安装
[root@www abc]# yum install mod_php72w php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-mbstring.x86_64 php72w-mysqlnd.x86_64 php72w-pdo.x86_64 php72w-fpm.x86_64 php72w-bcmath php72w-xmlwriter php72w-xmlreader php72w-ldap -y //安装php
[root@www mointer]# wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm //下载zabbix
[root@www mointer]# rpm -ivh zabbix-release-5.0-1.el7.noarch.rpm //安装

[root@www yum.repos.d]# yum install zabbix-server-mysql zabbix-agent zabbix-web -y //安装zabbix相关
[root@www yum.repos.d]# mysql -uroot -p  //登录数据库,并配置数据库
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by ‘123.’;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
[root@www yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql-5.0.6/create.sql.gz | mysql -uzabbix -p’123.’ zabbix //导入初始架构和数据,系统将提示您输入新创建的密码。
[root@www yum.repos.d]# vim /etc/zabbix/zabbix_server.conf //修改zabbix服务配置文件
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123.
[root@www yum.repos.d]# grep ‘^[a-Z]’ /etc/zabbix/zabbix_server.conf  //查看相关配置
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
[root@www yum.repos.d]# systemctl start zabbix-server //查看是否起来

[root@www ~]# vim /etc/zabbix/zabbix_agentd.conf //一般不需要改

[root@www ~]# systemctl start zabbix-agent.service //开启服务
[root@www ~]# netstat -ntlp | grep zabbix //查看监听
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 66567/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 66280/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 66567/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 66280/zabbix_server

开始部署web
配置apache虚拟主机
httpd.conf 插入 Listen 8020
<virtualHost www.lab.com:8020>
ServerName www.lab.com
DocumentRoot /var/zabbix
<Directory “/var/zabbix”>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

默认账号 Admin 密码 zabbix
乱码问题需要重新连接字体