-- MySQL 5.7 CLUSTER NDB 7.5
-- 创建undo logfile group
create logfile group lg_1
ADD UNDOFILE ‘undo_1.log‘
INITIAL_SIZE 1024M
undo_buffer_size 8M
ENGINE NDBCLUSTER;
-- 增加 logfile
ALTER logfile group lg_1
ADD UNDOFILE ‘undo_2.log‘
initial_size 1024M
ENGINE NDBCLUSTER;
-- 创建tablespace
CREATE TABLESPACE ts1
ADD DATAFILE ‘data_1.dat‘
USE LOGFILE GROUP lg_1
INITIAL_SIZE 1024M
ENGINE NDBCLUSTER;
-- 扩张tablespace
ALTER TABLESPACE ts_1
ADD DATAFILE ‘data_2.dat‘
INITIAL_SIZE 1024M
ENGINE NDBCLUSTER;
-- 创建disk table
CREATE TABLE dt_1 (
member_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
last_name VARCHAR(50) NOT NULL,
first_name VARCHAR(50) NOT NULL,
dob DATE NOT NULL,
joined DATE NOT NULL,
INDEX(last_name, first_name)
)
TABLESPACE ts_1 STORAGE DISK
ENGINE NDBCLUSTER;
-- 删除table
mysql> DROP TABLE dt_1;
mysql> ALTER TABLESPACE ts_1
-> DROP DATAFILE ‘data_2.dat‘
-> ENGINE NDBCLUSTER;
mysql> ALTER TABLESPACE ts_1
-> DROP DATAFILE ‘data_1.dat‘
-> ENGINE NDBCLUSTER;
mysql> DROP TABLESPACE ts_1
-> ENGINE NDBCLUSTER;
mysql> DROP LOGFILE GROUP lg_1
-> ENGINE NDBCLUSTER;
-- 修改内存表为磁盘表
alter table tablename tablespace
ts_1 STORAGE DISK ENGINE=NDB;