如题所示,本文在RHEL7上部署Zabbix-server【服务端】。
启用:YUM缓存
[root@zabbix-server ~]# cat /etc/yum.conf | grep --color keepcache keepcache=0 [root@zabbix-server ~]# sed -i "/keepcache/s/0/1/" /etc/yum.conf [root@zabbix-server ~]# cat /etc/yum.conf | grep --color keepcache keepcache=1 [root@zabbix-server ~]# cat /etc/yum.conf | grep --color cachedir cachedir=/var/cache/yum/$basearch/$releasever [root@zabbix-server ~]#
是否可以连通外网:
[root@zabbix-server ~]# ping -c 2 baidu.com PING baidu.com (123.125.114.144) 56(84) bytes of data. 64 bytes from 123.125.114.144: icmp_seq=1 ttl=128 time=138 ms 64 bytes from 123.125.114.144: icmp_seq=2 ttl=128 time=141 ms --- baidu.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1005ms rtt min/avg/max/mdev = 138.704/140.057/141.410/1.353 ms [root@zabbix-server ~]#
YUM:
1. 安装Zabbix官方源
http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@zabbix-server ~]# mkdir /software [root@zabbix-server ~]# cd /software [root@zabbix-server software]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm --2016-09-23 06:13:39-- http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm Resolving repo.zabbix.com (repo.zabbix.com)... 162.243.159.138 Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 13392 (13K) [application/x-redhat-package-manager] Saving to: ‘zabbix-release-3.2-1.el7.noarch.rpm’ 100%[======================================================================>] 13,392 56.9KB/s in 0.2s 2016-09-23 06:13:40 (56.9 KB/s) - ‘zabbix-release-3.2-1.el7.noarch.rpm’ saved [13392/13392] [root@zabbix-server software]# ls zabbix-release-3.2-1.el7.noarch.rpm [root@zabbix-server software]# [root@zabbix-server software]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm warning: zabbix-release-3.2-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-3.2-1.el7 ################################# [100%] [root@zabbix-server software]#
2. 安装epel官方源(Fedora)
http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
刷新YUM源:
[root@zabbix-server software]# yum repolist Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 zabbix | 951 B 00:00:00 zabbix-non-supported | 951 B 00:00:00 updates/7/x86_64/primary_db | 7.8 MB 00:00:24 (1/2): zabbix/x86_64/primary | 3.3 kB 00:00:00 (2/2): zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn zabbix 14/14 zabbix-non-supported 4/4 repo id repo name status base/7/x86_64 CentOS-7 - Base 9,007 extras/7/x86_64 CentOS-7 - Extras 390 updates/7/x86_64 CentOS-7 - Updates 2,471 zabbix/x86_64 Zabbix Official Repository - x86_64 14 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4 repolist: 11,886 [root@zabbix-server software]#
一、 安装:zabbix-server
CMD:yum install -y zabbix-server-mysql zabbix-web-mysql
[root@zabbix-server software]# yum install zabbix-server-mysql zabbix-web-mysql Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package zabbix-server-mysql.x86_64 0:3.2.0-1.el7 will be installed --> Processing Dependency: fping for package: zabbix-server-mysql-3.2.0-1.el7.x86_64 --> Processing Dependency: libiksemel.so.3()(64bit) for package: zabbix-server-mysql-3.2.0-1.el7.x86_64 --> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: zabbix-server-mysql-3.2.0-1.el7.x86_64 --> Processing Dependency: libodbc.so.2()(64bit) for package: zabbix-server-mysql-3.2.0-1.el7.x86_64 --> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: zabbix-server-mysql-3.2.0-1.el7.x86_64 ---> Package zabbix-web-mysql.noarch 0:3.2.0-1.el7 will be installed --> Processing Dependency: zabbix-web = 3.2.0-1.el7 for package: zabbix-web-mysql-3.2.0-1.el7.noarch --> Processing Dependency: php-mysql for package: zabbix-web-mysql-3.2.0-1.el7.noarch --> Running transaction check ---> Package OpenIPMI-libs.x86_64 0:2.0.19-11.el7 will be installed --> Processing Dependency: OpenIPMI-modalias = 2.0.19-11.el7 for package: OpenIPMI-libs-2.0.19-11.el7.x86_64 ---> Package fping.x86_64 0:3.10-1.el7 will be installed ---> Package iksemel.x86_64 0:1.4-2.el7.centos will be installed ---> Package php-mysql.x86_64 0:5.4.16-36.3.el7_2 will be installed --> Processing Dependency: php-pdo(x86-64) = 5.4.16-36.3.el7_2 for package: php-mysql-5.4.16-36.3.el7_2.x86_64 ---> Package unixODBC.x86_64 0:2.3.1-11.el7 will be installed ---> Package zabbix-web.noarch 0:3.2.0-1.el7 will be installed --> Processing Dependency: php >= 5.4 for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: php-gd for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: php-mbstring for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: php-bcmath for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: httpd for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: php-ldap for package: zabbix-web-3.2.0-1.el7.noarch --> Processing Dependency: php-xml for package: zabbix-web-3.2.0-1.el7.noarch --> Running transaction check ---> Package OpenIPMI-modalias.x86_64 0:2.0.19-11.el7 will be installed ---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed --> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64 ---> Package php.x86_64 0:5.4.16-36.3.el7_2 will be installed --> Processing Dependency: php-common(x86-64) = 5.4.16-36.3.el7_2 for package: php-5.4.16-36.3.el7_2.x86_64 --> Processing Dependency: php-cli(x86-64) = 5.4.16-36.3.el7_2 for package: php-5.4.16-36.3.el7_2.x86_64 ---> Package php-bcmath.x86_64 0:5.4.16-36.3.el7_2 will be installed ---> Package php-gd.x86_64 0:5.4.16-36.3.el7_2 will be installed --> Processing Dependency: libt1.so.5()(64bit) for package: php-gd-5.4.16-36.3.el7_2.x86_64 ---> Package php-ldap.x86_64 0:5.4.16-36.3.el7_2 will be installed ---> Package php-mbstring.x86_64 0:5.4.16-36.3.el7_2 will be installed ---> Package php-pdo.x86_64 0:5.4.16-36.3.el7_2 will be installed ---> Package php-xml.x86_64 0:5.4.16-36.3.el7_2 will be installed --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed ---> Package php-cli.x86_64 0:5.4.16-36.3.el7_2 will be installed ---> Package php-common.x86_64 0:5.4.16-36.3.el7_2 will be installed --> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-36.3.el7_2.x86_64 ---> Package t1lib.x86_64 0:5.1.2-14.el7 will be installed --> Running transaction check ---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Installing: zabbix-server-mysql x86_64 3.2.0-1.el7 zabbix 1.7 M zabbix-web-mysql noarch 3.2.0-1.el7 zabbix 5.0 k Installing for dependencies: OpenIPMI-libs x86_64 2.0.19-11.el7 base 501 k OpenIPMI-modalias x86_64 2.0.19-11.el7 base 15 k apr x86_64 1.4.8-3.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k fping x86_64 3.10-1.el7 zabbix-non-supported 40 k httpd x86_64 2.4.6-40.el7.centos.4 updates 2.7 M httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 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-36.3.el7_2 updates 1.4 M php-bcmath x86_64 5.4.16-36.3.el7_2 updates 56 k php-cli x86_64 5.4.16-36.3.el7_2 updates 2.7 M php-common x86_64 5.4.16-36.3.el7_2 updates 563 k php-gd x86_64 5.4.16-36.3.el7_2 updates 126 k php-ldap x86_64 5.4.16-36.3.el7_2 updates 51 k php-mbstring x86_64 5.4.16-36.3.el7_2 updates 504 k php-mysql x86_64 5.4.16-36.3.el7_2 updates 100 k php-pdo x86_64 5.4.16-36.3.el7_2 updates 97 k php-xml x86_64 5.4.16-36.3.el7_2 updates 124 k t1lib x86_64 5.1.2-14.el7 base 166 k unixODBC x86_64 2.3.1-11.el7 base 413 k zabbix-web noarch 3.2.0-1.el7 zabbix 3.6 M Transaction Summary ================================================================================================================ Install 2 Packages (+23 Dependent packages) Total download size: 15 M Installed size: 68 M Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7/base/packages/OpenIPMI-modalias-2.0.19-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for OpenIPMI-modalias-2.0.19-11.el7.x86_64.rpm is not installed (1/25): OpenIPMI-modalias-2.0.19-11.el7.x86_64.rpm | 15 kB 00:00:00 (2/25): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 Public key for httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm is not installed ] 151 kB/s | 466 kB 00:01:40 ETA (3/25): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:00 (4/25): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:02 (5/25): libzip-0.10.1-8.el7.x86_64.rpm | 48 kB 00:00:00 (6/25): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00 warning: /var/cache/yum/x86_64/7/zabbix-non-supported/packages/iksemel-1.4-2.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY Public key for iksemel-1.4-2.el7.centos.x86_64.rpm is not installed (7/25): iksemel-1.4-2.el7.centos.x86_64.rpm | 49 kB 00:00:01 (8/25): OpenIPMI-libs-2.0.19-11.el7.x86_64.rpm | 501 kB 00:00:04 (9/25): fping-3.10-1.el7.x86_64.rpm | 40 kB 00:00:04 (10/25): php-bcmath-5.4.16-36.3.el7_2.x86_64.rpm | 56 kB 00:00:00 (11/25): php-gd-5.4.16-36.3.el7_2.x86_64.rpm | 126 kB 00:00:02 (12/25): php-ldap-5.4.16-36.3.el7_2.x86_64.rpm | 51 kB 00:00:00 (13/25): php-5.4.16-36.3.el7_2.x86_64.rpm | 1.4 MB 00:00:13 (14/25): php-mbstring-5.4.16-36.3.el7_2.x86_64.rpm | 504 kB 00:00:09 (15/25): php-mysql-5.4.16-36.3.el7_2.x86_64.rpm | 100 kB 00:00:01 (16/25): php-xml-5.4.16-36.3.el7_2.x86_64.rpm | 124 kB 00:00:01 (17/25): php-pdo-5.4.16-36.3.el7_2.x86_64.rpm | 97 kB 00:00:02 (18/25): php-common-5.4.16-36.3.el7_2.x86_64.rpm | 563 kB 00:00:16 (19/25): t1lib-5.1.2-14.el7.x86_64.rpm | 166 kB 00:00:02 (20/25): unixODBC-2.3.1-11.el7.x86_64.rpm | 413 kB 00:00:06 (21/25): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:38 (22/25): php-cli-5.4.16-36.3.el7_2.x86_64.rpm | 2.7 MB 00:00:38 warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-server-mysql-3.2.0-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Public key for zabbix-server-mysql-3.2.0-1.el7.x86_64.rpm is not installed (23/25): zabbix-server-mysql-3.2.0-1.el7.x86_64.rpm | 1.7 MB 00:00:30 (24/25): zabbix-web-mysql-3.2.0-1.el7.noarch.rpm | 5.0 kB 00:00:00 (25/25): zabbix-web-3.2.0-1.el7.noarch.rpm | 3.6 MB 00:00:38 ---------------------------------------------------------------------------------------------------------------- Total 257 kB/s | 15 MB 00:01:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX Importing GPG key 0x79EA5ED4: Userid : "Zabbix SIA " Fingerprint: fbab d5fb 2025 5eca b22e e194 d13d 58e4 79ea 5ed4 Package : zabbix-release-3.2-1.el7.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX Is this ok [y/N]: y Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) " Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Is this ok [y/N]: y Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 Importing GPG key 0xA14FE591: Userid : "Zabbix LLC " Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591 Package : zabbix-release-3.2-1.el7.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : apr-1.4.8-3.el7.x86_64 1/25 Installing : apr-util-1.5.2-6.el7.x86_64 2/25 Installing : httpd-tools-2.4.6-40.el7.centos.4.x86_64 3/25 Installing : libzip-0.10.1-8.el7.x86_64 4/25 Installing : php-common-5.4.16-36.3.el7_2.x86_64 5/25 Installing : php-xml-5.4.16-36.3.el7_2.x86_64 6/25 Installing : php-ldap-5.4.16-36.3.el7_2.x86_64 7/25 Installing : php-cli-5.4.16-36.3.el7_2.x86_64 8/25 Installing : php-pdo-5.4.16-36.3.el7_2.x86_64 9/25 Installing : php-mysql-5.4.16-36.3.el7_2.x86_64 10/25 Installing : php-bcmath-5.4.16-36.3.el7_2.x86_64 11/25 Installing : php-mbstring-5.4.16-36.3.el7_2.x86_64 12/25 Installing : unixODBC-2.3.1-11.el7.x86_64 13/25 Installing : t1lib-5.1.2-14.el7.x86_64 14/25 Installing : php-gd-5.4.16-36.3.el7_2.x86_64 15/25 Installing : OpenIPMI-modalias-2.0.19-11.el7.x86_64 16/25 Installing : OpenIPMI-libs-2.0.19-11.el7.x86_64 17/25 Installing : iksemel-1.4-2.el7.centos.x86_64 18/25 Installing : mailcap-2.1.41-2.el7.noarch 19/25 Installing : httpd-2.4.6-40.el7.centos.4.x86_64 20/25 Installing : php-5.4.16-36.3.el7_2.x86_64 21/25 Installing : zabbix-web-mysql-3.2.0-1.el7.noarch 22/25 Installing : zabbix-web-3.2.0-1.el7.noarch 23/25 Installing : fping-3.10-1.el7.x86_64 24/25 Installing : zabbix-server-mysql-3.2.0-1.el7.x86_64 25/25 Verifying : fping-3.10-1.el7.x86_64 1/25 Verifying : mailcap-2.1.41-2.el7.noarch 2/25 Verifying : zabbix-web-3.2.0-1.el7.noarch 3/25 Verifying : iksemel-1.4-2.el7.centos.x86_64 4/25 Verifying : httpd-2.4.6-40.el7.centos.4.x86_64 5/25 Verifying : OpenIPMI-libs-2.0.19-11.el7.x86_64 6/25 Verifying : php-xml-5.4.16-36.3.el7_2.x86_64 7/25 Verifying : apr-1.4.8-3.el7.x86_64 8/25 Verifying : php-mysql-5.4.16-36.3.el7_2.x86_64 9/25 Verifying : OpenIPMI-modalias-2.0.19-11.el7.x86_64 10/25 Verifying : php-ldap-5.4.16-36.3.el7_2.x86_64 11/25 Verifying : php-common-5.4.16-36.3.el7_2.x86_64 12/25 Verifying : zabbix-web-mysql-3.2.0-1.el7.noarch 13/25 Verifying : t1lib-5.1.2-14.el7.x86_64 14/25 Verifying : php-5.4.16-36.3.el7_2.x86_64 15/25 Verifying : unixODBC-2.3.1-11.el7.x86_64 16/25 Verifying : php-cli-5.4.16-36.3.el7_2.x86_64 17/25 Verifying : apr-util-1.5.2-6.el7.x86_64 18/25 Verifying : zabbix-server-mysql-3.2.0-1.el7.x86_64 19/25 Verifying : httpd-tools-2.4.6-40.el7.centos.4.x86_64 20/25 Verifying : php-gd-5.4.16-36.3.el7_2.x86_64 21/25 Verifying : php-pdo-5.4.16-36.3.el7_2.x86_64 22/25 Verifying : php-bcmath-5.4.16-36.3.el7_2.x86_64 23/25 Verifying : libzip-0.10.1-8.el7.x86_64 24/25 Verifying : php-mbstring-5.4.16-36.3.el7_2.x86_64 25/25 Installed: zabbix-server-mysql.x86_64 0:3.2.0-1.el7 zabbix-web-mysql.noarch 0:3.2.0-1.el7 Dependency Installed: OpenIPMI-libs.x86_64 0:2.0.19-11.el7 OpenIPMI-modalias.x86_64 0:2.0.19-11.el7 apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 fping.x86_64 0:3.10-1.el7 httpd.x86_64 0:2.4.6-40.el7.centos.4 httpd-tools.x86_64 0:2.4.6-40.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-36.3.el7_2 php-bcmath.x86_64 0:5.4.16-36.3.el7_2 php-cli.x86_64 0:5.4.16-36.3.el7_2 php-common.x86_64 0:5.4.16-36.3.el7_2 php-gd.x86_64 0:5.4.16-36.3.el7_2 php-ldap.x86_64 0:5.4.16-36.3.el7_2 php-mbstring.x86_64 0:5.4.16-36.3.el7_2 php-mysql.x86_64 0:5.4.16-36.3.el7_2 php-pdo.x86_64 0:5.4.16-36.3.el7_2 php-xml.x86_64 0:5.4.16-36.3.el7_2 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7 zabbix-web.noarch 0:3.2.0-1.el7 Complete! [root@zabbix-server software]#
确认是否自动安装了:
[root@zabbix-server software]# rpm -qa | grep php-bcmath php-bcmath-5.4.16-36.3.el7_2.x86_64 [root@zabbix-server software]# rpm -qa | grep php-mbstring php-mbstring-5.4.16-36.3.el7_2.x86_64 [root@zabbix-server software]#
如果没有,可以去下列网址获取:
http://vault.centos.org
二、 安装:Zabbix-agent(可选)
CMD:yum install -y zabbix-agent
[root@zabbix-server software]# yum install -y zabbix-agent Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package zabbix-agent.x86_64 0:3.2.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Installing: zabbix-agent x86_64 3.2.0-1.el7 zabbix 333 k Transaction Summary ================================================================================================================ Install 1 Package Total download size: 333 k Installed size: 1.1 M Downloading packages: zabbix-agent-3.2.0-1.el7.x86_64.rpm | 333 kB 00:00:10 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zabbix-agent-3.2.0-1.el7.x86_64 1/1 Verifying : zabbix-agent-3.2.0-1.el7.x86_64 1/1 Installed: zabbix-agent.x86_64 0:3.2.0-1.el7 Complete! [root@zabbix-server software]#
三、 安装:Percona MySQL
安装方式:YUM。
[root@zabbix-server software]# rpm -ivh http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm Retrieving http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm warning: /var/tmp/rpm-tmp.1oOk5U: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY Preparing... ################################# [100%] Updating / installing... 1:percona-release-0.1-3 ################################# [100%] [root@zabbix-server software]# [root@zabbix-server software]# yum repolist Loaded plugins: fastestmirror, langpacks percona-release-noarch | 2.4 kB 00:00:00 percona-release-x86_64 | 2.5 kB 00:00:01 (1/2): percona-release-noarch/7/primary_db | 14 kB 00:00:01 (2/2): percona-release-x86_64/7/x86_64/primary_db | 355 kB 00:00:20 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn repo id repo name status base/7/x86_64 CentOS-7 - Base 9,007 extras/7/x86_64 CentOS-7 - Extras 390 percona-release-noarch/7 Percona-Release YUM repository - noarch 24 percona-release-x86_64/7/x86_64 Percona-Release YUM repository - x86_64 666 updates/7/x86_64 CentOS-7 - Updates 2,471 zabbix/x86_64 Zabbix Official Repository - x86_64 14 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4 repolist: 12,576 [root@zabbix-server software]# [root@zabbix-server software]# yum list | grep --color Percona-Server-server | grep --color 57 Percona-Server-server-57.x86_64 5.7.14-8.1.el7 percona-release-x86_64 [root@zabbix-server software]# [root@zabbix-server software]# yum install -y Percona-Server-server-57 (... ...过多输出。)
安装方式:YUM + createrepo。
清理YUM源: [root@zabbix-server software]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo percona-release.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo zabbix.repo [root@zabbix-server software]# [root@zabbix-server software]# mkdir /backup [root@zabbix-server software]# [root@zabbix-server software]# mv /etc/yum.repos.d/percona-release.repo /backup/ [root@zabbix-server software]# [root@zabbix-server software]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo zabbix.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo [root@zabbix-server software]# 安装createrepo: [root@zabbix-server software]# yum list | grep --color createrepo createrepo.noarch 0.9.9-23.el7 @anaconda createrepo.noarch 0.9.9-25.el7_2 updates createrepo_c.x86_64 0.9.0-1.el7.centos extras createrepo_c-devel.x86_64 0.9.0-1.el7.centos extras createrepo_c-libs.x86_64 0.9.0-1.el7.centos extras python-createrepo_c.x86_64 0.9.0-1.el7.centos extras [root@zabbix-server software]# [root@zabbix-server software]# yum install -y createrepo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-23.el7 will be updated ---> Package createrepo.noarch 0:0.9.9-25.el7_2 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Updating: createrepo noarch 0.9.9-25.el7_2 updates 92 k Transaction Summary ================================================================================================================ Upgrade 1 Package Total download size: 92 k Downloading packages: Not downloading deltainfo for updates, MD is 752 k and rpms are 92 k createrepo-0.9.9-25.el7_2.noarch.rpm | 92 kB 00:00:09 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Updating : createrepo-0.9.9-25.el7_2.noarch 1/2 Cleanup : createrepo-0.9.9-23.el7.noarch 2/2 Verifying : createrepo-0.9.9-25.el7_2.noarch 1/2 Verifying : createrepo-0.9.9-23.el7.noarch 2/2 Updated: createrepo.noarch 0:0.9.9-25.el7_2 Complete! [root@zabbix-server software]# 上传Percona-Server的介质到服务器: [root@zabbix-server software]# ls -ltr total 169728 -rw-r--r-- 1 root root 13392 Sep 14 05:00 zabbix-release-3.2-1.el7.noarch.rpm -rw-r--r-- 1 root root 173783040 Sep 23 06:31 Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar [root@zabbix-server software]# [root@zabbix-server software]# mv zabbix-release-3.2-1.el7.noarch.rpm /backup/ [root@zabbix-server software]# [root@zabbix-server software]# tar -xf Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr total 339424 -rw-rw-r-- 1 root root 93765360 Sep 19 04:44 Percona-Server-57-debuginfo-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1100480 Sep 19 04:44 Percona-Server-devel-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 7613920 Sep 19 04:44 Percona-Server-client-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1300920 Sep 19 04:44 Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 763384 Sep 19 04:44 Percona-Server-shared-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 39492980 Sep 19 04:44 Percona-Server-server-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1589128 Sep 19 04:44 Percona-Server-tokudb-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 28147928 Sep 19 04:44 Percona-Server-test-57-5.7.14-8.1.el7.x86_64.rpm -rw-r--r-- 1 root root 173783040 Sep 23 06:31 Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar [root@zabbix-server software]# 生成repo: [root@zabbix-server software]# createrepo /software/ Spawning worker 0 with 4 pkgs Spawning worker 1 with 4 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr total 339428 -rw-rw-r-- 1 root root 93765360 Sep 19 04:44 Percona-Server-57-debuginfo-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1100480 Sep 19 04:44 Percona-Server-devel-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 7613920 Sep 19 04:44 Percona-Server-client-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1300920 Sep 19 04:44 Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 763384 Sep 19 04:44 Percona-Server-shared-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 39492980 Sep 19 04:44 Percona-Server-server-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1589128 Sep 19 04:44 Percona-Server-tokudb-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 28147928 Sep 19 04:44 Percona-Server-test-57-5.7.14-8.1.el7.x86_64.rpm -rw-r--r-- 1 root root 173783040 Sep 23 06:31 Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar drwxr-xr-x 2 root root 4096 Sep 23 06:32 repodata [root@zabbix-server software]# 写入YUM源: [root@zabbix-server software]# vi /etc/yum.repos.d/local.repo [root@zabbix-server software]# cat /etc/yum.repos.d/local.repo [Local-software] name=Local-software baseurl=file:///software gpgcheck=0 [root@zabbix-server software]# 刷新YUN源: [root@zabbix-server software]# yum repolist Loaded plugins: fastestmirror, langpacks Local-software | 2.9 kB 00:00:00 Local-software/primary_db | 12 kB 00:00:00 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn repo id repo name status Local-software Local-software 8 base/7/x86_64 CentOS-7 - Base 9,007 extras/7/x86_64 CentOS-7 - Extras 390 updates/7/x86_64 CentOS-7 - Updates 2,471 zabbix/x86_64 Zabbix Official Repository - x86_64 14 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4 repolist: 11,894 [root@zabbix-server software]# 执行安装: [root@zabbix-server software]# yum list | grep --color Local-software Percona-Server-57-debuginfo.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-client-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-devel-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-server-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-shared-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-shared-compat-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-test-57.x86_64 5.7.14-8.1.el7 Local-software Percona-Server-tokudb-57.x86_64 5.7.14-8.1.el7 Local-software [root@zabbix-server software]# [root@zabbix-server software]# yum install -y Percona-Server-server-57 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package Percona-Server-server-57.x86_64 0:5.7.14-8.1.el7 will be installed --> Processing Dependency: Percona-Server-shared-57 for package: Percona-Server-server-57-5.7.14-8.1.el7.x86_64 --> Processing Dependency: Percona-Server-client-57 for package: Percona-Server-server-57-5.7.14-8.1.el7.x86_64 --> Running transaction check ---> Package Percona-Server-client-57.x86_64 0:5.7.14-8.1.el7 will be installed ---> Package Percona-Server-shared-57.x86_64 0:5.7.14-8.1.el7 will be installed --> Processing Dependency: Percona-Server-shared-compat-57 for package: Percona-Server-shared-57-5.7.14-8.1.el7.x86_64 --> Running transaction check ---> Package Percona-Server-shared-compat-57.x86_64 0:5.7.14-8.1.el7 will be obsoleting ---> Package mariadb-libs.x86_64 1:5.5.41-2.el7_0 will be obsoleted --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Installing: Percona-Server-server-57 x86_64 5.7.14-8.1.el7 Local-software 38 M Percona-Server-shared-compat-57 x86_64 5.7.14-8.1.el7 Local-software 1.2 M replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0 Installing for dependencies: Percona-Server-client-57 x86_64 5.7.14-8.1.el7 Local-software 7.3 M Percona-Server-shared-57 x86_64 5.7.14-8.1.el7 Local-software 745 k Transaction Summary ================================================================================================================ Install 2 Packages (+2 Dependent packages) Total download size: 47 M Downloading packages: ---------------------------------------------------------------------------------------------------------------- Total 187 MB/s | 47 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64 1/5 Installing : Percona-Server-shared-57-5.7.14-8.1.el7.x86_64 2/5 Installing : Percona-Server-client-57-5.7.14-8.1.el7.x86_64 3/5 Installing : Percona-Server-server-57-5.7.14-8.1.el7.x86_64 4/5 Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit. Run the following commands to create these functions: mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'" mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'" mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'" See http://www.percona.com/doc/percona-server/5.7/management/udf_percona_toolkit.html for more details Erasing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 5/5 Verifying : Percona-Server-shared-57-5.7.14-8.1.el7.x86_64 1/5 Verifying : Percona-Server-server-57-5.7.14-8.1.el7.x86_64 2/5 Verifying : Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64 3/5 Verifying : Percona-Server-client-57-5.7.14-8.1.el7.x86_64 4/5 Verifying : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 5/5 Installed: Percona-Server-server-57.x86_64 0:5.7.14-8.1.el7 Percona-Server-shared-compat-57.x86_64 0:5.7.14-8.1.el7 Dependency Installed: Percona-Server-client-57.x86_64 0:5.7.14-8.1.el7 Percona-Server-shared-57.x86_64 0:5.7.14-8.1.el7 Replaced: mariadb-libs.x86_64 1:5.5.41-2.el7_0 Complete! [root@zabbix-server software]#
安装后检查:
[root@zabbix-server software]# rpm -qa | grep --color Percona Percona-Server-shared-57-5.7.14-8.1.el7.x86_64 Percona-Server-server-57-5.7.14-8.1.el7.x86_64 Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64 Percona-Server-client-57-5.7.14-8.1.el7.x86_64 [root@zabbix-server software]# [root@zabbix-server software]# cat /etc/my.cnf | grep -v '#' | strings [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@zabbix-server software]#
可以看到:
1. MySQL数据目录:/var/lib?mysql
2. MySQL日志文件:/var/log/mysqld.log
启动服务:
[root@zabbix-server software]# ps -ef | grep --color mysql root 12487 5199 0 06:36 pts/0 00:00:00 grep --color=auto --color mysql [root@zabbix-server software]# [root@zabbix-server software]# netstat -tupln | grep --color mysql [root@zabbix-server software]# [root@zabbix-server software]# systemctl status mysqld mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled) Active: inactive (dead) [root@zabbix-server software]# [root@zabbix-server software]# systemctl start mysqld [root@zabbix-server software]# [root@zabbix-server software]# ps -ef | grep --color mysql mysql 12551 1 15 06:37 ? 00:00:01 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid root 12581 5199 0 06:37 pts/0 00:00:00 grep --color=auto --color mysql [root@zabbix-server software]# [root@zabbix-server software]# netstat -tupln | grep --color mysql tcp6 0 0 :::3306 :::* LISTEN 12551/mysqld [root@zabbix-server software]# [root@zabbix-server software]# systemctl status mysqld mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled) Active: active (running) since Fri 2016-09-23 06:37:26 PDT; 22s ago Process: 12548 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 12493 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 12551 (mysqld) CGroup: /system.slice/mysqld.service └─12551 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Sep 23 06:37:17 zabbix-server systemd[1]: Starting MySQL Server... Sep 23 06:37:26 zabbix-server systemd[1]: Started MySQL Server. [root@zabbix-server software]#
【MySQL】服务已经启动。
与【MySQL】有关的目录与文件的状态:
[root@zabbix-server software]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" /var/lib/mysql total 126792 -rw-r----- 1 mysql mysql 50331648 |2016-09-23|06:37:20| ib_logfile1 -rw-r----- 1 mysql mysql 56 |2016-09-23|06:37:22| auto.cnf -rw------- 1 mysql mysql 1680 |2016-09-23|06:37:22| ca-key.pem -rw-r--r-- 1 mysql mysql 1079 |2016-09-23|06:37:22| ca.pem -rw------- 1 mysql mysql 1680 |2016-09-23|06:37:22| server-key.pem -rw-r--r-- 1 mysql mysql 1087 |2016-09-23|06:37:22| server-cert.pem -rw------- 1 mysql mysql 1676 |2016-09-23|06:37:22| client-key.pem -rw-r--r-- 1 mysql mysql 1087 |2016-09-23|06:37:22| client-cert.pem -rw-r--r-- 1 mysql mysql 452 |2016-09-23|06:37:22| public_key.pem -rw------- 1 mysql mysql 1676 |2016-09-23|06:37:22| private_key.pem drwxr-x--- 2 mysql mysql 8192 |2016-09-23|06:37:23| performance_schema drwxr-x--- 2 mysql mysql 4096 |2016-09-23|06:37:23| mysql drwxr-x--- 2 mysql mysql 8192 |2016-09-23|06:37:23| sys -rw-r----- 1 mysql mysql 408 |2016-09-23|06:37:24| ib_buffer_pool -rw------- 1 mysql mysql 6 |2016-09-23|06:37:26| mysql.sock.lock srwxrwxrwx 1 mysql mysql 0 |2016-09-23|06:37:26| mysql.sock -rw-r----- 1 mysql mysql 3932160 |2016-09-23|06:37:28| xb_doublewrite -rw-r----- 1 mysql mysql 12582912 |2016-09-23|06:37:28| ibtmp1 -rw-r----- 1 mysql mysql 12582912 |2016-09-23|06:37:28| ibdata1 -rw-r----- 1 mysql mysql 50331648 |2016-09-23|06:37:28| ib_logfile0 [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" /var/log/ | grep --color mysql -rw-r----- 1 mysql mysql 4530 |2016-09-23|06:37:26| mysqld.log [root@zabbix-server software]#
登陆MySQL:
[root@zabbix-server software]# cat /var/log/mysqld.log | grep --color "A temporary password is generated" 2016-09-23T13:37:22.755557Z 1 [Note] A temporary password is generated for root@localhost: RNPdu,f0&P/q [root@zabbix-server software]# [root@zabbix-server software]# mysql -uroot -p'RNPdu,f0&P/q' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.14-8 Copyright (c) 2009-2016 Percona LLC and/or its affiliates Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> mysql> select user(); ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> mysql> alter user root@localhost identified by 'Abcd!234'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye [root@zabbix-server software]# [root@zabbix-server software]# mysql -uroot -p'Abcd!234' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.14-8 Percona Server (GPL), Release 8, Revision 1f84ccd Copyright (c) 2009-2016 Percona LLC and/or its affiliates Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
创建Zabbix数据库:
mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | zabbix | +--------------------+ 5 rows in set (0.00 sec) mysql> select user,host from mysql.user; +-----------+-----------+ | user | host | +-----------+-----------+ | mysql.sys | localhost | | root | localhost | +-----------+-----------+ 2 rows in set (0.00 sec) mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'Abcd!234'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> select user,host from mysql.user; +-----------+-----------+ | user | host | +-----------+-----------+ | mysql.sys | localhost | | root | localhost | | zabbix | localhost | +-----------+-----------+ 3 rows in set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye [root@zabbix-server software]#
初始化Zabbix库:
[root@zabbix-server software]# cd /usr/share/doc/zabbix-server-mysql-3.2.0/ [root@zabbix-server zabbix-server-mysql-3.2.0]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" total 1860 -rw-r--r-- 1 root root 98 |2016-09-13|05:20:55| AUTHORS -rw-r--r-- 1 root root 706351 |2016-09-13|05:20:56| ChangeLog -rw-r--r-- 1 root root 188 |2016-09-13|05:21:04| README -rw-r--r-- 1 root root 17990 |2016-09-13|05:21:18| COPYING -rw-r--r-- 1 root root 52 |2016-09-13|05:21:22| NEWS -rw-r--r-- 1 root root 1161201 |2016-09-13|09:43:09| create.sql.gz [root@zabbix-server zabbix-server-mysql-3.2.0]# [root@zabbix-server zabbix-server-mysql-3.2.0]# zcat create.sql.gz | mysql -uroot -p'Abcd!234' zabbix mysql: [Warning] Using a password on the command line interface can be insecure. [root@zabbix-server zabbix-server-mysql-3.2.0]#
四、配置并启动【zabbix-server】服务
配置Zabbix配置文件:
[root@zabbix-server ~]# cat /etc/zabbix/zabbix_server.conf | grep -v '#' | strings LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=Abcd!234 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000 [root@zabbix-server ~]#
启动服务【zabbix-server】:
1. 检查trousers软件包的状态,并升级为【0.3.13-1.el7】:
[root@zabbix-server ~]# rpm -qa | grep --color trousers trousers-0.3.11.2-3.el7.x86_64 [root@zabbix-server ~]# [root@zabbix-server ~]# yum list | grep --color trousers trousers.x86_64 0.3.11.2-3.el7 @anaconda trousers.i686 0.3.13-1.el7 base trousers.x86_64 0.3.13-1.el7 base trousers-devel.i686 0.3.13-1.el7 base trousers-devel.x86_64 0.3.13-1.el7 base trousers-static.i686 0.3.13-1.el7 base trousers-static.x86_64 0.3.13-1.el7 base [root@zabbix-server ~]# [root@zabbix-server ~]# yum update trousers Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package trousers.x86_64 0:0.3.11.2-3.el7 will be updated ---> Package trousers.x86_64 0:0.3.13-1.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Updating: trousers x86_64 0.3.13-1.el7 base 289 k Transaction Summary ================================================================================================================ Upgrade 1 Package Total download size: 289 k Is this ok [y/d/N]: y Downloading packages: No Presto metadata available for base trousers-0.3.13-1.el7.x86_64.rpm | 289 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : trousers-0.3.13-1.el7.x86_64 1/2 Cleanup : trousers-0.3.11.2-3.el7.x86_64 2/2 Verifying : trousers-0.3.13-1.el7.x86_64 1/2 Verifying : trousers-0.3.11.2-3.el7.x86_64 2/2 Updated: trousers.x86_64 0:0.3.13-1.el7 Complete! [root@zabbix-server ~]# [root@zabbix-server ~]# rpm -qa | grep --color trousers trousers-0.3.13-1.el7.x86_64 [root@zabbix-server ~]#
2. 启动服务:zabbix-server
[root@zabbix-server ~]# ps -ef | grep --color zabbix root 12874 5199 0 06:53 pts/0 00:00:00 grep --color=auto --color zabbix [root@zabbix-server ~]# [root@zabbix-server ~]# netstat -tupln | grep --color zabbix [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl status zabbix-server zabbix-server.service - Zabbix Server Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled) Active: inactive (dead) [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl start zabbix-server [root@zabbix-server ~]# [root@zabbix-server ~]# netstat -tupln | grep --color zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 12890/zabbix_server tcp6 0 0 :::10051 :::* LISTEN 12890/zabbix_server [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl status zabbix-server zabbix-server.service - Zabbix Server Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled) Active: active (running) since Fri 2016-09-23 06:54:09 PDT; 9s ago Process: 12888 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 12890 (zabbix_server) CGroup: /system.slice/zabbix-server.service ├─12890 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf ├─12892 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] ├─12893 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.001257 sec, idle 60 sec] ├─12894 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000006 sec, idle 5 sec] ├─12895 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000002 sec, idle 5 sec] ├─12896 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000004 sec, idle 5 sec] ├─12897 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000004 sec, idle 5 sec] ├─12898 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000004 sec, idle 5 sec] ├─12899 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000075 sec, idle 5 sec] ├─12900 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connectio... ├─12901 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connectio... ├─12902 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connectio... ├─12903 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connectio... ├─12904 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connectio... ├─12905 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000005 sec, idle 5 sec] ├─12906 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.003516 sec, idle 30 ... ├─12907 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] ├─12908 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maint... ├─12909 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001236 sec, idle 5 sec] ├─12910 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000454 sec, idle 60 sec] ├─12911 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec] ├─12912 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec] ├─12913 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 1 sec] ├─12914 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec] ├─12915 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000612 sec, idle 3 sec... ├─12916 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000003 sec, i... ├─12917 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000002 sec, idle 1 sec] └─12918 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000242 sec, idle 5 sec] Sep 23 06:54:09 zabbix-server systemd[1]: Starting Zabbix Server... Sep 23 06:54:09 zabbix-server systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) afte...art. Sep 23 06:54:09 zabbix-server systemd[1]: Started Zabbix Server. Hint: Some lines were ellipsized, use -l to show in full. [root@zabbix-server ~]#
开机启动:
[root@zabbix-server ~]# chkconfig zabbix-server on Note: Forwarding request to 'systemctl enable zabbix-server.service'. ln -s '/usr/lib/systemd/system/zabbix-server.service' '/etc/systemd/system/multi-user.target.wants/zabbix-server.service' [root@zabbix-server ~]#
五、配置:zabbix-server 的 HTTPD 虚拟主机
配置文件:/etc/httpd/conf.d/zabbix.conf
[root@zabbix-server ~]# vi /etc/httpd/conf.d/zabbix.conf [root@zabbix-server ~]# [root@zabbix-server ~]# cat /etc/httpd/conf.d/zabbix.conf # # Zabbix monitoring system php web frontend # Alias /zabbix /usr/share/zabbix Options FollowSymLinks AllowOverride None Require all granted php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 # php_value date.timezone Europe/Riga php_value date.timezone Asia/Shanghai Require all denied Require all denied Require all denied Require all denied [root@zabbix-server ~]#
启动【httpd】服务:
[root@zabbix-server ~]# netstat -tupln | grep http [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: inactive (dead) Docs: man:httpd(8) man:apachectl(8) [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl start httpd [root@zabbix-server ~]# [root@zabbix-server ~]# netstat -tupln | grep http tcp6 0 0 :::80 :::* LISTEN 13060/httpd [root@zabbix-server ~]# [root@zabbix-server ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: active (running) since Fri 2016-09-23 06:59:19 PDT; 7s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 13060 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service ├─13060 /usr/sbin/httpd -DFOREGROUND ├─13061 /usr/sbin/httpd -DFOREGROUND ├─13062 /usr/sbin/httpd -DFOREGROUND ├─13063 /usr/sbin/httpd -DFOREGROUND ├─13064 /usr/sbin/httpd -DFOREGROUND └─13065 /usr/sbin/httpd -DFOREGROUND Sep 23 06:59:19 zabbix-server systemd[1]: Starting The Apache HTTP Server... Sep 23 06:59:19 zabbix-server httpd[13060]: AH00558: httpd: Could not reliably determine the server's ful...sage Sep 23 06:59:19 zabbix-server systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@zabbix-server ~]#
设置开机启动:
[root@zabbix-server ~]# chkconfig httpd on Note: Forwarding request to 'systemctl enable httpd.service'. ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service' [root@zabbix-server ~]#
六、Zabbix:WEB界面配置
本地网址:
http://IP/zabbix
在我的环境中:
http://192.168.111.128/zabbix
1. 安装:
2. 登陆与使用:
默认口令:
User:Admin(一定要首字母大写)
Password:zabbix
登陆后:
3. 界面汉化:
首先确认中文是否可以选择:
[root@zabbix-server ~]# cat /usr/share/zabbix/include/locales.inc.php | grep --color "zh_CN" 'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true], [root@zabbix-server ~]#
确认【display】为:true,即可。
然后,WEB界面操作:
4. 中文乱码的问题:
本地MS Windows中,找到微软雅黑的字符(fonts),并上传Zabbix服务器:
然后做出配置:
[root@zabbix-server yum.repos.d]# cd /software [root@zabbix-server software]# ls Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar Percona-Server-57-debuginfo-5.7.14-8.1.el7.x86_64.rpm Percona-Server-client-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-devel-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-server-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-shared-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-test-57-5.7.14-8.1.el7.x86_64.rpm Percona-Server-tokudb-57-5.7.14-8.1.el7.x86_64.rpm repodata [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr total 362484 -rw-rw-r-- 1 root root 93765360 Sep 19 04:44 Percona-Server-57-debuginfo-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1100480 Sep 19 04:44 Percona-Server-devel-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 7613920 Sep 19 04:44 Percona-Server-client-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1300920 Sep 19 04:44 Percona-Server-shared-compat-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 763384 Sep 19 04:44 Percona-Server-shared-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 39492980 Sep 19 04:44 Percona-Server-server-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 1589128 Sep 19 04:44 Percona-Server-tokudb-57-5.7.14-8.1.el7.x86_64.rpm -rw-rw-r-- 1 root root 28147928 Sep 19 04:44 Percona-Server-test-57-5.7.14-8.1.el7.x86_64.rpm -rw-r--r-- 1 root root 173783040 Sep 23 06:31 Percona-Server-5.7.14-8-r1f84ccd-el7-x86_64-bundle.tar drwxr-xr-x 2 root root 4096 Sep 23 06:32 repodata -rw-r--r-- 1 root root 23606748 Sep 23 08:50 msyh.ttc [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr /usr/share/zabbix/fonts total 0 lrwxrwxrwx 1 root root 33 Sep 23 06:19 graphfont.ttf -> /etc/alternatives/zabbix-web-font [root@zabbix-server software]# [root@zabbix-server software]# cp msyh.ttc /usr/share/zabbix/fonts [root@zabbix-server software]# [root@zabbix-server software]# ls -ltr /usr/share/zabbix/fonts total 23056 lrwxrwxrwx 1 root root 33 Sep 23 06:19 graphfont.ttf -> /etc/alternatives/zabbix-web-font -rw-r--r-- 1 root root 23606748 Sep 23 08:50 msyh.ttc [root@zabbix-server software]# [root@zabbix-server software]# vi /usr/share/zabbix/include/defines.inc.php [root@zabbix-server software]# [root@zabbix-server software]# cat /usr/share/zabbix/include/defines.inc.php | grep --color "FONT_NAME" // define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name define('ZBX_FONT_NAME', 'graphfont'); // define('ZBX_FONT_NAME', 'msyh'); [root@zabbix-server software]#
————————————
至此,关于Zabbix的安装,就基本结束了。
七、让Zabbix监控一台服务器:
安装并配置:zabbix-agent
[root@zabbix-client ~]# yum install -y zabbix-get zabbix-agent Loaded plugins: fastestmirror, langpacks zabbix | 951 B 00:00:00 zabbix-non-supported | 951 B 00:00:00 Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: mirrors.cn99.com * updates: mirrors.cn99.com Resolving Dependencies --> Running transaction check ---> Package zabbix-agent.x86_64 0:3.2.0-1.el7 will be installed ---> Package zabbix-get.x86_64 0:3.2.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Installing: zabbix-agent x86_64 3.2.0-1.el7 zabbix 333 k zabbix-get x86_64 3.2.0-1.el7 zabbix 232 k Transaction Summary ================================================================================================================ Install 2 Packages Total size: 565 k Installed size: 1.9 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zabbix-agent-3.2.0-1.el7.x86_64 1/2 Installing : zabbix-get-3.2.0-1.el7.x86_64 2/2 Verifying : zabbix-get-3.2.0-1.el7.x86_64 1/2 Verifying : zabbix-agent-3.2.0-1.el7.x86_64 2/2 Installed: zabbix-agent.x86_64 0:3.2.0-1.el7 zabbix-get.x86_64 0:3.2.0-1.el7 Complete! [root@zabbix-client ~]# [root@zabbix-client ~]# cat /etc/zabbix/zabbix_agentd.conf | grep -v '#' | strings PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=192.168.111.128 ServerActive=192.168.111.128:10051 Hostname=zabbix-client Include=/etc/zabbix/zabbix_agentd.d/*.conf [root@zabbix-client ~]#
启动【zabbix-agent】服务:
[root@zabbix-client ~]# netstat -tupln | grep zabbix [root@zabbix-client ~]# [root@zabbix-client ~]# systemctl start zabbix-agent [root@zabbix-client ~]# [root@zabbix-client ~]# netstat -tupln | grep zabbix tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 12599/zabbix_agentd tcp6 0 0 :::10050 :::* LISTEN 12599/zabbix_agentd [root@zabbix-client ~]# [root@zabbix-client ~]# systemctl status zabbix-agent zabbix-agent.service - Zabbix Agent Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled) Active: active (running) since Fri 2016-09-23 08:36:42 PDT; 1min 23s ago Process: 12591 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS) Process: 12597 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 12599 (zabbix_agentd) CGroup: /system.slice/zabbix-agent.service ├─12599 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf ├─12600 /usr/sbin/zabbix_agentd: collector [idle 1 sec] ├─12601 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] ├─12602 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] ├─12603 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] └─12604 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] Sep 23 08:36:41 zabbix-client systemd[1]: Starting Zabbix Agent... Sep 23 08:36:42 zabbix-client systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) afte...art. Sep 23 08:36:42 zabbix-client systemd[1]: Started Zabbix Agent. Hint: Some lines were ellipsized, use -l to show in full. [root@zabbix-client ~]#
这样,Zabbix客户端的Agent就安装好了。
Zabbix服务器端安装:zabbix-get
[root@zabbix-server ~]# yum list | grep zabbix-get zabbix-get.x86_64 3.2.0-1.el7 zabbix [root@zabbix-server ~]# [root@zabbix-server ~]# yum install -y zabbix-get Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Resolving Dependencies --> Running transaction check ---> Package zabbix-get.x86_64 0:3.2.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Installing: zabbix-get x86_64 3.2.0-1.el7 zabbix 232 k Transaction Summary ================================================================================================================ Install 1 Package Total download size: 232 k Installed size: 857 k Downloading packages: zabbix-get-3.2.0-1.el7.x86_64.rpm | 232 kB 00:00:03 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zabbix-get-3.2.0-1.el7.x86_64 1/1 Verifying : zabbix-get-3.2.0-1.el7.x86_64 1/1 Installed: zabbix-get.x86_64 0:3.2.0-1.el7 Complete! [root@zabbix-server ~]#
Zabbix服务端获取客户端的信息:
[root@zabbix-server yum.repos.d]# zabbix_get -s 192.168.111.129 -p 10050 -k "system.uname" Linux zabbix-client 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 [root@zabbix-server yum.repos.d]# [root@zabbix-server yum.repos.d]# zabbix_get -s 192.168.111.129 -p 10050 -k "system.uptime" 1134 [root@zabbix-server yum.repos.d]#
可以看到,从服务端到客户端的通讯正常。
【WEB操作】服务端,添加对客户端的监控:
至此,客户端添加完成。
————————————
Done。