澳门金莎娱乐网站:MySQL_第三方数据库引擎_tok

作者: 数据库信息  发布:2019-09-14

    前阵子迁移zabbix到tokudb,整理部分操作笔记到那篇博文。澳门金莎娱乐网站 1

 



 

    借使转发,请注解博文来源: www.cnblogs.com/xinysu/   ,版权归 乐乎 苏家小萝卜 全数。望各位扶助!

 



 1 tokudb引擎介绍

  1. 特点:高压缩,可帮衬多少个集中索引,帮忙ACID、MVCC,使用 Fractal Tree 索引
  2. 优点:
    • fractal tree 能够再掌握下,对轻便IO有那二个大的改进成效
      • fractal tree 能够急忙插入及删除,在从心所欲IO方面包车型大巴习性比 B-tree的习性更优
    • 高压缩,官方网站给出最大25倍
      • 对数码及索引举办压缩,依照数量的可压缩性,官方网站给出的最大滑坡比是 25 倍
    • 在线索引成立,成立时期,insert delete的DML帮忙,update呢 ?
    • 在线列扩充删除重命名,修改期间,insert delete的DML协理,update呢 ?
    • 在线备份
    • 七个聚集索引
    • 无io读复制
      • TokuDB slave能够布署,让来自master修改能够最小化。通过记录fractal tree索引:
      • Insert/update/delete操作能够调节撤销read-modify-write的一坐一起,然后注入新闻到合适的fractal tree。
      • Update/delete操作能够配备撤除必要io的一致性检查。
      • 为了选择应用无io读复制,服必得要配置:
      • 在replication master:
      • 设置为binlog行模式:BINLOG_FORMAT=ROW
      • 在replication slave:
      • Slave必需为只读:read_only=1
      • 撤消一致性检查:tokudb_rpl_unique_checks=0
      • 闭馆查找(read-modify-write) :tokudb_rpl_lookup_rows=0
      • 能够在三个也许多少个slave上配备。只要master使用了依据行的复制,优化在tokudb slave就可用。也等于说若是master使用innodb只怕myisam表也是可用的。
    • 无损化,少碎片
      • 4Mb为单位实行仓库储存
    • 敏捷回涨
      • 平复时间长度少于1min

2 Tokudb安装

2.1 percona mysql安装

1 下载最新percona mysql二进制包

2 解压

tar zvxf Percona-Server-5.7.17-13-Linux.x86_64.ssl101.tar.gz

3 软连接

ln -s /opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101 /usr/local/pmysql

4 建立用户及用户组

groupadd mysql

useradd -g mysql -s /sbin/nologin -d /usr/local/mysql/ -M mysql

5 建立文件夹

mkdir -p /data/mysql/pmysql3330/{data,tmp,logs}

6 数据库配置文件

pmysql3330.cnf

7 授权
[root@sutest242 percona]# chown -R mysql:mysql /usr/local/pmysql/
[root@sutest242 percona]# chown -R mysql:mysql /opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101
[root@sutest242 percona]# chown -R mysql:mysql /data/mysql/pmysql3330/

8 看是否需要配置环境变量

vim /etc/profile

PATH=$PATH:/usr/local/pmysql/bin

source profile

9 初始化实例

/usr/local/pmysql/bin/mysqld --defaults-file=/data/mysql/pmysql3330.cnf --initialize

10 检查是否安装有问题

vim /data/mysql/pmysql3330/data/error.log

11 启动数据库实例

/usr/local/pmysql/bin/mysqld --defaults-file=/data/mysql/pmysql3330.cnf &

12 修改密码

cat /data/mysql/pmysql3330/data/error.log | grep password

/usr/local/pmysql/bin/mysql --socket=/tmp/pmysql3330.sock -uroot -p

alter user root@localhost idnetified by '******';

flush privileges;

2.2 安装 jemalloc,处理内部存款和储蓄器

 找个流行版本安装就足以了

 

wget 

tar xjf jemalloc-4.2.1.tar.bz2

cd jemalloc-4.2.1

./configure

make && make install

echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf

 

解压进度中一经报错如下,请安装 bzip2 包 :yum install -y bzip2

 

[root@sutest242 percona]# tar -xjf jemalloc-4.2.1.tar.bz2

tar (child): bzip2: Cannot exec: No such file or directory

tar (child): Error is not recoverable: exiting now

tar: Child returned status 2

tar: Error is not recoverable: exiting now

 

 

安装成功后,在数据库配置文件中的mysqld_safe模块,增加援引libjemalloc.so,记得供给先找下那几个文件的实际上位置,然后cp或许ls一份到/usr/lib64目录下。

在数据库配置文件中增添援用

 

[mysqld_safe]

malloc-lib=/usr/lib64/libjemalloc.so.1

 

 

稳重,数据库关闭后,需求用mysqld_safe运维服务,使用 jemalloc 管理内存。

 

[root@sutest242 jemalloc-5.0.0]# /usr/local/pmysql/bin/mysqladmin --socket=/tmp/pmysql3330.sock -uroot -p shutdown

Enter password:

[root@sutest242 jemalloc-5.0.0]# ps axu | grep pmysql

root     12418  0.0  0.0 112648   964 pts/1    S    10:29   0:00 grep --color=auto pmysql

[root@sutest242 jemalloc-5.0.0]# cd /usr/local/pmysql/

[root@sutest242 pmysql]# ./bin/mysqld_safe --defaults-file=/data/mysql/pmysql3330.cnf &

[1] 13745

[root@sutest242 pmysql]#  mysqld_safe Adding '/usr/lib/libjemalloc.so.1' to LD_PRELOAD for mysqld

2017-06-24T02:31:06.679622Z mysqld_safe Logging to '/data/mysql/pmysql3330/data/error.log'.

2017-06-24T02:31:06.685066Z mysqld_safe Logging to '/data/mysql/pmysql3330/data/error.log'.

2017-06-24T02:31:06.788240Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/pmysql3330/data

 

2.3 修改transparent_hugepage

tokudb引擎须要运行透明大页,更加好的提供内部存款和储蓄器管理。

[root@sutest244 percona5718]# cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

 

亟需修改为never,若是不修改,使用tokudb引擎的时候,会在error.log中报错

 

Transparent huge pages are enabled, according to /sys/kernel/mm/redhat_transparent_hugepage/enabled

Transparent huge pages are enabled, according to /sys/kernel/mm/transparent_hugepage/enabled

 

配置如下:

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

 

**2.4 安装tokudb引擎跟percona client **

官方网站下载后装置。

rpm -ivhPercona-Server-shared-57-5.7.17-13.1.el6.x86_64.rpm

rpm -ivhPercona-Server-client-57-5.7.17-13.1.el7.x86_64.rpm

rpm -ivhPercona-Server-server-57-5.7.17-13.1.el6.x86_64.rpm

rpm -ivh --force --nodeps Percona-Server-tokudb-57-5.7.17-13.1.el7.x86_64.rpm

**2.5 启用tokudb存储引擎**

设置tokudb引擎后,会提示运转指令语法如下:

 

* 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_tokudb_admin --enable -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]

  * See for more installation details

  * See for an introduction to TokuDB

 

使用 ps_tokudb_admin指令 :

ps_tokudb_admin --enable -uroot -p  --sock=/tmp/pmysql.sock --defaults-file=/data/mysql/mysql3306.cnf

 

假设符合规律,则是以下呈现,不健康的话,看下后面包车型地铁设置步骤是否少了

 

Checking if Percona server is running with jemalloc enabled...
>> Percona server is running with jemalloc enabled.

Checking transparent huge pages status on the system...
>> Transparent huge pages are currently disabled on the system.

Checking if thp-setting=never option is already set in config file...
>> Option thp-setting=never is not set in the config file.
>> (needed only if THP is not disabled permanently on the system)

Checking TokuDB plugin status...
>> TokuDB plugin is not installed.

Adding thp-setting=never option into /etc/mysql/my.cnf
>> Successfuly added thp-setting=never option into /etc/mysql/my.cnf

Installing TokuDB engine...
>> Successfuly installed TokuDB plugin.

 

安装生产后,能够在

 

SHOW PLUGINS;

SHOW ENGINES;

 

TokuDB Version

root@localhost:pmysql3330.sock  10:42:50 [(none)]>SELECT @@tokudb_version;

------------------

| @@tokudb_version |

------------------

| 5.7.17-13        |

------------------

1 row in set (0.00 sec)

 

3 文件管理及分析

3.1 安装tokudb引擎后的增加产量文件

在数据目录中,新添了8个文件

[root@sutest242 data]# pwd

/data/mysql/pmysql3330/data

[root@sutest242 data]# ls -lh | grep tokudb

-rw-r-----. 1 mysql mysql  16K Jun 24 10:42 tokudb.directory

-rw-r-----. 1 mysql mysql  16K Jun 24 10:42 tokudb.environment

-rw-------. 1 mysql mysql    0 Jun 24 10:42 __tokudb_lock_dont_delete_me_data

-rw-------. 1 mysql mysql    0 Jun 24 10:42 __tokudb_lock_dont_delete_me_environment

-rw-------. 1 mysql mysql    0 Jun 24 10:42 __tokudb_lock_dont_delete_me_logs

-rw-------. 1 mysql mysql    0 Jun 24 10:42 __tokudb_lock_dont_delete_me_recovery

-rw-------. 1 mysql mysql    0 Jun 24 10:42 __tokudb_lock_dont_delete_me_temp

-rw-r-----. 1 mysql mysql  16K Jun 24 10:42 tokudb.rollback

 

  1. tokudb.environment:tokudb赢取的情形变量存储文件,像成立时间、当前版本号
  2. tokudb.rollback:每贰个tokudb的事体,都有谈得来的回滚日志,具体回滚日志分配相关消息记录在此间
  3. tokudb.directory:映射文件夹的名字

3.2 tokudb文件管理

能够统一把tokudb的数据文件存储在有些文件夹下,参数是 tokudb_data_dir

能够统一把tokudb的有时文件存款和储蓄在有个别文件夹下,参数是 tokudb_tmp_dir

能够统一把tokudb的日记文件存款和储蓄在某些文件夹下,参数是 tokudb_log_dir

  • 什么迁移:
    1. 关闭数据库服务
    2. 安顿文件中加多或许涂改 tokudb_data_dir、tokudb_tmp_dir、、、
    3. 成立 tokudb 文件的囤积目录
    4. 挪动文件
      1. 移动 *.tokudb 文件 跟 __tokudb_lock_dont_delete_me_data 到新的蕴藏目录
      2. 移动 __tokudb_lock_dont_delete_me_temp 到新的 存款和储蓄目录
      3. 移动 到新的 log*.tokulog* files and your __tokudb_lock_dont_delete_me_logs file 存款和储蓄目录
    5. 起步数据库服务器
    6. 查看文件的寄放地点
      1. SELECT dictionary_name, internal_file_name FROM INFORMATION_SCHEMA.TokuDB_file_map;

**3.3 主题素材浅析**

information_schemaCurry边的附和系统视图深入分析

 

root@localhost:pmysql3330.sock  17:15:33 [information_schema]>show tables like '%tokudb%';

-----------------------------------------

| Tables_in_information_schema (%tokudb%) |

-----------------------------------------

| TokuDB_fractal_tree_block_map           |

| TokuDB_lock_waits                       |

| TokuDB_trx                              |

| TokuDB_file_map                         |

| TokuDB_locks                            |

| TokuDB_fractal_tree_info                |

| TokuDB_background_job_status            |

-----------------------------------------

7 rows in set (0.00 sec)

 

 

4 备份

    tokudb怎么样备份呢?

   单表也得以动用mysqldump。全库呢? tokudb引擎全库备份,官方版本是采取 tokudb_backup 引擎来进展,援助在线热备。也正是,要求其他安装这么些引擎,安装相对简单,使用 ps_tokudb_admin 重启数据库服务预加载引擎 ps_tokudb_admin。

4.1 安器械份引擎

   首先,确定保证数据库是运营健康状态,实行ps_tokudb_admin,若是数据库配置文件 cnf不是在 /etc/my.cnf,必要手动钦点--defaults-file,幸免不可能找到配置文件写入 preload-hotbackup。

 

[root@sutest242 pmysql]# ps_tokudb_admin --enable-backup --socket=/tmp/pmysql3330.sock -uroot -p*** --defaults-file=/data/mysql/pmysql3330.cnf

Checking SELinux status...

INFO: SELinux is in permissive mode.

 

Checking if Percona Server is running with jemalloc enabled...

INFO: Percona Server is running with jemalloc enabled.

 

Checking transparent huge pages status on the system...

INFO: Transparent huge pages are currently disabled on the system.

 

Checking if thp-setting=never option is already set in config file...

INFO: Option thp-setting=never is not set in the config file.

      (needed only if THP is not disabled permanently on the system)

 

Checking if preload-hotbackup option is already set in config file...

INFO: Option preload-hotbackup is not set in the config file.

 

Checking TokuDB engine plugin status...

INFO: TokuDB engine plugin is installed.

 

Checking TokuBackup plugin status...

INFO: TokuBackup plugin is not installed.

 

Adding preload-hotbackup option into /data/mysql/pmysql3330.cnf

INFO: Successfully added preload-hotbackup option into /data/mysql/pmysql3330.cnf

PLEASE RESTART MYSQL SERVICE AND RUN THIS SCRIPT AGAIN TO FINISH INSTALLATION!

 

 

    这年,能够看出提醒:Successfully added preload-hotbackup option into /data/mysql/pmysql3330.cnf,查看配置文件,在 mysqld_safe 配置中,添扩张了一行 配置 :preload-hotbackup。

 

[mysqld_safe]

preload-hotbackup

malloc-lib=/usr/lib/libjemalloc.so.1

 

 

    重启数据库服务,使用 mysqladmin关闭,mysqld_safe 启动

 

 

[root@sutest242 pmysql]# /usr/local/pmysql/bin/mysqladmin --socket=/tmp/pmysql3330.sock -uroot -p shutdown

Enter password:

2017-06-26T03:48:20.192200Z mysqld_safe mysqld from pid file /data/mysql/pmysql3330/data/mysql.pid ended

[1]   Done                    ./bin/mysqld_safe --defaults-file=/data/mysql/pmysql3330.cnf

 

[root@sutest242 pmysql]# ./bin/mysqld_safe --defaults-file=/data/mysql/pmysql3330.cnf &

[1] 10069

[root@sutest242 pmysql]#  mysqld_safe Adding '/usr/lib/libjemalloc.so.1' to LD_PRELOAD for mysqld

 mysqld_safe Adding '/usr/lib64/libHotBackup.so' to LD_PRELOAD for mysqld

2017-06-26T03:50:32.005677Z mysqld_safe Logging to '/data/mysql/pmysql3330/data/error.log'.

2017-06-26T03:50:32.013350Z mysqld_safe Logging to '/data/mysql/pmysql3330/data/error.log'.

2017-06-26T03:50:32.099577Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/pmysql3330/data

 

   这里有个地点注意下, libHotBackup.so 记得要cp到 /usr/lib 恐怕/usr/lib64的目录下,不然mysqld_safe运营数据库的时候,会报错如下:

 

mysqld_safe Adding '/usr/lib/libjemalloc.so.1' to LD_PRELOAD for mysqld

mysqld_safe Adding '/opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101/lib/libHotBackup.so' to LD_PRELOAD for mysqld

mysqld_safe ld_preload libraries can only be loaded from system directories (/usr/lib64, /usr/lib, /usr/local/pmysql/lib)

 

    这种场合下,它检查到 安装目录下有 libHotBackup.so 引擎文件,会选用那一个加载,须求 把那几个文件拷贝到 /usr/lib64 或者/usr/lib,再重新加载这么些文件,然后再度实施 mysqld_saft运转服务。

 

cp /opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101/lib/libHotBackup.so /usr/lib/libHotBackup.so

mv /opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101/lib/libHotBackup.so /opt/percona/Percona-Server-5.7.17-13-Linux.x86_64.ssl101/lib/libHotBackup.so.bak

 

    数据库运营后,安器械份引擎

 

[root@sutest242 pmysql]# ps_tokudb_admin --enable-backup --socket=/tmp/pmysql3330.sock -uroot -p

Enter password:

 

Checking SELinux status...

INFO: SELinux is in permissive mode.

 

Checking if Percona Server is running with jemalloc enabled...

INFO: Percona Server is running with jemalloc enabled.

 

Checking transparent huge pages status on the system...

INFO: Transparent huge pages are currently disabled on the system.

 

Checking if thp-setting=never option is already set in config file...

INFO: Option thp-setting=never is not set in the config file.

      (needed only if THP is not disabled permanently on the system)

 

Checking if preload-hotbackup option is already set in config file...

INFO: Option preload-hotbackup is set in the config file.

 

Checking TokuDB engine plugin status...

INFO: TokuDB engine plugin is installed.

 

Checking TokuBackup plugin status...

INFO: TokuBackup plugin is not installed.

 

Checking if Percona Server is running with libHotBackup.so preloaded...

INFO: Percona Server is running with libHotBackup.so preloaded.

 

Adding thp-setting=never option into /etc/my.cnf

INFO: Successfully added thp-setting=never option into /etc/my.cnf

 

Installing TokuBackup plugin...

INFO: Successfully installed TokuBackup plugin.

 

 

    检查

 

root@localhost:pmysql3330.sock  14:34:21 [(none)]>show plugins;

......

| TokuDB                        | ACTIVE   | STORAGE ENGINE     | ha_tokudb.so     | GPL     |

| TokuDB_background_job_status  | ACTIVE   | INFORMATION SCHEMA | ha_tokudb.so     | GPL     |

| TokuDB_file_map               | ACTIVE   | INFORMATION SCHEMA | ha_tokudb.so     | GPL     |

| TokuDB_fractal_tree_block_map | ACTIVE   | INFORMATION SCHEMA | ha_tokudb.so     | GPL     |

| TokuDB_fractal_tree_info      | 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_trx                    | ACTIVE   | INFORMATION SCHEMA | ha_tokudb.so     | GPL     |

| tokudb_backup                 | ACTIVE   | DAEMON             | tokudb_backup.so | GPL     |

------------------------------- ---------- -------------------- ------------------ ---------

59 rows in set (0.00 sec)

 

**4.2 备份tokudb**

实例备份

  • 布置前提
    • 只要实例含有innodb引擎的表格,要求关闭 innodb异步io的变量 innodb_use_native_aio,制止出现数据不平等,不恐怕苏醒的备份。这几个变量只好在布局文件中增进,属于readonly变量
    • 确立备份文件夹,那几个文件夹必须是为空、授权备份文件夹可写,因为备份的时候,需求写入及创造文件夹,所以对其所在的文本夹要求有权力
    • 注意,tokudb_back对笔者引擎的表格,帮忙对单独存款和储蓄的 tokudb_data_dir tokudb_log_dir binary log备份,然而,不支持不支持不帮忙innodb或然myisam引擎的报表其余部存款和储蓄器储,也正是 全部的InnoDB存款和储蓄引擎,MyISAM,及别的文件必需在MySQL datadir
    • tokubackup不备份MySQL的配备文件(S)
    • tokubackup不补助增量备份
  • 配置
    • 在布署文件中设置 innodb_use_native_aio = OFF,重启数据库实例,这里注意,运维数据库须求到 /usr/local/pmysql 目录下,施行 ./bin/mysqld_safe --defaults-file=/data/mysql/pmysql3330.cnf
    • 确立文件夹 /data/backup/pmysql3330 ,并授权
      • chown -R mysql:mysql /data/backup

      备份分为第22中学,一种是实例备份,一种是钦点备份,近年来tokudb_backup仅援助整个实例备份,协助混合引擎,钦赐备份,近些日子接纳mysqldump方法。

  • 实例备份
    • set tokudb_backup_dir='/data/backup/pmysql3330';
    • 实施这几个命令则起始备份,备份进度中,帮助读写,
  • 备份出错验证

root@localhost:pmysql3330.sock  10:57:13 [(none)]>select @@tokudb_backup_last_error;

----------------------------

| @@tokudb_backup_last_error |

----------------------------

|                         13 |

----------------------------

1 row in set (0.00 sec)

 

root@localhost:pmysql3330.sock  10:57:30 [(none)]>select @@tokudb_backup_last_error_string;

---------------------------------------------------

| @@tokudb_backup_last_error_string                 |

---------------------------------------------------

| tokudb backup couldn't create needed directories. |

---------------------------------------------------

1 row in set (0.00 sec)

  • 报表备份

[root@sutest242 local]# /usr/local/pmysql/bin/mysqldump --socket=/tmp/pmysql3330.sock -uroot -p --set-gtid-purged=OFF --databases toku --tables tbback_toku > /tmp/tbback_toku.sql

Enter password:

  • 实例备份后重操旧业
    • tokudbback没有特定的函数举行数据复苏,能够行使cp大概sync到 数据目录,也许直接采纳备份目录
    • 注意权限修改

rsync -avrP /data/backup/ /var/lib/mysql/

chown -R mysql:mysql /var/lib/mysql

 

 

本文由金沙澳门官网发布于数据库信息,转载请注明出处:澳门金莎娱乐网站:MySQL_第三方数据库引擎_tok

关键词: 金沙澳门官网

上一篇:mysql的并发处理机制_上篇
下一篇:没有了