3.0版本源:https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/
4.0版本源:https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
zabbix官方镜像源就是他妈的个大坑……
登陆zabbix的初始账号密码:U:Admin P:zabbix (注意大小写)
DBPassword=
DBSocket=
安装环境:
centos7.8,关闭selinux,firewalld,epel源和centos7镜像源还是要的,老铁,这个简单,阿里走一波
安装步骤:
由于zabbix依赖lamp/lnmp环境,
这边apache和php直接yum安装
1,安装apache,php
yum -y install httpd
systemctl start httpd
systemctl status httpd
systemctl enable httpd
yum -y install php
php-mysql是一个用于让PHP程序使用MYSQL数据库的模块。需要安装改模块,使用命令:
yum -y install php-mysql
查看apache安装目录下,有无此二文件:
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/10-php.conf
它的设定让Apache可以加载PHP模块
重启apache:systemctl restart httpd
测试能否调用PHP程序
echo " " >> /var/www/html/info.php
2,安装mysql:采用编译安装,便于管理
版本:mysql-5.6.22.tar.gz
yum install -y cmake gcc-c++ ncurses-devel git perl-devel (若缺少包,自行补装)
cd /mnt/ && tar xzvf mysql-5.6.22.tar.gz && cd mysql-5.6.22 && groupadd mysql && mkdir -pv /data/mysql && useradd -r -g mysql -d /data/mysql -s /sbin/nologgin mysql && chown -R mysql.mysql /data/mysql && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci && make && make install && chmod -R 755 /usr/local/mysql && cd /usr/local/mysql && ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
此编译已执行无误
在下使用salt批量安装的,阁下可仅执行cmd.run后的命令即可:
salt '' cmd.run "cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf"
salt '' cmd.run "sed -i '/mysqld/a\datadir = /data/mysql' /etc/my.cnf"
salt '' cmd.run "sed -i '/datadir=/s#\/var\/lib\/mysql#\/data\/mysql#g' /etc/my.cnf"
salt '' cmd.run "cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld"
salt '' cmd.run "chmod 755 /etc/init.d/mysqld;chkconfig --add mysqld;chkconfig mysqld on"
salt '' cmd.run "echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile.d/mysqld.sh"
salt '*' cmd.run "/etc/init.d/mysqld restart"
请自行启用日志
启动数据库:/etc/init.d/mysqld start
查看端口:ss -nlt
[20:29:58-root@jack mysql]#ss -nlt |egrep -v ":22|:25"
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 1000 :4505 :
LISTEN 0 1000 :4506 :
LISTEN 0 80 [::]:3306 [::]:
LISTEN 0 511 [::]:80 [::]:
3,安装zabbix
官网:https://www.zabbix.com/download_sources
#rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
#yum clean all
然后要去改源地址:不然会一直提示没有软件包,这可是官网啊,我无语了(推荐使用清华的下载地址本文开端所提)
#yum install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
#mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password'; (也可指定主机登陆)
mysql> grant all privileges on zabbix. to zabbix@localhost;
mysql> quit;
导入初始架构和数据
#zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
在zabbix库中看到新建的表和数据
需要对zabbix-server配置,否则启动不会监听端口:
编辑文件/etc/zabbix/zabbix_server.conf
DBPassword=zabbix
DBSocket=/tmp/mysql.sock (此配置必须要,否则不监听10051端口,zabbix页面会报错)
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区
php_value date.timezone Asia/Shanghai
4,启动zabbix服务端和客户端
#systemctl restart zabbix-server zabbix-agent
#systemctl enable zabbix-server zabbix-agent
5,查看端口
[20:42:36-root@jack mysql]#ss -nlt|egrep -v ":22|25"
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 1000 :4505 :
LISTEN 0 1000 :4506 :
LISTEN 0 128 :10050 :
LISTEN 0 128 :10051 :
LISTEN 0 128 [::]:10050 [::]:
LISTEN 0 128 [::]:10051 [::]:
LISTEN 0 80 [::]:3306 [::]:
LISTEN 0 511 [::]:80 [::]:
6,进入zabbix进行设置
http://jack7/zabbix/setup
7,关于设置的问题,最多可能就是关于数据库的配置,一般就是关于库的授权和导入架构的问题
会提示数据库无法连接,不是zabbix的库
8,更多问题可以查看zabbix和mysql的日志