centos7.2 部署zabbix 3.2.7
centos7.2 部署zabbix 3.2.7
[zabbix@zabbixServer ~]$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
不得不说,官方文档确实强大
1.官方文档地址:
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages
2.导入源:
[zabbix@zabbixServer ~]$
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
3.安装zabbix包
[zabbix@zabbixServer ~]$ sudo yum install zabbix*
清楚的看一下要安装那些包
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
zabbix-agent x86_64 3.2.7-1.el7 zabbix 345 k
zabbix-get x86_64 3.2.7-1.el7 zabbix 237 k
zabbix-java-gateway x86_64 3.2.7-1.el7 zabbix 720 k
zabbix-proxy-mysql x86_64 3.2.7-1.el7 zabbix 650 k
zabbix-proxy-pgsql x86_64 3.2.7-1.el7 zabbix 650 k
zabbix-proxy-sqlite3 x86_64 3.2.7-1.el7 zabbix 629 k
zabbix-sender x86_64 3.2.7-1.el7 zabbix 247 k
zabbix-server-mysql x86_64 3.2.7-1.el7 zabbix 1.8 M
zabbix-server-pgsql x86_64 3.2.7-1.el7 zabbix 1.8 M
zabbix-web noarch 3.2.7-1.el7 zabbix 3.7 M
zabbix-web-japanese noarch 3.2.7-1.el7 zabbix 6.2 k
zabbix-web-mysql noarch 3.2.7-1.el7 zabbix 5.8 k
zabbix-web-pgsql noarch 3.2.7-1.el7 zabbix 5.8 k
Installing for dependencies:
OpenIPMI-libs x86_64 2.0.19-15.el7 base 502 k
OpenIPMI-modalias x86_64 2.0.19-15.el7 base 15 k
fping x86_64 3.10-1.el7 zabbix-non-supported 40 k
httpd x86_64 2.4.6-45.el7.centos.4 updates 2.7 M
httpd-tools x86_64 2.4.6-45.el7.centos.4 updates 84 k
iksemel x86_64 1.4-2.el7.centos zabbix-non-supported 49 k
libzip x86_64 0.10.1-8.el7 base 48 k
mailcap noarch 2.1.41-2.el7 base 31 k
php x86_64 5.4.16-42.el7 base 1.4 M
php-bcmath x86_64 5.4.16-42.el7 base 57 k
php-cli x86_64 5.4.16-42.el7 base 2.7 M
php-common x86_64 5.4.16-42.el7 base 564 k
php-gd x86_64 5.4.16-42.el7 base 127 k
php-ldap x86_64 5.4.16-42.el7 base 52 k
php-mbstring x86_64 5.4.16-42.el7 base 505 k
php-mysql x86_64 5.4.16-42.el7 base 101 k
php-pdo x86_64 5.4.16-42.el7 base 98 k
php-pgsql x86_64 5.4.16-42.el7 base 86 k
php-xml x86_64 5.4.16-42.el7 base 125 k
postgresql-libs x86_64 9.2.18-1.el7 base 232 k
t1lib x86_64 5.1.2-14.el7 base 166 k
unixODBC x86_64 2.3.1-11.el7 base 413 k
vlgothic-p-fonts noarch 20130607-2.el7 base 2.2 M
Transaction Summary
=================================================================================================================================================================================================================
Install 13 Packages (+23 Dependent packages)
Total download size: 23 M
Installed size: 90 M
Is this ok [y/d/N]:
******************************************************
Installed:
zabbix-agent.x86_64 0:3.2.7-1.el7 zabbix-get.x86_64 0:3.2.7-1.el7 zabbix-java-gateway.x86_64 0:3.2.7-1.el7 zabbix-proxy-mysql.x86_64 0:3.2.7-1.el7 zabbix-proxy-pgsql.x86_64 0:3.2.7-1.el7
zabbix-proxy-sqlite3.x86_64 0:3.2.7-1.el7 zabbix-sender.x86_64 0:3.2.7-1.el7 zabbix-server-mysql.x86_64 0:3.2.7-1.el7 zabbix-server-pgsql.x86_64 0:3.2.7-1.el7 zabbix-web.noarch 0:3.2.7-1.el7
zabbix-web-japanese.noarch 0:3.2.7-1.el7 zabbix-web-mysql.noarch 0:3.2.7-1.el7 zabbix-web-pgsql.noarch 0:3.2.7-1.el7
Dependency Installed:
OpenIPMI-libs.x86_64 0:2.0.19-15.el7 OpenIPMI-modalias.x86_64 0:2.0.19-15.el7 fping.x86_64 0:3.10-1.el7 httpd.x86_64 0:2.4.6-45.el7.centos.4 httpd-tools.x86_64 0:2.4.6-45.el7.centos.4
iksemel.x86_64 0:1.4-2.el7.centos libzip.x86_64 0:0.10.1-8.el7 mailcap.noarch 0:2.1.41-2.el7 php.x86_64 0:5.4.16-42.el7 php-bcmath.x86_64 0:5.4.16-42.el7
php-cli.x86_64 0:5.4.16-42.el7 php-common.x86_64 0:5.4.16-42.el7 php-gd.x86_64 0:5.4.16-42.el7 php-ldap.x86_64 0:5.4.16-42.el7 php-mbstring.x86_64 0:5.4.16-42.el7
php-mysql.x86_64 0:5.4.16-42.el7 php-pdo.x86_64 0:5.4.16-42.el7 php-pgsql.x86_64 0:5.4.16-42.el7 php-xml.x86_64 0:5.4.16-42.el7 postgresql-libs.x86_64 0:9.2.18-1.el7
t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7 vlgothic-p-fonts.noarch 0:20130607-2.el7
Complete!
******************************************************
安装完成之后,看还缺少哪些包:
rpm -q zabbix-agent zabbix-get zabbix-java-gateway zabbix-proxy-mysql zabbix-proxy-pgsql zabbix-proxy-sqlite3 zabbix-sender zabbix-server-mysql zabbix-server-pgsql zabbix-web zabbix-web-japanese zabbix-web-mysql zabbix-web-pgsql
Installing for dependencies:
依赖环境检测:
rpm -q OpenIPMI-libs OpenIPMI-modalias fping httpd httpd-tools iksemel libzip mailcap php php-bcmath php-cli php-common php-gd php-ldap php-mbstring php-mysql php-pdo php-pgsql php-xml postgresql-libs t1lib unixODBC vlgothic-p-fonts
4.我们给本机也安装上客户端
[zabbix@zabbixServer ~]$ sudo yum install zabbix-agent
5.初始化数据库
CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。用mariadb也行。我还是选择了mysql
(1)安装mysql
安装mysql社区版官方源
[zabbix@zabbixServer ~]$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[zabbix@zabbixServer ~]$ rpm -ivh mysql-community-release-el7-5.noarch.rpm
#查看可以安装的mysql版本
[root@zabbixServer ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 39
mysql-tools-community/x86_64 MySQL Tools Community 47
mysql56-community/x86_64 MySQL 5.6 Community Server 344
#安装带有当前可用的mysql5系列社区版资源的rpm包
[zabbix@zabbixServer ~]$ sudo yum install mysql-community-server
*****************************************************************************
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.6.37-2.el7 mysql56-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.52-1.el7
mysql-community-server x86_64 5.6.37-2.el7 mysql56-community 59 M
Installing for dependencies:
mysql-community-client x86_64 5.6.37-2.el7 mysql56-community 19 M
mysql-community-common x86_64 5.6.37-2.el7 mysql56-community 257 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
Transaction Summary
=================================================================================================================================================================================================================
Install 2 Packages (+8 Dependent packages)
Total download size: 82 M
Is this ok [y/d/N]:
*********************************************************************
安装完成:
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql-community-release-el7-5.noarch (installed)
From : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Installed:
mysql-community-libs.x86_64 0:5.6.37-2.el7 mysql-community-server.x86_64 0:5.6.37-2.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.6.37-2.el7 mysql-community-common.x86_64 0:5.6.37-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
Replaced:
mariadb-libs.x86_64 1:5.5.52-1.el7
Complete!
************************************************************************
[zabbix@zabbixServer ~]$ sudo systemctl enable mysqld #设置开机启动
[zabbix@zabbixServer ~]$ systemctl start mysqld #启动服务
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
进入mysql报错:
[zabbix@zabbixServer ~]$ mysql -uroot -p
Enter password: 直接回车 密码默认为空!
如果正常进入,继续执行下一步,如果出现如下错误,按照提示操作:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决办法:
[zabbix@zabbixServer ~]$ sudo mysql_secure_installation
按照提示一步步来。
进入mysql,创建zabbix数据库并授权!
mysql>create database zabbix character set utf8 collate utf8_bin;
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql>flush privileges;
mysql>quit;
(2)进入到这个目录
[root@zabbixServer zabbix-server-mysql-3.2.7]# pwd
/usr/share/doc/zabbix-server-mysql-3.2.7
[root@zabbixServer zabbix-server-mysql-3.2.7]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
导入zabbix数据库
[root@zabbixServer zabbix-server-mysql-3.2.7]# zcat create.sql.gz |mysql -uzabbix -pzabbix -b zabbix
Warning: Using a password on the command line interface can be insecure.
5.修改配置文件:修改zabbix配置,主要是zabbix数据库用户名和密码的设定
[zabbix@zabbixServer ~]$ vim /etc/zabbix/zabbix_server.conf
DBUser=zabbix --配置默认数据库用户名 如果你创建zabbix数据库的时候不一样,请更改
DBPassword=zabbix --去掉前面的#号 配置默认的数据库密码没有设定,改成你设定的密码
其他的默认就可以。
6.启动zabbix服务,并设置开机自启动
启动zabbix server服务
[root@zabbixServer ~]# systemctl start zabbix-server ---第一次执行 可能会出现如下提示:
Job for zabbix-server.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
[root@zabbixServer ~]# systemctl start zabbix-server
[root@zabbixServer ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
7.编辑zabbix前端的PHP配合配置
[zabbix@zabbixServer ~]$ sudo vim /etc/httpd/conf.d/zabbix.conf
编辑zabbix前端的php配置,更改下时区
vim /etc/httpd/conf.d/zabbix.conf
去掉时区前的#号,改一下位置
php_value date.timezone Asia/Shanghai
其他默认
8 启动apache服务,设置开机自启动
[root@zabbixServer ~]# systemctl start httpd
[root@zabbixServer ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
8.登陆zabbix
http://IP/zabbix/
上述IP地址,为安装zabbix服务的机器IP地址,
如果用的虚拟环境,或者阿里云,记得关闭防火墙,或者开通相关的web端口,要不会出现远程访问不了。
*****************************************
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
systemctlrestart iptables.service #最后重启防火墙使配置生效
systemctlenable iptables.service #设置防火墙开机启动
*************************************************************
参考地址:
http://www.centoscn.com/CentosSecurity/CentosSafe/2015/0126/4558.html
http://www.cnblogs.com/me80/p/7232975.html
http://blog.csdn.net/sunxiaoju/article/details/53261099
https://github.com/zabbixcn/zabbix3.0-rpm
http://itnihao.blog.51cto.com/1741976/1742701
http://www.cnblogs.com/linprogram/p/5730809.html
http://www.cnblogs.com/linprogram/p/5730861.html
http://blog.csdn.net/u014057054/article/details/66476990
https://wenku.baidu.com/view/76623efa4b35eefdc9d33397.html
zabbix官方源:
http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/