1、开始安装
准备安装好的Cents7系统。可以安装在虚拟机上,随后按如下命令进行安装。
0、更换阿里yum
备份原yum
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
下载阿里yum
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清除缓存
yum clean all
生成缓存
yum makecache
安装ftp和telnet
yum install ftp-* telnet-* -y
1、永久关闭:selinux
vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
2、停止firewall
systemctl stop firewalld.service
3、禁止firewall开机启动
systemctl disable firewalld.service
4、安装epel-release
yum install epel-release -y
5、安装Development Tools
yum groups install "Development Tools" -y
6、安装zabbix的镜像源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
7、安装zabbix-server-mysql
yum install -y zabbix-server-mysql
8、安装web前端mysql,可能会有网络问题安装失败,重复安装即可。大小为:2.8M
yum install zabbix-web-mysql -y
9、安装mariadb
yum install mariadb-server -y
2、安装完成,启动服务
1、查看数据库是否启动
systemctl status mariadb.service
2、启动数据库
systemctl start mariadb.service
3、查看mysql进程是否启动
ps aux|grep mysql
4、安装mysql_secure_installation
[root@zabbix4 yum.repos.d]# mysql_secure_installation
Enter current password for root (enter for none): 回车
Set root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
5、创建mariadb数据库
# 登录数据库
mysql -uroot -p
# 密码不用输入,直接回车进入。
# 创建数据库
CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
# 创建用户用于访问数据库
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@zabbix123';
# 刷新权限
flush privileges;
6、导入zabbix相关的表结构。
zcat /usr/share/doc/zabbix-server-mysql-4.0.17/create.sql.gz |mysql -uzabbix -pzabbix@zabbix123 zabbix
7、导入完成之后,重新登录mysql,查看zabbix库是否都存在了表。
mysql -uroot -p # 密码不用输入,直接回车进入。
show databases;
use zabbix;
show tables;
# 全部的相关表已经导入成功
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
144 rows in set (0.01 sec)
8、配置zabbix-server
vim /etc/zabbix/zabbix_server.conf
更改的地方:
(1)、DBHost=localhost
(2)、DBPassword=zabbix@zabbix123 #密码为zabbix用户的密码zabbix@zabbix123
保存退出。
9、启动zabbix服务
# 查看当前状态
systemctl status zabbix-server.service
# 启动fuwui
systemctl start zabbix-server.service
# 查看进程
ps aux |grep zabbix
# 查看启动日志
vim /var/log/zabbix/zabbix_server.log
10、配置zabbix的前端
vim /etc/php.ini
更改的地方:
(1)、max_execution_time = 300
(2)、post_max_size = 16M
(3)、always_populate_raw_post_data = -1
(4)、max_input_vars = 10000
(5)、date.timezone = Asia/Shanghai
11、php设置完了,启动Apache服务器
# 查看状态
systemctl status httpd.service
# 启动服务
systemctl start httpd.service
3、页面安装
(2)、进入安装页面,到达Configure DBconnection选项时,只用输入连接的密码即可。zabbix@zabbix123。
(3)、Zabbix server details页面,name为:Zabbix Server。
4、安装完成
5、登录zabbix
账号:Admin,默认密码是:zabbix
5、安装zabbix-agent
yum install zabbix-agent -y
# 进入配置文件中
vim /etc/zabbix/zabbix_agentd.conf
# 查看
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server (是否和页面安装的Name一致)
## 启动zabbix-agent服务
systemctl start zabbix-agent
systemctl status zabbix-agent