运维开发网

zabbix安装_lamp环境部署

运维开发网 https://www.qedev.com 2021-02-24 13:53 出处:51CTO 作者:李石岩
zabbix安装

一、关闭防火墙和SELinux

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# setenforce 0
[[email protected] ~]# sed -i “s/SELinux=enforcing/SELinux=disabled/g” /etc/seLinux/config

二、安装部署LAMP环境

1、安装LAMP基础环境,yum需要提前配置好,才不会出现问题

[[email protected] ~]# yum install -y httpd php php-mysql

2、启动相关服务、初始化数据库

  ①启动Apache

[[email protected] ~]# systemctl start httpd

  ②设置Apache和mariadb开机自启动

[[email protected] ~]# systemctl enable httpd

  ③初始化数据库

按照之前配置

3、安装Zabbix

  ①安装Zabbix源

[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm  ②导入Zabbix源的秘钥
[[email protected] ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

  ③安装Zabbix相关服务

[[email protected] ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

三、启动Zabbix服务

1、配置Zabbix服务端主配置文件、并开启Zabbix服务

  ①编辑/etc/zabbix/zabbix_server.conf

[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf         #仅需修改以下列出部分
DBHost=localhost
DBName=zabbix
DBUser=zabbix
[email protected]

四、创建和读入数据库

  ①创建数据库并授权

MySQL [(none)]> use mysql
Database changed
MySQL [mysql]> use zabbix
Database changed
MySQL [zabbix]> create user   'zabbix'@'localhost' identified by '[email protected]';
Query OK, 0 rows affected (0.11 sec)
MySQL [zabbix]>  grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.01 sec)
MySQL [zabbix]>  flush privileges;
Query OK, 0 rows affected (0.01 sec)

  ②读入数据库

[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.28/
[[email protected] zabbix-server-mysql-4.0.28]# zcat create.sql.gz | /usr/local/mysql/bin/mysql -uroot -p zabbix
Enter password: 
[[email protected] zabbix-server-mysql-4.0.28]#

# cd /usr/share/doc/zabbix-server-mysql-4.0.28/
# zcat create.sql.gz | /usr/local/mysql/bin/mysql -uroot -p zabbix

  ③检查导入的数据库

# mysql -u root -p
 [(none)]> use zabbix
 [zabbix]> SHOW TABLES;
[[email protected] zabbix-server-mysql-4.0.28]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.13 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> use zabbix
Database changed
mysql> 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.00 sec)
mysql>

三、启动Zabbix服务

1、配置Zabbix服务端主配置文件、并开启Zabbix服务

  ①编辑/etc/zabbix/zabbix_server.conf

# vim /etc/zabbix/zabbix_server.conf         #仅需修改以下列出部分
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock

②开启zabbix-server服务,并设置为开机自启动

# systemctl start zabbix-server.service 
# systemctl enable zabbix-server.service

2、编辑Zabbix前端PHP配置文件

# vim /etc/httpd/conf.d/zabbix.conf
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai

否则安装 zabbix web时会报错误

3、重启Apache服务,同步更新一下系统时间

 systemctl restart httpd
ntpdate ntp.sjtu.edu.cn        #或者使用cn.pool.ntp.org这个时间同步服务器   ---因为没配置这个就不做了
3 Jul 18:53:36 ntpdate[5330]: the NTP socket is in use, exiting

四、安装Zabbix Web

1、浏览器访问你的Zabbix服务器IP(http://IP地址/zabbix),然后点击"Next step"

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号