centos7.5离线安装zabbix4.0
Posted daofaziran
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7.5离线安装zabbix4.0相关的知识,希望对你有一定的参考价值。
一.配置环境
1.1 Linux环境说明
zabbix 安装要求 https://www.zabbix.com/documentation/4.0/zh/manual/installation/requirements
[root@localhost bw]# cat /etc/redhat-release 查看系统版本信息
CentOS Linux release 7.4.1708 (Core)
[root@localhost bw]# systemctl stop firewalld.service 关闭防火墙
[root@localhost bw]# systemctl disable firewalld.service 开机禁止启动防火墙
[root@localhost bw]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled 关闭selinux
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost bw]#setenforce 0 #临时关闭
[root@localhost bw]#getenforce #结果为Disabled 为关闭 检查selinux是否关闭
1.2 搭建LAMP环境
Zabbix是建立在LAMP或者LNMP环境之上,在此为了方便就使用yum安装LAMP环境。
# 建立仓库
[root@localhost bw]#yum -y install epel-release
[root@localhost bw]#yum -y install createrepo --downloadonly --downloaddir=/home/bw/repo
[root@localhost bw]# cd repo
[root@localhost repo]#yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash --downloadonly --downloaddir=/home/bw/repo
[root@localhost repo]# yum localinstall -y ./* 安装后检查应用版本
[root@localhost repo]# rpm -qa httpd php mariadb 安装后检查应用版本
httpd-2.4.6-89.el7.centos.x86_64
mariadb-5.5.60-1.el7_5.x86_64
php-5.4.16-46.el7.x86_64
1.2.2编辑httpd
[root@localhost repo]# vim /etc/httpd/conf/httpd.conf
95 ServerName www.aihuidi.com:80 修改主机名,URL
164 DirectoryIndex index.html index.php 修改首页文件格式
1.2.3编辑配置PHP,配置中国时区
[root@localhost repo]# vim /etc/php.ini
878 date.timezone = PRC
1.2.4启动mysqld
[root@localhost repo]# systemctl start mariadb 启动数据库
[root@localhost repo]# systemctl enable mariadb 加入开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost repo]# systemctl status mariadb 查看运行状态
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-06-13 00:31:21 CST; 11s ago
Main PID: 2490 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─2490 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─2653 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/ma...
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: MySQL manual for more instructions.
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: Please report any problems at http://mariadb.org/jira
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: The latest information about MariaDB is available at http://mariadb.org/.
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: You can find additional information about the MySQL part at:
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: http://dev.mysql.com
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: Consider joining MariaDB‘s strong and vibrant community:
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: https://mariadb.org/get-involved/
Jun 13 00:31:19 node2 mysqld_safe[2490]: 190613 00:31:19 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.
Jun 13 00:31:19 node2 mysqld_safe[2490]: 190613 00:31:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jun 13 00:31:21 node2 systemd[1]: Started MariaDB database server.
[root@localhost repo]# netstat -lntup|grep mysqld 查看服务端口是否存在
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2653/mysqld
6370/mysqld
1.2.5 初始化数据库,并设置root用户密码
[root@localhost repo]# mysqladmin -u root password 123456 设置数据库密码
[root@localhost repo]# mysql -uroot -p 登录数据库
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin; #创建zabbix数据库
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all ON zabbix.* TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | node2 |
| root | node2 |
+--------+-----------+
7 rows in set (0.00 sec)
MariaDB [(none)]> drop user ‘‘@localhost; # 删除空用户
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
| | node2 |
| root | node2 |
+--------+-----------+
6 rows in set (0.00 sec)
MariaDB [(none)]> quit;
Bye
二.安装zabbix
安装依赖包+组件
[root@localhost repo]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64 javacc.noarch javacc-javadoc.noarch javacc-maven-plugin.noarch javacc* --downloadonly --downloaddir=/home/bw/repo
[root@localhost repo]# yum install php-bcmath php-mbstring -y --downloadonly --downloaddir=/home/bw/repo #安装php支持zabbix组件
[root@localhost repo]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm 安装zabbix yum源 ,本地下载,上传到虚拟机上
[root@localhost repo]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y --downloadonly --downloaddir=/home/bw/repo 安装zabbix组件
#报错的话添加yum源
cat <<EOF > /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
# 添加密钥
curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591
-o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX
-o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
#安装zabbix agent篇(centos7)
ubuntu上请参考 在ubuntu1804上安装zabbix agent
[root@localhost repo]# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
[root@localhost repo]# yum -y install zabbix-agent-4.0.9-3.el7.x86_64.rpm
yum localinstall -y ./*
[root@localhost repo]# hostname
xxxxx
[root@localhost repo]# firewall-cmd --state
not running
[root@localhost repo]# vi /etc/zabbix/zabbix_agentd.conf
Server=xx.xx.xx.xx #zabbix-server地址
ServerActive=xx.xx.xx.xx #zabbix-server地址
Hostname=agent1 #这台安装zabbix-agent的主机名,可以通过hostname命令查看主机名
[root@localhost repo]# systemctl start zabbix-agent.service
[root@localhost repo]]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost repo]# systemctl status zabbix-agent.service
[root@localhost repo]# cat /var/log/zabbix/zabbix_agentd.log
42453:20200125:082336.776 Starting Zabbix Agent [xxxxx]. Zabbix 4.0.9 (revision 97a69d5d5a).
42453:20200125:082336.776 **** Enabled features ****
42453:20200125:082336.776 IPv6 support: YES
42453:20200125:082336.776 TLS support: YES
42453:20200125:082336.776 **************************
42453:20200125:082336.776 using configuration file: /etc/zabbix/zabbix_agentd.conf
42453:20200125:082336.778 agent #0 started [main process]
42454:20200125:082336.778 agent #1 started [collector]
42456:20200125:082336.779 agent #3 started [listener #2]
42455:20200125:082336.779 agent #2 started [listener #1]
42458:20200125:082336.780 agent #5 started [active checks #1]
42457:20200125:082336.782 agent #4 started [listener #3]
————————————————
原文链接:https://blog.csdn.net/GongMeiyan/java/article/details/104079380
yum localinstall -y ./* # 本地安装
# 导入初始架构和数据,系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: #导入数据到数据库zabbix中(最后一个zabbix是数据库zabbix),且因为用户zabbix是%(任意主机),所以登录时需要加上当前主机ip(-h 192.168.200.157)密码是用户zabbix登陆密码zabbix
[root@localhost repo]# vim /etc/zabbix/zabbix_server.conf 配置数据库密码
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
100:DBName=zabbix
116:DBUser=zabbix
124:DBPassword=123456 把注释打开写zabbix库的密码
356:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
473:Timeout=4
516:AlertScriptsPath=/usr/lib/zabbix/alertscripts
527:ExternalScripts=/usr/lib/zabbix/externalscripts
563:LogSlowQueries=3000
[root@localhost repo]# vim /etc/httpd/conf.d/zabbix.conf 修改时区
php_value date.timezone Asia/Shanghai
[root@localhost repo]# systemctl enable zabbix-server 启动zabbix服务并加入开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@localhost repo]# systemctl start zabbix-server
[root@localhost repo]# systemctl start httpd 启动httpd服务并加入开机自启动
[root@localhost repo]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost repo]#
google 浏览器访问 http://ip/zabbix
原文链接:https://blog.csdn.net/weixin_43822878/java/article/details/91569016
1、环境说明
1.1 Linux环境说明
zabbix 安装要求 https://www.zabbix.com/documentation/4.0/zh/manual/installation/requirements
[root@node2 ~]# cat /etc/redhat-release 查看系统版本信息
CentOS Linux release 7.4.1708 (Core)
[root@node2 ~]# systemctl stop firewalld.service 关闭防火墙
[root@node2 ~]# systemctl disable firewalld.service 开机禁止启动防火墙
[root@node2 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled 关闭selinux
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
#关闭selinux
setenforce 0 临时关闭selinux
getenforce 结果为Disabled 为关闭 检查selinux是否关闭
# 上传打包文件,解压并安装
[root@localhost bw]# tar -xvf repo.tar
[root@localhost bw]# ll
总用量 170892
drwxr-xr-x. 2 root root 16384 6月 19 17:26 repo
-rw-r--r--. 1 root root 174970880 6月 19 17:45 repo.tar
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 公共
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 模板
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 视频
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 图片
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 文档
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 下载
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 音乐
drwxr-xr-x. 2 bw bw 6 6月 18 14:23 桌面
[root@localhost bw]#
[root@localhost bw]# cd repo/
[root@localhost repo]# yum localinstall -y ./*
nother app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:157 M RSS (498 MB VSZ)
已启动: Fri Jun 19 17:59:42 2020 - 07:24之前
状态 :睡眠中,进程ID:3974
^C
Exiting on user cancel.
[root@localhost repo]# kill -9 3974
[root@localhost repo]# yum localinstall -y ./*
完毕!
# 查看安装状态及配置
[root@localhost repo]# rpm -qa httpd php mariadb
mariadb-5.5.65-1.el7.x86_64
php-5.4.16-48.el7.x86_64
httpd-2.4.6-93.el7.centos.x86_64
[root@localhost repo]# vim /etc/httpd/conf/httpd.conf
[root@localhost repo]#
1.2.2编辑httpd
[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
95 ServerName www.aihuidi.com:80 修改主机名,URL
164 DirectoryIndex index.html index.php 修改首页文件格式
1.2.3编辑配置PHP,配置中国时区
[root@node2 ~]# vim /etc/php.ini
878 date.timezone = PRC
1.2.4启动mysqld
[root@node2 ~]# systemctl start mariadb 启动数据库
[root@node2 ~]# systemctl enable mariadb 加入开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@node2 ~]# systemctl status mariadb 查看运行状态
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-06-13 00:31:21 CST; 11s ago
Main PID: 2490 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─2490 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─2653 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/ma...
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: MySQL manual for more instructions.
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: Please report any problems at http://mariadb.org/jira
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: The latest information about MariaDB is available at http://mariadb.org/.
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: You can find additional information about the MySQL part at:
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: http://dev.mysql.com
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: Consider joining MariaDB‘s strong and vibrant community:
Jun 13 00:31:19 node2 mariadb-prepare-db-dir[2412]: https://mariadb.org/get-involved/
Jun 13 00:31:19 node2 mysqld_safe[2490]: 190613 00:31:19 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.
Jun 13 00:31:19 node2 mysqld_safe[2490]: 190613 00:31:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jun 13 00:31:21 node2 systemd[1]: Started MariaDB database server.
[root@node2 ~]# netstat -lntup|grep mysqld 查看服务端口是否存在
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2653/mysqld
6370/mysqld
1.2.5 初始化数据库,并设置root用户密码
[root@node2 ~]# mysqladmin -u root password 123456 设置数据库密码
[root@node2 ~]# mysql -uroot -p 登录数据库
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin; #创建zabbix数据库
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all ON zabbix.* TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | node2 |
| root | node2 |
+--------+-----------+
7 rows in set (0.00 sec)
MariaDB [(none)]> drop user ‘‘@localhost; # 删除空用户
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
| | node2 |
| root | node2 |
+--------+-----------+
6 rows in set (0.00 sec)
MariaDB [(none)]> quit;
Bye
#配置zabbix agent篇(centos7)
ubuntu上请参考 在ubuntu1804上安装zabbix agent
[root@agent1 ~]# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
[root@agent1 ~]# hostname
xxxxx
[root@agent1 ~]# firewall-cmd --state
not running
[root@agent1 ~]# vi /etc/zabbix/zabbix_agentd.conf
Server=xx.xx.xx.xx #zabbix-server地址
ServerActive=xx.xx.xx.xx #zabbix-server地址
Hostname=agent1 #这台安装zabbix-agent的主机名,可以通过hostname命令查看主机名
[root@agent1 ~]# systemctl start zabbix-agent.service
[root@agent1 ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@agent1 ~]# systemctl status zabbix-agent.service
[root@agent1 ~]# cat /var/log/zabbix/zabbix_agentd.log
42453:20200125:082336.776 Starting Zabbix Agent [xxxxx]. Zabbix 4.0.9 (revision 97a69d5d5a).
42453:20200125:082336.776 **** Enabled features ****
42453:20200125:082336.776 IPv6 support: YES
42453:20200125:082336.776 TLS support: YES
42453:20200125:082336.776 **************************
42453:20200125:082336.776 using configuration file: /etc/zabbix/zabbix_agentd.conf
42453:20200125:082336.778 agent #0 started [main process]
42454:20200125:082336.778 agent #1 started [collector]
42456:20200125:082336.779 agent #3 started [listener #2]
42455:20200125:082336.779 agent #2 started [listener #1]
42458:20200125:082336.780 agent #5 started [active checks #1]
42457:20200125:082336.782 agent #4 started [listener #3]
————————————————
原文链接:https://blog.csdn.net/GongMeiyan/java/article/details/104079380
# 导入初始架构和数据,系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: #导入数据到数据库zabbix中(最后一个zabbix是数据库zabbix),且因为用户zabbix是%(任意主机),所以登录时需要加上当前主机ip(-h 192.168.200.157)密码是用户zabbix登陆密码zabbix
[root@node2 ~]# vim /etc/zabbix/zabbix_server.conf 配置数据库密码
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
100:DBName=zabbix
116:DBUser=zabbix
124:DBPassword=123456 把注释打开写zabbix库的密码
356:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
473:Timeout=4
516:AlertScriptsPath=/usr/lib/zabbix/alertscripts
527:ExternalScripts=/usr/lib/zabbix/externalscripts
563:LogSlowQueries=3000
[root@node2 ~]# vim /etc/httpd/conf.d/zabbix.conf 修改时区
php_value date.timezone Asia/Shanghai
[root@node2 ~]# systemctl enable zabbix-server 启动zabbix服务并加入开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@node2 ~]# systemctl start zabbix-server
[root@node2 ~]# systemctl start httpd 启动httpd服务并加入开机自启动
[root@node2 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@node2 ~]#
google 浏览器访问 http://ip/zabbix
以上是关于centos7.5离线安装zabbix4.0的主要内容,如果未能解决你的问题,请参考以下文章