zabbix使用Percona数据库tokudb引擎
1.安装TokuDB数据库
[root@zabbix-tokudb ~]# yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
[root@zabbix-tokudb ~]# yum install Percona-Server-tokudb-57.x86_64
...省略多行...
Dependencies Resolved
=========================================================================================================================
Package Arch Version Repository
=========================================================================================================================
Installing:
Percona-Server-shared-compat-57 x86_64 5.7.30-33.1.el7 percona-rel
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
Percona-Server-tokudb-57 x86_64 5.7.30-33.1.el7 percona-rel
Installing for dependencies:
Percona-Server-client-57 x86_64 5.7.30-33.1.el7 percona-rel
Percona-Server-server-57 x86_64 5.7.30-33.1.el7 percona-rel
Percona-Server-shared-57 x86_64 5.7.30-33.1.el7 percona-rel
jemalloc x86_64 3.6.0-1.el7 epel
libaio x86_64 0.3.109-13.el7 base
Transaction Summary
=========================================================================================================================
Install 2 Packages (+5 Dependent packages)
#在线下载安装,因为国外源问题,下载非常缓慢,所以使用离线安装。
[root@zabbix-tokudb ~]# wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.30-33/binary/redhat/7/x86_64/Percona-Server-5.7.30-33-r6517692-el7-x86_64-bundle.tar
[root@zabbix-tokudb ~]# yum remove -y mariadb*
[root@zabbix-tokudb ~]# yum install jemalloc -y
[root@zabbix-tokudb ~]# tar xf Percona-Server-5.7.30-33-r6517692-el7-x86_64-bundle.tar
[root@zabbix-tokudb ~]# mkdir yum
[root@zabbix-tokudb ~]# mv Percona-Server-tokudb-57-5.7.30-33.1.el7.x86_64.rpm Percona-Server-shared-compat-57-5.7.30-33.1.el7.x86_64.rpm Percona-Server-shared-57-5.7.30-33.1.el7.x86_64.rpm Percona-Server-server-57-5.7.30-33.1.el7.x86_64.rpm Percona-Server-client-57-5.7.30-33.1.el7.x86_64.rpm yum/
[root@zabbix-tokudb ~]# cd yum
[root@zabbix-tokudb ~/yum]# ll
-rw-rw-r-- 1 root root 7529704 May 14 06:04 Percona-Server-client-57-5.7.30-33.1.el7.x86_64.rpm
-rw-rw-r-- 1 root root 41034904 May 14 06:04 Percona-Server-server-57-5.7.30-33.1.el7.x86_64.rpm
-rw-rw-r-- 1 root root 761328 May 14 06:04 Percona-Server-shared-57-5.7.30-33.1.el7.x86_64.rpm
-rw-rw-r-- 1 root root 1295212 May 14 06:04 Percona-Server-shared-compat-57-5.7.30-33.1.el7.x86_64.rpm
-rw-rw-r-- 1 root root 1787540 May 14 06:04 Percona-Server-tokudb-57-5.7.30-33.1.el7.x86_64.rpm
[root@zabbix-tokudb ~/yum]# yum localinstall -y Percona-Server-*
...省略多行...
* This release of Percona Server is distributed with TokuDB storage engine.
* Run the following script to enable the TokuDB storage engine in Percona Server:
ps-admin --enable-tokudb -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]
...省略多行...
Complete!
[root@zabbix-tokudb ~/yum]# systemctl start mysqld
[root@zabbix-tokudb ~/yum]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6558/sshd
tcp6 0 0 :::3306 :::* LISTEN 21846/mysqld
tcp6 0 0 :::22 :::* LISTEN 6558/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 6493/dhclient
udp 0 0 127.0.0.1:323 0.0.0.0:* 5111/chronyd
udp6 0 0 ::1:323 :::* 5111/chronyd
[root@zabbix-tokudb ~/yum]# grep 'password' /var/log/mysqld.log
2020-07-20T13:34:53.998007Z 1 [Note] A temporary password is generated for root@localhost: lvauI)4!5>Uz
[root@zabbix-tokudb ~/yum]# mysql -uroot -p'lvauI)4!5>Uz'
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.30-33
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user root@'localhost' identified by 'lvauI)4!5>Ua';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
[root@zabbix-tokudb ~/yum]# ps_tokudb_admin --enable -uroot -p'lvauI)4!5>Ua'
WARNING: This script is deprecated and will be removed in 8.0. You can use ps-admin script which has more functionality.
Checking location of jemalloc library ...
INFO: Using jemalloc library from /usr/lib64/libjemalloc.so.1
Checking transparent huge pages status on the system...
INFO: Transparent huge pages are currently disabled on the system.
Checking if THP_SETTING variable is set to never or madvise in /etc/sysconfig/mysql...
INFO: Variable THP_SETTING is not set to never or madvise in /etc/sysconfig/mysql.
Checking if LD_PRELOAD variable is set for libjemalloc.so.1 in /etc/sysconfig/mysql...
INFO: Variable LD_PRELOAD for libjemalloc.so.1 is not set in /etc/sysconfig/mysql.
Checking TokuDB engine plugin status...
INFO: TokuDB engine plugin is not installed.
Adding LD_PRELOAD variable into /etc/sysconfig/mysql
INFO: Successfully added LD_PRELOAD variable for libjemalloc.so.1 into /etc/sysconfig/mysql
PLEASE RESTART MYSQL SERVICE AND RUN THIS SCRIPT AGAIN TO FINISH INSTALLATION!
[root@zabbix-tokudb ~/yum]# systemctl restart mysqld
[root@zabbix-tokudb ~/yum]# ps_tokudb_admin --enable -uroot -p'lvauI)4!5>Ua'
WARNING: This script is deprecated and will be removed in 8.0. You can use ps-admin script which has more functionality.
Checking location of jemalloc library ...
INFO: Using jemalloc library from /usr/lib64/libjemalloc.so.1
Checking transparent huge pages status on the system...
INFO: Transparent huge pages are currently disabled on the system.
Checking if THP_SETTING variable is set to never or madvise in /etc/sysconfig/mysql...
INFO: Variable THP_SETTING is not set to never or madvise in /etc/sysconfig/mysql.
Checking if LD_PRELOAD variable is set for libjemalloc.so.1 in /etc/sysconfig/mysql...
INFO: Variable LD_PRELOAD for libjemalloc.so.1 is set in /etc/sysconfig/mysql.
Checking TokuDB engine plugin status...
INFO: TokuDB engine plugin is not installed.
Adding THP_SETTING=never variable into /etc/sysconfig/mysql
INFO: Successfully added THP_SETTING=never option into /etc/sysconfig/mysql
Installing TokuDB engine...
INFO: Successfully installed TokuDB engine plugin.
########注意,这里补充下,需要关闭THP。########
[root@zabbix-tokudb ~/yum]# vim /etc/rc.local
#最后面添加如下代码,永久生效
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
#source下,使当前生效
[root@zabbix-tokudb ~/yum]# source /etc/rc.local
[root@zabbix-tokudb ~/yum]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@zabbix-tokudb ~/yum]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
################################################
[root@zabbix-tokudb ~/yum]# mysql -uroot -p'lvauI)4!5>Ua'
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)
mysql> SHOW PLUGINS;
+-------------------------------+----------+--------------------+----------------------+---------+
| Name | Status | Type | Library | License |
+-------------------------------+----------+--------------------+----------------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL |
...省略多行...
| TokuDB | ACTIVE | STORAGE ENGINE | ha_tokudb.so | GPL |
| TokuDB_file_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_info | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_block_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_trx | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_locks | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_lock_waits | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_background_job_status | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
+-------------------------------+----------+--------------------+----------------------+---------+
61 rows in set (0.00 sec)
2.安装Zabbix4.0
[root@zabbix-tokudb ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.J1zGBb: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.0-2.el7 ################################# [100%]
[root@zabbix-tokudb ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.rep o
[root@zabbix-tokudb ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
[root@zabbix-tokudb ~]# mysql -uroot -p'lvauI)4!5>Ua'
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> create user zabbix@localhost identified by 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> create user zabbix@localhost identified by 'Zabbix_pass123';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
[root@zabbix-tokudb ~]# rpm -ql zabbix-server-mysql
......
/usr/share/doc/zabbix-server-mysql-4.0.22/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
[root@zabbix-tokudb ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.22/
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# gunzip create.sql.gz
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# ll
-rw-r--r-- 1 root root 6284141 Jun 29 16:26 create.sql
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# grep 'InnoDB' create.sql
) ENGINE=InnoDB;
......
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# sed -i 's#ENGINE=InnoDB#ENGINE=tokudb#g' create.sql
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# cat create.sql |mysql -uzabbix -p'Zabbix_pass123' zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-tokudb /usr/share/doc/zabbix-server-mysql-4.0.22]# cd
[root@zabbix-tokudb ~]# vim /etc/zabbix/zabbix_server.conf
[root@zabbix-tokudb ~]# grep 'DBPassword=' /etc/zabbix/zabbix_server.conf
# DBPassword=
DBPassword=Zabbix_pass123
[root@zabbix-tokudb ~]# vim /etc/httpd/conf.d/zabbix.conf
[root@zabbix-tokudb ~]# grep 'date.timezone' /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
[root@zabbix-tokudb ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@zabbix-tokudb ~]# systemctl enable zabbix-server zabbix-agent httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix-tokudb ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6558/sshd
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 22367/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 22374/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 21963/mysqld
tcp6 0 0 :::80 :::* LISTEN 22365/httpd
tcp6 0 0 :::22 :::* LISTEN 6558/sshd
tcp6 0 0 :::10050 :::* LISTEN 22367/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 22374/zabbix_server
[root@zabbix-tokudb ~]# ip a
......
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:6c:ef:70 brd ff:ff:ff:ff:ff:ff
inet 192.168.199.106/24 brd 192.168.199.255 scope global dynamic eth0
使用http://192.168.199.106/zabbix 配置web,数据库密码填写 Zabbix_pass123
mysql> select @@datadir;
+-----------------+
| @@datadir |
+-----------------+
| /var/lib/mysql/ |
+-----------------+