如何安装zabbix
转变:
weibo 01:10.0.0.7(server)
weibo 02:10.0.0.8(agent)
第一部分:server端开始配
1.下载zabbix的rpm包(注意:这个rpm包里包含yum zabbix的仓库配置文件)
[root@web01 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
[root@web01 ~]# ll /etc/yum.repos.d/
CentOS-Base.repo epel.repo zabbix.repo
[root@web01 ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
2.或者
[root@web01 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
3.zabbix-server-mysql为针对mysql的集成 ;zabbix-web-mysql为针对http的集成
[root@web01 ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
4.安装数据库
[root@web01 ~]# vim /etc/yum.repos.d/mysql.repo
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=0
[root@web01 ~]# yum install -y mysql-community-server
[root@web01 ~]# systemctl start mysqld
5.创建zabbix在mysql里的数据库zabbix并且授权登录用户。后面的授权用户只是方便本地localhost登录用的,不然拒绝登录。
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'10.0.0.%' identified by 'zabbix';
Query OK, 0 rows affected (0.01 sec) #把这个放在前面这个后面授权,经验之谈吧
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
6.这是zabbix在生成的过程中生成的表的压缩包需要我们导到mysql数据库专门库里
[root@web01 ~]# ll /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz
-rw-r--r-- 1 root root 1267039 11月 12 2018 /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz
7.导入命令
[root@web01 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz | mysql -uzabbix -pzabbix zabbix
8.修改zabbix配置文件(主要是关于连接数据库的)
[root@web01 ~]# vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBHost=zabbix
9.开始第二段:统一时间了
[root@web01 ~]# yum install -y ntpdate
[root@web01 ~]# timedatectl set-timezone 'Asia/Shanghai'
[root@web01 ~]# ntpdate ntp1.aliyun.com
11 Mar 19:14:26 ntpdate[10016]: adjust time server 120.25.115.20 offset -0.377025 sec
[root@web01 ~]# date
2021年 03月 11日 星期四 19:15:13 CST
10.修改http配置文件里关于时区的:php_value date.timezone Asia/Shanghai
[root@web01 ~]# vim /etc/httpd/conf.d/zabbix.conf
<IfModule mod_php5.c>
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 Europe/Riga
php_value date.timezone Asia/Shanghai
11.server端配好启动
[root@web01 ~]# systemctl start zabbix-server
第二部分:agent端开始配
1.这个下载的是一个zabbix的源
[root@webo2 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
2.装备客户端
[root@webo2 ~]# yum install -y zabbix-agent
3.配置agent端zabbix配置文件只需要指向server端ip
[root@webo2 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=10.0.0.7
4.agent端统一时间和时区
[root@webo2 ~]# timedatectl set-ntp no
[root@webo2 ~]# timedatectl set-timezone "Asia/Shanghai"
[root@webo2 ~]# ntpdate ntp1.aliyun.com
11 Mar 19:40:29 ntpdate[12802]: adjust time server 120.25.115.20 offset -0.360104 sec
[root@webo2 ~]# date
2021年 03月 11日 星期四 19:40:32 CST
5.开启zabbix客户端并检查启动起来没有
[root@webo2 ~]# systemctl start zabbix-agent.service
[root@webo2 ~]# netstat -lntp | grep 'zabbix'
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 12849/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 12849/zabbix_agentd
6.配好agent后开启zabbix服务端
[root@web01 ~]# systemctl start zabbix-server
[root@web01 ~]# netstat -lntp | grep server
Active Internet connections (only servers)
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 10588/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 10588/zabbix_server
7.开启http在服务端
[root@web01 ~]# systemctl start httpd
8.最好登录网页检查成功zabbix能否显示正常网页
登录10.0.0.7访问页面成功!!!
注意:
可以查找错误
[root@web01 ~]# vim /var/log/zabbix/zabbix_server.log