怎么在mysql5.7中安装toku存储引擎

默认分类 未结 1 1595
②ing
②ing 2023-03-17 21:35
相关标签:
1条回答
  • 2023-03-17 21:42

    对于有Oracle运维经验的童鞋来说,如果服务器内存很大,一般都会设置HugePages,是因为如下原因:对于 Linux 操作系统,通过 Linux kswapd 进程和页表内存结构(针对系统中存在的每个进程包含一条记录)实现内存管理。 linux的内存管理采取的是分页存取机制,为了保证物理内存能得到充分的利用,内核会按照LRU算法在适当的时候将物理内存中不经常使用的内存页自动交换到虚拟内存中,而将经常使用的信息保留到物理内存。通常情况下,Linux默认情况下每页是4K,这就意味着如果物理内存很大,则映射表的条目将会非常多,会影响CPU的检索效率。而且也浪费内存。因为内存大小是固定的,为了减少映射表的条目,可采取的办法只有增加页的尺寸。因此Hugepage便因此而来。也就是打破传统的小页面的内存管理方式,使用大页面2m,4m,16m,但是Linux系统的大页默认就是2M如此一来映射条目则明显减少。如果系统有大量的物理内存(大于64G),建议使用Hugepage。注意事项 1、HugePage使用的是共享内存,在操作系统启动期间被动态分配并被保留,因为他们不会被置换。 2、由于不会被置换的特点,在使用hugepage的内存不能被其他的进程使用。所以要合理设置该值,避免造成内存浪费。 3、如果增加HugePage或添加物理内存或者是当前服务器增加了新的instance以及SGA设置发生变化,应该重新设置所需的HugePage。辣么,MySQL也是支持滴,那么下面开始讲讲怎么设置大页内存1.首先来看看共享段内存,###centos6的默认共享段内存大小是64G,如果你服务器内存没有超过128G,可以不用修改 # Controls the maximum shared segment size, in byteskernel.shmmax = 68719476736 # Controls the maximum number of shared memory segments, in pageskernel.shmall = 4294967296###先透露一下,使用大页内存的和没有使用大页内存的PageTables [root@crmdbL-172 ~]# free -m total used free shared buffers cachedMem: 32058 29144 2913 0 20 11526-/+ buffers/cache: 17597 14460Swap: 8191 3 8188[root@crmdbL-172 ~]# [root@crmdbL-172 ~]# cat /proc/meminfo | grep PageTables PageTables: 44808 kB[root@crmdbL-172 ~]# [root@node-207 ~]# free -m total used free shared buffers cachedMem: 32095 28501 3593 0 21 9233-/+ buffers/cache: 19246 12848Swap: 8095 0 8095[root@node-207 ~]# [root@node-207 ~]# cat /proc/meminfo | grep PageTables PageTables: 5372 kB[root@node-207 ~]# 差距呢44808-5372=394362.设置MySQL使用大页内存########下面开始设置使用大页内存innodb_buffer_pool_size = 16384Minnodb_additional_mem_pool_size = 16M16384M+16M/2=8200根据以往对ORACLE设置大页的经验,大页内存要大于这个内存,所以我设置了8211个大页vim /etc/sysctl.conf #### HugePages 大小 vm.nr_hugepages=8211###使用大页内存的用户IDvm.hugetlb_shm_group=3306 (id mysql得到的结果)设置当前系统生效,只要刷新一下就行了sysctl -pvim /etc/security/limits.conf * soft nofile 65535 * soft nproc 65535 * hard nofile 65535 * hard nproc 65535#* soft core 0#* hard rss 10000#@student hard nproc 20#@faculty soft nproc 20#@faculty hard nproc 50#ftp hard nproc 0#@student - maxlogins 4###设置mysql 使用 HugePages @mysql soft memlock unlimited@mysql hard memlock unlimitedoracle使用大页也是这样设置重启MySQL,查看错误日志,150728 16:37:43 mysqld_safe mysqld from pid file /data/3306/tmp/mysql.pid ended150728 16:37:44 mysqld_safe Starting mysqld daemon with databases from /data/3306/data2015-07-28 16:37:45 0 [Note] /opt/app/mysql/bin/mysqld (mysqld 5.6.24-log) starting as process 13420 ...2015-07-28 16:37:45 13420 [Note] Plugin ‘FEDERATED‘ is disabled.2015-07-28 16:37:45 7f56f311d740 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB‘s internal memory allocator.2015-07-28 16:37:45 13420 [Note] InnoDB: Using atomics to ref count buffer pool pages2015-07-28 16:37:45 13420 [Note] InnoDB: The InnoDB memory heap is disabled2015-07-28 16:37:45 13420 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2015-07-28 16:37:45 13420 [Note] InnoDB: Memory barrier is not used2015-07-28 16:37:45 13420 [Note] InnoDB: Compressed tables use zlib 1.2.32015-07-28 16:37:45 13420 [Note] InnoDB: Using Linux native AIO2015-07-28 16:37:45 13420 [Note] InnoDB: Using CPU crc32 instructions2015-07-28 16:37:45 13420 [Note] InnoDB: Initializing buffer pool, size = 16.0GInnoDB: HugeTLB: Warning: Failed to allocate 2197815296 bytes. errno 12InnoDB HugeTLB: Warning: Using conventional memory pool居然两个警告InnoDB: HugeTLB: Warning: Failed to allocate 2197815296 bytes. errno 12InnoDB HugeTLB: Warning: Using conventional memory pool ####using conventional memory pool因为hugepage分配内存的时候,预分配、 而且这些分配的内存不能被其他进程占用,而且也不会交换到swap里面去。因为这边配置的,不够大,innodb引擎要求的比你分配的大,这点内存不够使用,所以转成使用常规内存了oracle这方面也出过案例,配置的内存小于SGA大小,白白的浪费那么多内存,造成是用到swap既然报警说不够,查看官方文档,才知道大页内存大小要大于(innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_buffer_size+tmp_table_size),那么刚才配置的显然不够那么我来慷慨点9300个大页也就是说有(9300*2M=18600M,有18.1G的内存),看看能正常启用大页的日志是怎么样的,再次启动mysql看看,这次就不报错了150728 16:55:33 mysqld_safe mysqld from pid file /data/3306/tmp/mysql.pid ended150728 16:56:04 mysqld_safe Starting mysqld daemon with databases from /data/3306/data2015-07-28 16:56:05 0 [Note] /opt/app/mysql/bin/mysqld (mysqld 5.6.24-log) starting as process 17256 ...2015-07-28 16:56:05 17256 [Note] Plugin ‘FEDERATED‘ is disabled.2015-07-28 16:56:05 7fa0048e5740 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB‘s internal memory allocator.2015-07-28 16:56:05 17256 [Note] InnoDB: Using atomics to ref count buffer pool pages2015-07-28 16:56:05 17256 [Note] InnoDB: The InnoDB memory heap is disabled2015-07-28 16:56:05 17256 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2015-07-28 16:56:05 17256 [Note] InnoDB: Memory barrier is not used2015-07-28 16:56:05 17256 [Note] InnoDB: Compressed tables use zlib 1.2.32015-07-28 16:56:05 17256 [Note] InnoDB: Using Linux native AIO2015-07-28 16:56:05 17256 [Note] InnoDB: Using CPU crc32 instructions2015-07-28 16:56:05 17256 [Note] InnoDB: Initializing buffer pool, size = 16.0G2015-07-28 16:56:06 17256 [Note] InnoDB: Completed initialization of buffer pool2015-07-28 16:56:06 17256 [Note] InnoDB: Highest supported file format is Barracuda.2015-07-28 16:56:06 17256 [Note] InnoDB: 128 rollback segment(s) are active.2015-07-28 16:56:06 17256 [Note] InnoDB: Waiting for purge to start2015-07-28 16:56:07 17256 [Note] InnoDB: 5.6.24 started; log sequence number 265641450282015-07-28 16:56:07 17256 [Note] Server hostname (bind-address): ‘*‘; port: 33062015-07-28 16:56:07 17256 [Note] IPv6 is available.2015-07-28 16:56:07 17256 [Note] - ‘::‘ resolves to ‘::‘;2015-07-28 16:56:07 17256 [Note] Server socket created on IP: ‘::‘.2015-07-28 16:56:07 17256 [Warning] Recovery from master pos 155925988 and file mysql-bin.000025.2015-07-28 16:56:07 17256 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SL***E; see the ‘START SL***E Syntax‘ in the MySQL Manual for more information.2015-07-28 16:56:07 17256 [Note] Slave SQL thread initialized, starting replication in log ‘mysql-bin.000025‘ at position 155925988, relay log ‘/data/3306/logs/relay-bin.000058‘ position: 42015-07-28 16:56:07 17256 [Note] Slave I/O thread: connected to master ‘slave@172.16.117.247:3306‘,replication started in log ‘mysql-bin.000025‘ at position 1559259882015-07-28 16:56:07 17256 [Note] Event Scheduler: Loaded 0 events2015-07-28 16:56:07 17256 [Note] /opt/app/mysql/bin/mysqld: ready for connections.Version: ‘5.6.24-log‘ socket: ‘/data/3306/tmp/mysql.sock‘ port: 3306 MySQL Community Server (GPL)[root@node-207 ~]# cat /proc/meminfo | grep ^HugePagesHugePages_Total: 9300HugePages_Free: 9067HugePages_Rsvd: 8178HugePages_Surp: 0Hugepagesize: 2048 kB[root@node-207 ~]# 因为大页内存是独占的,你给多了,也是浪费,那么根据计算公式设置合理的大页大小。然后根据公式在计算了一下innodb_buffer_pool_size = 16384Minnodb_additional_mem_pool_size = 16Minnodb_log_buffer_size = 32Mtmp_table_size=512Mmax_heap_table_size=512M(16384+16+32+512)=16944/2=8472,因为大页内存要比这个大,所以设置了8476,多了四个,因为这是独占的,设置多的也是不能使用的,一般多设置(2个大页以上,5个大页以下)注意这边指的临时表是max_heap_table_size这个参数值大小,是说允许创建内存引擎的临时表大小,下面我们来看看启动日志是不是正常150728 17:14:23 mysqld_safe Starting mysqld daemon with databases from /data/3306/data2015-07-28 17:14:23 0 [Note] /opt/app/mysql/bin/mysqld (mysqld 5.6.24-log) starting as process 18569 ...2015-07-28 17:14:23 18569 [Note] Plugin ‘FEDERATED‘ is disabled.2015-07-28 17:14:23 7fee7b559740 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB‘s internal memory allocator.2015-07-28 17:14:23 18569 [Note] InnoDB: Using atomics to ref count buffer pool pages2015-07-28 17:14:23 18569 [Note] InnoDB: The InnoDB memory heap is disabled2015-07-28 17:14:23 18569 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2015-07-28 17:14:23 18569 [Note] InnoDB: Memory barrier is not used2015-07-28 17:14:23 18569 [Note] InnoDB: Compressed tables use zlib 1.2.32015-07-28 17:14:23 18569 [Note] InnoDB: Using Linux native AIO2015-07-28 17:14:23 18569 [Note] InnoDB: Using CPU crc32 instructions2015-07-28 17:14:23 18569 [Note] InnoDB: Initializing buffer pool, size = 16.0G2015-07-28 17:14:24 18569 [Note] InnoDB: Completed initialization of buffer pool2015-07-28 17:14:24 18569 [Note] InnoDB: Highest supported file format is Barracuda.2015-07-28 17:14:25 18569 [Note] InnoDB: 128 rollback segment(s) are active.2015-07-28 17:14:25 18569 [Note] InnoDB: Waiting for purge to start2015-07-28 17:14:25 18569 [Note] InnoDB: 5.6.24 started; log sequence number 265854467082015-07-28 17:14:25 18569 [Note] Server hostname (bind-address): ‘*‘; port: 33062015-07-28 17:14:25 18569 [Note] IPv6 is available.2015-07-28 17:14:25 18569 [Note] - ‘::‘ resolves to ‘::‘;2015-07-28 17:14:25 18569 [Note] Server socket created on IP: ‘::‘.2015-07-28 17:14:25 18569 [Warning] Recovery from master pos 166617263 and file mysql-bin.000025.2015-07-28 17:14:25 18569 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SL***E; see the ‘START SL***E Syntax‘ in the MySQL Manual for more information.2015-07-28 17:14:25 18569 [Note] Slave SQL thread initialized, starting replication in log ‘mysql-bin.000025‘ at position 166617263, relay log ‘/data/3306/logs/relay-bin.000060‘ position: 42015-07-28 17:14:25 18569 [Note] Slave I/O thread: connected to master ‘slave@172.16.117.247:3306‘,replication started in log ‘mysql-bin.000025‘ at position 1666172632015-07-28 17:14:25 18569 [Note] Event Scheduler: Loaded 0 events2015-07-28 17:14:25 18569 [Note] /opt/app/mysql/bin/mysqld: ready for connections.Version: ‘5.6.24-log‘ socket: ‘/data/3306/tmp/mysql.sock‘ port: 3306 MySQL Community Server (GPL)OK,非常好那么我们来看看大页内存使用了多少,[root@node-207 ~]# cat /proc/meminfo | grep ^HugePagesHugePages_Total: 8476HugePages_Free: 8202HugePages_Rsvd: 8137HugePages_Surp: 0Hugepagesize: 2048 kB[root@node-207 ~]# 才使用了一点点HugePages_Total: 8476HugePages_Free: 8202HugePages_Rsvd: 8137Hugepagesize: 2048 kB那么我们来个大表count(主键)再来看看[root@node-207 ~]# cat /proc/meminfo | grep ^HugePagesHugePages_Total: 8476HugePages_Free: 8123HugePages_Rsvd: 8058HugePages_Surp: 0Hugepagesize: 2048 kB[root@node-207 ~]# cat /proc/meminfo | grep ^HugePagesHugePages_Total: 8476HugePages_Free: 7233HugePages_Rsvd: 7201HugePages_Surp: 0Hugepagesize: 2048 kB####看到木有,有在使用大页了 HugePages_Free: 8123####HugePages_Free: 7233在看看innodb情况,算起来是用了那么多内存,到此大页内存是配置好了---BUFFER POOL 7Buffer pool size 131072Free buffers 113960Database pages 17102Old database pages 8571Modified db pages 1164Pending reads 0Pending writes: LRU 0, flush list 0, single page 0Pages made young 55, not young 00.13 youngs/s, 0.00 non-youngs/sPages read 17080, created 22, written 10560.80 reads/s, 0.00 creates/s, 3.33 writes/sBuffer pool hit rate 974 / 1000, young-making rate 4 / 1000 not 0 / 1000Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/sLRU len: 17102, unzip_LRU len: 0I/O sum[0]:cur[4], unzip sum[0]:cur[0]--------------ROW OPERATIONS--------------0 queries inside InnoDB, 0 queries in queue0 read views open inside InnoDBMain thread process no. 18569, id 140659839203072, state: sleepingNumber of rows inserted 12222, updated 10955, deleted 184, read 181948410.53 inserts/s, 7.67 updates/s, 0.40 deletes/s, 8.07 reads/s----------------------------END OF INNODB MONITOR OUTPUT============================1 row in set (0.00 sec)参考资料:https://dev.mysql.com/doc/refman/5.0/en/large-page-support.htmlI hope this comment will save severals hours and white nights on production launching...After folowing every How-to and all‘s documentation over Google, to enable huge pages... i must give you this post.For enabling huge pages with Linux Debian 6.0.5 on Linux 2.6.32-5-amd64 #x86_64 GNU/Linux (64Bits)and MySQL 5.1, you got to add this your /etc/sysctl.conf :# Total of allowed memoryvm.nr_hugepages = YYYYYY# total amount of memory that can be allocated to shared memory, huge pages or not, on the boxkernel.shmall = XXXXXXXXXX# maximum single shared memory segment, which for me was basically innodb_buffer_pool+1%kernel.shmmax = XXXXXXXXXX# Groupe autorisévm.hugetlb_shm_group = `id -g mysql`XXXXX is given by this script shell in bash :##### SCRIPT START ##########!/bin/bash# keep 2go memory for system# (i got 68Go on this one ans 128Go RAM on other one)keep_for_system=2097152mem=$(free|grep Mem|awk ‘{print$2}‘)mem=$(echo "$mem-$marge"|bc)totmem=$(echo "$mem*1024"|bc)huge=$(grep Hugepagesize /proc/meminfo|awk ‘{print $2}‘)max=$(echo "$totmem*75/100"|bc)all=$(echo "$max/$huge"|bc)echo "kernel.shmmax = $max"echo "kernel.shmall = $all"######### SCRIPT END #########check memory usage before reboot by command :cat /proc/meminfo | grep -i hugeReboot your system.and check memory usage again.It works !;-)Posted by John Anderson on May 13 2015 11:09am [Delete] [Edit] A bit of a note on the math here, some articles and blogs say that you should add your innodb_buffer_pool size to your innodb_additional_mem_pool_size, and divide that by your hugetlb page size. Then add a few on to that. Unfortunately, that doesn‘t seem to be the whole story.For those who want to allocate as little RAM as possible to HugeTLB while still satisfying the requirements outlined in my.cnf, this formula might be a little better. This is after some experimentation led me to put some effort behind finding out why I always had to allocate many more pages than the math suggested.The real formula should be:(innodb_buffer_pool_size in kb +innodb_additional_mem_pool_size in kb + tmp_table_size in kb + innodb_log_buffer_size in kb) / hugetlb size in kbThen to that, add an additional 11 - 15 pages until MySQL starts. I give my best guess as to why these pages are unaccounted for below. First, a note on why tmp_table_size is included: I‘m not sure if it *should* be tmp_table_size * max_tmp_tables, but MySQL starts and runs with only tmp_table_size included. I think this only applies if default_tmp_storage_engine is InnoDB. If a tmp table needs to be created for a sort or order, and that table is going to be InnoDB in RAM, then hugetlb will need to be used.Secondly, I noticed in the source code that the InnoDB buffer log uses the ‘os_mem_alloc_large‘ function. So I think that should be included in the calculation as well. In my experimentation, I had 22 pages unaccounted for until I found that, then my unaccounted for pages went down to 11.As for the pages which don‘t seem to be accounted for, I think that is the overhead cost of the nature of pages. For instance, if you have an innodb_buffer_pool size of 256 MB, and you have 8 buffer instances then you have: (268435456 bytes / 8 instances ) = 33554.4 kilobtes to allocate per page.At 2048 KB per page, that comes to 16.4 pages per buffer. That .4 of a page means an entire page must be allocated, or 17 pages per buffer instead of 16.4. That would account for 8 pages right there. So if one is really picky, declaring buffer sizes that meet the page size exactly would theoretically leave no overhead to absorb. I don‘t know why but MySQL and google convert have differing opinions on how to convert megabytes to bytes, and vice versa. So if you want to cut it as close as possible, fill out your my.cnf. Start mysql without large-pages, and take note of the values of these 4 variables. Then convert those values into kilobytes for the page count calculation.

    配置MySQL使用HugePages

    标签:

    TokuDB引擎是有Tokutek开发的一个数据库存储引擎,在设计之初便引入了独特的索引算法,在其 官网 测试中, 文章 中看到TokuDB性能比InnoDB高出很多。MySQL是一个插件式的数据库,在MySQL5.5版本之前MyISAM是MySQL的默认存储引擎,在之后的版本中默认的存储引擎变成了InnoDB。其特点是它支持事务,具有完善的崩溃恢复机制,具体的特点这里不说明,可以自行的寻找资料。这里介绍的TokuDB和InnoDB有很多相似之处:一个高性能,支持事务、MVCC、聚簇索引等。最大的不同在于TokuDB采用了一种叫做Fractal Tree的索引结构,使其在随机写数据的处理上有很大提升。一般来说数据库的索引结构都采用B+Tree或则类似的数据结构,InnoDB也是如此。InnoDB是以主键组织的B+Tree结构,数据按照主键顺序排列。对于顺序的自增主键有很好的性能,但是不适合随机写入,大量的随机I/O会使数据页*产生碎片,索引维护开销很多大。而TokuDB的Fractal Tree的索引结构很好的解决了这个问题。TokuDB解决随机写入的问题得益于其索引结构,Fractal Tree 和 B-Tree的差别主要在于索引树的内部节点上,B-Tree索引的内部结构只有指向父节点和子节点的指针,而Fractal Tree的内部节点不仅有指向父节点和子节点的指针,还有一块Buffer区。当数据写入时会先落到这个Buffer区上,该区是一个FIFO结构,写是一个顺序的过程,和其他缓冲区一样,满了就一次性刷写数据。所以TokuDB上插入数据基本上变成了一个顺序添加的过程。TokuDB另一个特点是压缩性能和低CPU消耗,TokuDB存储引擎默认的块大小是4M,这使其有更好的压缩效率。默认支持压缩功能,不需要配置其他的东西。压缩选项有:TokuDB_Quicklz、TokuDB_Lzma、TokuDB_Zlib,同时也支持非压缩选项。TokuDB_Zlib支持的默认压缩格式。一般压缩都需要消耗更多的CPU。但TukuDB消耗的CPU资源较少。安装为了方便安装,直接在percona版本的MySQL上安装TokuDB存储引擎。Ubuntu下apt安装percona MySQL: http://www.percona.com/doc/percona-server/5.6/installation/apt_repo.htmlvi /etc/apt/sources.list.d/percona.listdeb http://repo.percona.com/apt trusty main其他:添加其他软件的更新,和本次安装无关vi /etc/apt/sources.listdeb http://mirrors.aliyun.com/ubuntu trusty main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu trusty-updates main restricted universe multiversedeb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse源添加完毕之后更新:apt-get update最后apt安装percona MySQL:apt-get install percona-server-server-5.6 percona-server-client-5.6以上percona MySQL安装完毕,接着就开始安装TokuDB。 参考官网的安装说明: https://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html 安装TokuDB的前提条件是需要支持jemalloc,需要关闭 Transparent huge pages ,执行:echo never > /sys/kernel/mm/transparent_hugepage/enabledecho never > /sys/kernel/mm/transparent_hugepage/defrag效果:root@ptest:~# cat /sys/kernel/mm/transparent_hugepage/enabledalways madvise [never]root@ptest:~# cat /sys/kernel/mm/transparent_hugepage/defragalways madvise [never]开始apt安装TokuDB:root@ptest:~# apt-get install percona-server-tokudb-5.6安装好检查:root@ptest:~# ps_tokudb_admin --enable -uroot -pEnter password:Continuing without password...Checking if Percona server is running with jemalloc enabled...grep: /proc/5440/environ: Permission denied>> 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 installed.Adding thp-setting=never option into /etc/mysql/my.cnf>> Successfuly added thp-setting=never option into /etc/mysql/my.cnf #把参数thp-setting=never加载到了my.cnf的[mysqld_safe]的选项组下通过show engines、show plugins 查看存储引擎,是否安装成功,要是没有成功则检查上面是否有错误。要是通过show engines没有TokuDB,但通过show plugins有则需要手动install:INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';查看版本:>SELECT @@tokudb_version;+------------------+| @@tokudb_version |+------------------+| tokudb-7.5.6 |+------------------+以上就完成了TokuDB的安装。详细信息请见 官网 。测试:针对插入、压缩、存储引擎转换、事务、复制等日常用到的功能进行测试。1)插入和压缩性能:压缩参数: tokudb_row_formatzjy@127.0.0.1 : test 10:58:58>show create table login_log_Toku/G;*************************** 1. row *************************** Table: login_log_TokuCreate Table: CREATE TABLE `login_log_Toku` (`userID` varchar(255) NOT NULL,`tryIP` varchar(255) DEFAULT NULL,`tryTime` datetime DEFAULT NULL,`tryResult` tinyint(1) DEFAULT '0',`refferUrl` varchar(255) DEFAULT NULL,`sID` int(10) unsigned NOT NULL AUTO_INCREMENT,`authType` tinyint(1) DEFAULT '1',`type` tinyint(1) DEFAULT '1',`deviceType` varchar(64) DEFAULT '',PRIMARY KEY (`sID`),KEY `idx_tryip` (`tryIP`),KEY `idx_userid` (`userID`),KEY `idx_tryTime` (`tryTime`)) ENGINE=TokuDB DEFAULT CHARSET=utf81 row in set (0.01 sec)ERROR:No query specifiedzjy@127.0.0.1 : test 10:59:45>insert into login_log_Toku select * from login_log;Query OK, 49534274 rows affected (18 min 35.63 sec)Records: 49534274Duplicates: 0Warnings: 0zjy@127.0.0.1 : test 11:18:40>create table login_log_innodb like login_log;Query OK, 0 rows affected (0.11 sec)zjy@127.0.0.1 : test 11:27:58>insert into login_log_innodb select * from login_log;Query OK, 49534274 rows affected (2 hours 1 min 34.06 sec)Records: 49534274Duplicates: 0Warnings: 0zjy@127.0.0.1 : test 01:29:38>create table login_log_myisam like login_log;Query OK, 0 rows affected (0.15 sec)zjy@127.0.0.1 : test 08:56:30>alter table login_log_myisam engine = myisam;Query OK, 0 rows affected (0.10 sec)Records: 0Duplicates: 0Warnings: 0zjy@127.0.0.1 : test 08:56:51>insert into login_log_myisam select * from login_log;Query OK, 49534274 rows affected (14 min 25.44 sec)Records: 49534274Duplicates: 0Warnings: 0上面看到写入TokuDB表的时间远远小于InnoDB,MyISAM(堆表)的写入也比InnoDB好很多。-rw-rw---- 1 mysql mysql 8.7K5月7 23:27 login_log_innodb.frm-rw-rw---- 1 mysql mysql 9.7G5月8 03:12 login_log_innodb.ibd-rw-rw---- 1 mysql mysql 8.7K5月8 08:56 login_log_myisam.frm-rw-rw---- 1 mysql mysql 3.8G5月8 09:00 login_log_myisam.MYD-rw-rw---- 1 mysql mysql 1.7G5月8 09:11 login_log_myisam.MYI-rw-rw---- 1 mysql mysql 8.7K5月8 16:43 login_log_Toku.frm查看文件,看到InnoDB所占的空间比MyISAM大,9.7>5.5。TokuDB在数据库目录下面只保存.frm表结构定义文件,其数据保存在数据库的目录的上一层:ls -lh *toku*-rw------- 1 mysql mysql12K5月 12 17:00 log000000000005.tokulog27-rw-rw---- 1 mysql mysql64K5月8 16:43 _test_sql_c80_2a_status_34_1_1b.tokudb-rw-rw---- 1 mysql mysql 265M5月8 16:43 _test_login_log_Toku_key_idx_tryip_3c_1_1b_B_1.tokudb-rw-rw---- 1 mysql mysql 229M5月8 16:43 _test_login_log_Toku_key_idx_tryTime_3c_1_1b_B_3.tokudb-rw-rw---- 1 mysql mysql 282M5月8 16:43 _test_login_log_Toku_key_idx_userid_3c_1_1b_B_2.tokudb-rw-rw---- 1 mysql mysql 1.4G5月8 18:25 _test_login_log_Toku_main_3c_1_1b_B_0.tokudb-rw-rw---- 1 mysql mysql17K5月7 17:10 _test_ttt_main_5_1_1b_B_0.tokudb-rw-rw---- 1 mysql mysql16K5月7 17:10 _test_ttt_status_3_1_1b.tokudb-rw-rw---- 1 mysql mysql32K5月8 16:43 tokudb.directory-rw-rw---- 1 mysql mysql16K5月7 17:09 tokudb.environment-rw------- 1 mysql mysql05月7 17:09 __tokudb_lock_dont_delete_me_data-rw------- 1 mysql mysql05月7 17:09 __tokudb_lock_dont_delete_me_environment-rw------- 1 mysql mysql05月7 17:09 __tokudb_lock_dont_delete_me_logs-rw------- 1 mysql mysql05月7 17:09 __tokudb_lock_dont_delete_me_recovery-rw------- 1 mysql mysql05月7 17:09 __tokudb_lock_dont_delete_me_temp-rw-rw---- 1 mysql mysql32K5月8 16:43 tokudb.rollback从上面看出,TokuDB的索引文件和数据文件是分开的,一个索引一个文件。总共大小为2.2G,最小。其他为TokuDB的日志文件和一些元数据。

    可以修改的呀选手动安装,在确定安装路径选择

    0 讨论(0)
提交回复