秋栈博客

七月

CentOS7快速部署zabbix

3
2022-07-10

一、关闭selinux

#按下i编辑 vi /etc/selinux/config 
#禁用
SELINUX SELINUX=disabled #注释掉这一行 
#SELINUXTYPE=targeted #使配置立即生效 sentenforce 0
或使用下面的命令
sed -i 's/selinux=enforcing/selinux=disabled/' /etc/selinux/config

二、安装zabbix存储库

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all

三、安装zabbix server和agent

yum install zabbix-server-mysql zabbix-agent

四、安装Zabbix前端

yum install centos-release-scl
编辑配置文件zabbix.repo并启用zabbix前端储存库
vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
安装Zabbix前端软件包
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl

五、安装数据库并设置开机自启

yum -y install mariadb-server systemctl start mariadb systemctl enable mariadb
初始化数据库
mysql_secure_installation Set root password?[Y/n] //输入Y并设置密码 Remove anonymous users[Y/n] //Y Disallow root login remotely?[Y/n] //n Remove test database and access to it ?[Y/n] //Y Reload privilege tables now?[Y/n] //Y
创建数据库和用户并允许远程登录
mysql -uroot -p create database zabbix character set utf8 collate utf8_bin; create user zabbix@localhost identified by '123456'; 
grant all privileges on zabbix.* to zabbix@'%'; 
flush privileges; 
exit;

六、导入初始架构和数据,输入刚创建的密码

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix

七、为Zabbix server配置数据库

vi /etc/zabbix/zabbix_server.conf
输入 /DBP 快速定位DBPassword
### Option: DBPassword 
# Database password. 
# Comment this line if no password is used. 
# # Mandatory: no 
# Default: DBPassword=123456

八、配置PHP

vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
server { listen 80; 
##配置服务器IP server_name 1.14.110.97; 
root /usr/share/zabbix; 
index index.php; 
location = /favicon.ico { log_not_found off; 
}
添加Nginx进行监听,然后配置正确时区
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock 
listen.acl_users = apache,nginx listen.allowed_clients = 127.0.0.1 ... php_value[date.timezone] = Asia/Shanghai

九、启动Zabbix server和agent进程,并设置开机自启

systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm 
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

十、浏览器访问ip/setup.php进入配置页面

环境检测,若时区未配置正确请确认 配置数据库信息,密码为123456 添加监控的第一台主机 zabbix默认账号为Admin 密码zabbix 主页面 设置中文
  • 0