Domanda

Io uso il mio computer di casa come il mio database personale per il mio progetto di hobby di analisi. Questa macchina ha uno SSD per l'unità principale dove MySQL memorizza i propri dati. Essa ha anche un disco rigido secondario che è più grande e non uno SSD. Sono in procinto di creare una tabella che ho paura potrebbe essere troppo grande per entrare sul mio SSD; è possibile per me per memorizzare invece che una tabella sul più grande (ma più lento) unità? Se è importante, sto utilizzando in genere le tabelle MyISAM, ma potrebbe essere convinto a usare InnoDB se che avrebbe aiutato.

È stato utile?

Soluzione 3

La risposta di

?? Rolando quasi funziona, tranne che richiede collegamenti fisici. Per quanto mi risulta, gli hard link non sono possibili tra 2 unità fisiche (utilizzando una diversa unità fisica è l'unica ragione per cui voglio una nuova directory).

Tuttavia, la sua risposta (e di href="https://dba.stackexchange.com/a/10112/1256"> Vladislav) mi ha fornito l'ispirazione per trovare un risposta che sembra funzionare per me. In breve, creare un file database_name.sym e metterlo nella directory di directory dei dati di database_name. Mettere il nome della nuova directory in quel file .sym, e quindi spostare la directory dei dati database_name nella nuova posizione si fa riferimento nel file .sym.

Altri suggerimenti

Come già discusso qui, non v'è alcun supporto automatico per collegamenti nelle MySQL. Tuttavia è possibile creare link simbolici youself.

Spostare i file dalla directory dei dati da qualche altra parte, come amministratore creare collegamenti simbolici con

mklink originale-percorso nuovo-path

Se si dispone di un antico di Windows (ad esempio XP o Windows 2003), questo non avrebbe funzionato. Supporto collegamento simbolico in NTFS ha debuttato in Vista.

Migrazione s singola tabella MyISAM altro disco è href="http://dev.mysql.com/doc/refman/5.5/en/limits-windows.html" possibile solo in versioni di Linux, non di Windows, di MySQL con le clausole di dati della directory e indice di directory di ALTER tABLE su una tabella MyISAM.

Tuttavia, in Windows, è possibile spostare manualmente i file MYD e .MYI in cui si desidera.

UPDATE 2012-01-03 22:03 EDT

Interestinging, MySQL 5.5.15 sul mio Windows 7 macchine dice esiste supporto link simbolico:

mysql> show variables like 'have_sym%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_symlink  | YES   |
+---------------+-------+
1 row in set (0.09 sec)

Ho anche scoperto che dei link simbolici è possibile in Windows:

sul mio Windows 7 macchine a casa, esiste il mklink utility a riga di comando:

C:\Windows\system32>mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

C:\Windows\system32>

Sono scioccata !!! Ciò significa che si può sperimentare con CREATE TABLE ... DATA DIRECTORY='...' INDEX DIRECTORY='...' in Windows.

Ho appena provato questo:

use test
drop table if exists data_table;
drop table if exists data_table_sharded;
CREATE TABLE data_table (a int,primary key(a)) ENGINE=MyISAM;
CREATE TABLE data_table_sharded LIKE data_table;
ALTER TABLE data_table_sharded DATA DIRECTORY='C:\DAT' INDEX DIRECTORY='C:\NDX';

Ho appena ricevuto questa:

mysql> use test
Database changed
mysql> drop table if exists data_table;
Query OK, 0 rows affected (0.02 sec)

mysql> drop table if exists data_table_sharded;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE data_table (a int,primary key(a)) ENGINE=MyISAM;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE data_table_sharded LIKE data_table;
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER TABLE data_table_sharded DATA DIRECTORY='C:\DAT' INDEX DIRECTORY='C:\NDX';
Query OK, 0 rows affected, 2 warnings (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 2

mysql> show warnings;
+---------+------+----------------------------------+
| Level   | Code | Message                          |
+---------+------+----------------------------------+
| Warning | 1618 | <DATA DIRECTORY> option ignored  |
| Warning | 1618 | <INDEX DIRECTORY> option ignored |
+---------+------+----------------------------------+
2 rows in set (0.00 sec)

mysql>

non è ancora possibile utilizzare l'opzione DATA DIRECTORY E INDEX DIRECTORY in CREATE TABLE o ALTER TABLE.

UPDATE 2012-01-03 22:45 EDT

ho eseguito questi comandi

use test
drop table if exists data_table;
drop table if exists data_table_sharded;
CREATE TABLE data_table (a int,primary key(a)) ENGINE=MyISAM;
INSERT INTO data_table VALUES (71),(22),(128),(97),(18),(4),(112),(277);
CREATE TABLE data_table_sharded LIKE data_table;

Ho fatto due directory

  • mkdir C:\dat
  • mkdir C:\ndx

Ho creato quelle cartelle e ha creato collegamenti fisici per data_table_sharded

C:\MySQL\data\test>mklink /H data_table_sharded.MYD C:\dat\data_table_sharded.MYD
Hardlink created for data_table_sharded.MYD <<===>> C:\dat\data_table_sharded.MYD

C:\MySQL\data\test>mklink /H data_table_sharded.MYI C:\ndx\data_table_sharded.MYI
Hardlink created for data_table_sharded.MYI <<===>> C:\ndx\data_table_sharded.MYI

C:\MySQL\data\test>

Sono tornato a MySQL e caricato i dati da data_table:

mysql> flush tables;
Query OK, 0 rows affected (0.05 sec)

mysql> INSERT INTO data_table_sharded SELECT * FROM data_table;
Query OK, 8 rows affected (0.00 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> show create table data_table_sharded\G
*************************** 1. row ***************************
       Table: data_table_sharded
Create Table: CREATE TABLE `data_table_sharded` (
  `a` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> select * from data_table_sharded;
+-----+
| a   |
+-----+
|   4 |
|  18 |
|  22 |
|  71 |
|  97 |
| 112 |
| 128 |
| 277 |
+-----+
8 rows in set (0.00 sec)

mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)

mysql>

Quindi, si può fare. Basta usare mklink per creare hard link invece di link simbolici. WOW !!!

ho imparato qualcosa su MySQL per Windows. Dubito che Oracle implementare le opzioni DATA DIRECTORY e INDEX DIRECTORY in quanto il motore di memorizzazione di default è ora InnoDB.

Nonostante ciò, si crea la tabella vuota, spostare il .MYD e .MYI a diverse cartelle dal sistema operativo, creare hard link, FLUSH TABLES; correre e inserisci i tuoi dati.

Fare un tentativo, e fatemi sapere come va ...

Utilizzando hard link per questo richiede la creazione di un collegamento fisso per ogni file. Utilizzando il / J a comando mklink crea una directory Junction, e dopo che un comando mysql sarebbe scrivere i file nella directory per l'altra unità. Per esempio è possibile creare un bivio per C: \ dat per l'unità più lenta, e lasciare C: \ ndx sulla SSD per un accesso più rapido quando le query vengono indicizzati.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a dba.stackexchange
scroll top