2018.06.10 - zabbix的安装

本文详细记录了从零开始搭建LAMP环境,并在此基础上安装配置Zabbix 3.5的过程。包括解决安装过程中遇到的问题,如数据库配置、防火墙设置等。

前面实际操作了 LAMP(mysql5.6,php5.6)的安装,基本安装运行都没什么问题。

于是今天开始在原来的环境上安装zabbix(3.5版本),结果运行失败。甚至系统都出现了问题,不能reboot、poweroff。

也可能是远程虚拟机的问题,也可能是我所安装的环境和zabbix所需求的环境不一致造成的。

不过不管了,直接将原来的虚拟机删除了,从头来过!!!


安装起来还是很快的,毕竟是最小化安装。配置下网卡,连上网络。


转到XSHELL操作了,先完成基本的升级---yum update。

查看当前系统环境 

安装LAMP环境

yum install epel-release

yum install mariadb mariadb-server php php-mysql httpd


查看环境版本:



初始化mysql数据库,并配置root用户密码


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank,so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: 
Re-enter new password: 

Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.
Remove anonymous users? [Y/n] y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
 ... skipping.
By default, MariaDB comes with a database named 'test' that anyone can access.  This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!


创建zabbix数据库及其用户



测试刚刚创建的zabbix用户,是否可以连接mysql数据库


启动Apache服务

systemctl start httpd

netstat –tunl

firewall-cmd --zone=public --add-port=80/tcp –permanent

firewall-cmd --reload

安装zabbix的yum源(这里选择的是最新版本3.5)

rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm

安装zabbix

yum install zabbix-server-mysql zabbix-web-mysql

数据库导入

zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p zabbix

配置数据库用户及密码

vi /etc/zabbix/zabbix_server.conf

DBHost=localhost
DBName=zabbix
DBUser=zabbix

DBPassword=zabbix

SELinux配置(最终还是关闭了)

setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on

编辑Zabbix前端PHP配置,更改时区
vim /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai

重启Apache、zabbix服务

浏览器访问 http://10.50.8.230/zabbix,终于出现了这个页面了!


2018.06.12

基本设置了一下,使用正常。(报警很多....)






### 3.10 zabbix-scl.conf 文件缺失与 Zabbix 软件包依赖关系 `zabbix-scl.conf` 文件的缺失通常与未正确安装 `zabbix-apache-conf-scl` 或相关依赖包有关。该文件由 `zabbix-apache-conf-scl` 包提供,用于配置 Zabbix 前端在 Apache 下的运行环境。如果该文件缺失,则 Apache 无法加载 Zabbix 的虚拟主机配置,导致服务启动失败 [^1]。 为确保该文件正确存在,需确认以下软件包已安装- `zabbix-web-mysql-scl` - `zabbix-apache-conf-scl` 可以通过以下命令检查这些包是否已安装: ```bash rpm -q zabbix-web-mysql-scl zabbix-apache-conf-scl ``` 如果发现 `zabbix-apache-conf-scl` 未安装,应从 Zabbix 官方仓库或离线 RPM 包中安装: ```bash yum install -y zabbix-apache-conf-scl ``` 安装完成后,应检查 `/etc/httpd/conf.d/` 目录下是否生成了 `zabbix-scl.conf` 文件: ```bash ls -l /etc/httpd/conf.d/zabbix-scl.conf ``` 若文件仍然缺失,可能是因为 Zabbix SCL 仓库配置错误或未启用。需要检查 `/etc/yum.repos.d/CentOS-SCLo-scl.repo` 和 `/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo` 文件中的 `enabled` 值是否为 `1`。必要时可以手动修改配置文件,启用仓库: ```ini [centos-sclo-rh] name=CentOS-7 - SCLo rh baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo ``` 安装完成后,再次执行 `yum install zabbix-web-mysql-scl zabbix-apache-conf-scl` 命令以确保所有依赖项正确安装 [^5]。 此外,某些情况下可能由于 PHP 依赖问题导致 `zabbix-web-mysql-scl` 安装失败。例如,缺少 `rh-php72-php-mbstring` 等模块。应确保已启用 `centos-release-scl` 源,并安装以下 PHP 扩展: ```bash yum install -y rh-php72-php-mbstring rh-php72-php-bcmath rh-php72-php-gd rh-php72-php-mysqlnd rh-php72-php-xml rh-php72-php-ldap rh-php72-php-fpm rh-php72 ``` 完成上述操作后,重新安装 Zabbix 相关组件,并验证 `zabbix-scl.conf` 是否生成。 ### 3.11 检查 Apache 配置与服务状态 安装完成后,建议执行以下命令检查 Apache 配置是否正确: ```bash httpd -t ``` 如果提示 `Syntax OK`,则表示配置文件无语法错误。随后重启 Apache 服务以应用更改: ```bash systemctl restart httpd ``` 如果服务仍然无法启动,可查看 Apache 错误日志: ```bash tail -f /var/log/httpd/error_log ``` 日志中通常会记录具体的加载失败原因,如模块缺失、权限问题或 SELinux 限制等。 ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值