MYSQL5.1集群对数据保存到磁盘的设置

MYSQL5.1.16后的集群数据的非索引部分可以保存到磁盘上。
我来总结一下。随时更新。
先来做一下实验,这些SQL语句都得在SQL节点上运行。
1、创建LOGFILE GROUP


mysql> create logfile group lg_1
    -> add undofile 'undo_1.dat'
    -> initial_size 128M
    -> undo_buffer_size 16M
    -> engine=ndb;
Query OK, 0 rows affected (3.63 sec)

mysql> alter logfile group lg_1
    -> add undofile 'undo_2.dat'
    -> initial_size 80M
    -> engine ndb;
Query OK, 0 rows affected (2.48 sec)

2、创建表空间


mysql> create tablespace ts_1
    -> add datafile 'data_1.dat'
    -> use logfile group lg_1
    -> initial_size 128M
    -> engine ndb;
Query OK, 0 rows affected (3.49 sec)

mysql> alter tablespace ts_1
    -> add datafile 'data_2.dat'
    -> initial_size 160M
    -> engine ndb;
Query OK, 0 rows affected (5.92 sec)

3、应用到NDBCLUSTER引擎的表

mysql> alter table t11 tablespace ts_1 storage disk;
Query OK, 5 rows affected (1.88 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> desc t11;
+-------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| str | varchar(255) | NO | | | |
| money | decimal(12,2) | NO | | | |
+-------+---------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)


4、我们来查看一下NDBD节点上的文件。
之前和之后的比较:


[root@localhost ndb_5_fs]# ls

D1 D10 D11 D2 D8 D9 LCP
[root@localhost ndb_5_fs]# ls

D1 D10 D11 D2 D8 D9 data_1.dat data_2.dat LCP undo_1.dat undo_2.dat

多出来的就是我们刚刚创建的文件。

5、手册上有个很个很重要的提示,
--initial 初始化的时候不会清空logfile group ,和 tablespace。必须手动删除。

Important

Starting the cluster with the --initial option does not remove Disk Data files. You must remove these manually prior to performing an initial restart of the cluster.

本文出自 “上帝,咱们不见不散!” 博客,转载请与作者联系!

转载于:https://my.oschina.net/u/585111/blog/219505

猜你喜欢

转载自blog.csdn.net/weixin_33894640/article/details/92008329