一、# 通过命令临时禁用 SELinux
setenforce 0

或者修改配置文件
sed -i ‘s/^SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

然后重启电脑

二、systemctl stop firewalld # 停止 firewalld
systemctl disable firewalld # 禁用 firewall 开机启动

三、确认服务器时间同步
ntpdate -d cn.pool.ntp.org
ntpdate cn.pool.ntp.org

四、更新yum源,腾迅,阿里,网易都可以
https://mirrors.cloud.tencent.com/help/centos.html https://mirrors.cloud.tencent.com/help/epel.html
以上是腾迅的
如果是公司网络做了限制,可能需要更换zabbix yum源,不然安装过程中会报错提示还有多少数据就被连接中断。


RHEL7/CentOS7
 cat < /etc/yum.repos.d/zabbix.repo
 [zabbix]
 name=Zabbix Official Repository - $basearch
 baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/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=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
 gpgcheck=1
 EOF

添加gpgkey

curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 
 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX 
 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
 添加之后即可使用-
 yum makecache -y
 yum install zabbix-<…>

Ubuntu 16.04
 cat > /etc/apt/sources.list.d/zabbix.list << EOF
 deb https://mirrors.aliyun.com/zabbix/zabbix/4.0/ubuntu xenial main
 deb-src https://mirrors.aliyun.com/zabbix/zabbix/4.0/ubuntu xenial main
 EOF添加key
 curl -o - “https://mirrors.aliyun.com/zabbix/zabbix-official-repo.key” | apt-key add -
 更新源,安装相关包
 apt-get update
 apt-get install -y zabbix-<…>


参考


五、如果在下面的yum源安装不报错,可以不用更换zabbix,如果不行就g更换的上面第四步***分割线以内***的yum源。
#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm 安装3.4的yum源

#yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server
这个时候有可能会报报错:“zabbix-web-3.4.15-1.el7.noarch: [Errno 256] No more mirrors to try”更换分割线内的yum源

六、 [root@localhost src]# systemctl start mariadb
 [root@localhost src]# systemctl enable mariadb

七、 [root@localhost src]# mysql

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; #创建数据库实例
 MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘; #授权localhost主机名访问数据库实例zabbix,用户名/密码:zabbix/Zabbix

八、导入初始模式和数据

进入create.sql.gz所在目录:

[root@localhost src]# cd /usr/share/doc/zabbix-server-mysql-3.4.15/

导入初始模式:

[root@localhost zabbix-server-mysql-3.4.15]# zcat create.sql.gz |mysql -uroot zabbix

九、关于zabbix配置

配置zabbix-server的配置文件zabbix_server.conf:

[root@localhost zabbix-server-mysql-3.4.15]# grep -n "^DB" /etc/zabbix/zabbix_server.conf
91:DBHost=localhost
98:DBName=zabbix
113:DBUser=zabbix

122:DBPassword=zabbix
我的配置文件是:

[root@localhost ~]# grep -Ev ‘$|#’ /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
 DBHost=localhost
 DBName=zabbix
 DBUser=‘zabbix’ #这行要加引号不然会出现zabbix服务器无法访问数据库
 DBPassword=zabbix
 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
 ListenIP=0.0.0.0
 Timeout=4
 AlertScriptsPath=/usr/lib/zabbix/alertscripts
 ExternalScripts=/usr/lib/zabbix/externalscripts
 LogSlowQueries=3000
 [root@localhost ~]#

十、 启动zabbix服务器

[root@localhost zabbix-server-mysql-3.4.15]# systemctl start zabbix-server
[root@localhost zabbix-server-mysql-3.4.15]# systemctl enable zabbix-server

十一、需要编辑Apache的配置文件,消注释设置正确的时区

[root@localhost zabbix-server-mysql-3.4.15]# grep -n “date.timezone” /etc/httpd/conf.d/zabbix.conf
 更改为:php_value date.timezone Asia/Shanghai

十二、启动服务 ,设置开机启动服务

[root@localhost zabbix-server-mysql-3.4.15]# systemctl start httpd
[root@localhost zabbix-server-mysql-3.4.15]# systemctl enable httpd
启动zabbix-agent并设置开机自启动
 [root@localhost zabbix-server-mysql-3.4.15]# systemctl start zabbix-agent[root@localhost zabbix-server-mysql-3.4.15]# systemctl enable zabbix-agent

十三、Zabbix Web网页安装

在浏览器输入地址http://服务器ip/zabbix/setup.php,出现欢迎界面,点击下一步

出现必要条件检测界面,正常都是OK,点击下一步

配置DB连接,与zabbix_server.conf文件中主机、数据库名称、用户名、密码保持一致,点击下一步

zabbix服务器详细信息,点击下一步

安装前汇总,检查信息无误,点击下一步安装

安装成功会出现提示成功的界面。

然后点击“Finish“按钮。结束安装。

zabbix网页登录

在浏览器输入http://zabbix服务器ip/zabbix/index.php,输入管理员用户名Admin(区分大小写),默认密码zabbix,点击登入即可。

十四、如果出现 3437:20200423:234047.221 [Z3001] connection to database ‘zabbix’ failed: [1045] Access denied for user ‘zabbix’@‘localhost’ (using password: NO)

3437:20200423:234047.221 database is down: reconnecting in 10 seconds

或者登录zabbix网页后发现zabbix-server服务器运行中为否。

netstat -tunlp|grep 10051

没有显示任何显示,均表示zabbix-server服务没有启动起来

请确认第九步的zabbix主配置文件为正确的,原因可能是zabbix的主配置文件读取和mariadb数据库中的grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘;授权语句中的单引号不兼容有关。确认无误后重启

#systemctl restart zabbix-server.server

进入zabbx网页后就能看到服务器已启动。

怎样关掉zabbix_agent服务 zabbix停止服务_mysql

十五、参考: