1安装之前的准备
1.1关闭防火墙
- 临时关闭防火墙:sudo systemctl stop firewalld
- 永久关闭防火墙:sudo systemctl disable firewalld,然后reboot重启
- 查看防火墙状态:sudo systemctl status firewalld
1.2关闭SELinux
- 查看当前状态:getenforce
- 临时关闭:setenforce 0
- 永久关闭:vim /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,保存后重启
2安装及配置数据库
2.1安装数据库
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7- x86_64/pgdg-centos10-10-2.noarch.rpm -y
yum install postgresql10-contrib postgresql10-server -y
2.2初始化数据库
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl start postgresql-10
systemctl enable postgresql-10.service
2.3配置数据库
- 切换用户到postgres:su - postgres
- 进入pgsql:psql
- 配置密码:ALTER USER postgres WITH PASSWORD '111111';
- 创建数据库和用户:CREATE DATABASE zabbix;CREATE USER zabbix CREATEDB LOGIN PASSWORD '111111';GRANT ALL ON DATABASE zabbix TO zabbix;
- 修改监听地址权限
vim /var/lib/pgsql/10/data/postgresql.conf修改为listen_addresses = '*'
vim /var/lib/pgsql/10/data/pg_hba.conf,末尾添加一行:host all all 0.0.0.0/0 md5
3安装php
安装php源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y - mod_php72w yum-utils php72w-cli php72w-common php72w-gd php72w-mbstring php72w-mysql
php72-xml php72-fpm php-redis php72w-xml php72w-fpm
systemctl enable php-fpm.service
systemctl start php-fpm
4安装及配置zabbix
4.1安装zabbix
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 -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-agent
4.2导入初始架构和数据
zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
4.3为Zabbix服务器配置数据库
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区:php_value date.timezone Asia/Shanghai
vi /etc/zabbix/zabbix_server.conf
DBHOST =localhost
数据库名= zabbix
DBUSER = zabbix
DBPASSWORD = 111111
4.4其他配置
修改文件权限
chown -R root:apache /var/lib/php
httpd配置 vim /etc/httpd/conf/httpd.conf:ServerName x.x.x.x(定义客户端从服务器读取数据时返回给客户端的主机名)
DocumentRoot "/usr/share/zabbix"
4.5启动Zabbix服务器和代理程序进程并使其在系统引导时启动
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
4.6安装php
打开网址安装
http://x.x.x.x/setup.php
按照提示进行安装
按照提示修改 vim /etc/php.ini 里面参数 时区设置为PRC
按照提示进行操作完成安装
5用zabbix监控linux主机
在被监控主机上安装
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 -y zabbix40-agent.x86_64
cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.old
vim /etc/zabbix/zabbix_agentd.conf #清空配置文件
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.10.104 # 填写zabbix_server服务端 的 IP
ListenPort=10050
ServerActive=192.168.10.104 # 填写zabbix_server服务端 的 IP
Hostname=aliyun #监控端主机名
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/*.conf
systemctl restart zabbix-agent
去网页新建主机 添加模板即可监控
6版本配置
软件 |
版本 |
Centos |
7 |
Postgresql |
10 |
Zabbix |
4.0 |