Gestire, scalare e ottimizzare MySQL Cluster - Par

Transcript

Gestire, scalare e ottimizzare MySQL Cluster - Par
Gestire, scalare e ottimizzare
MySQL Cluster
Mirko Conte, System Architect
MySQL Tech Tour Rome, 29 aprile 2015
direzione e sede legale
via campanini 6
20124 milano
tel: +39 02/66.732.1 – fax: +39 02/66.732.300
unità operativa
p.zza san benedetto da norcia 33
00071 pomezia (rm)
tel: +39 06/9826.9600 – fax: +39 06/9826.9680
partita iva e codice fiscale: 12938200156
c.c.i.a.a. milano n.1599095
registro imprese 12938200156
capitale sociale € 2.418.433,00 i.v.
Agenda
•
•
•
•
•
•
Gestire un cluster con MySQL Cluster Manager
Eseguire un benchmark
Scalare orizzontalmente con MySQL Cluster Manager
Ottimizzare schema e query
Aggiornare a caldo un cluster con MySQL Cluster Manager
Online schema changes
2
Gestire un cluster con MCM
•
•
•
•
•
•
•
•
start/stop cluster [-B] <cluster>
show status [-r|-o] <cluster>
delete cluster <cluster>
get <param>[:<processtype>[:<nodeid>]] <cluster>
set [-B] <param>:<processtype>[:<nodeid>]=<valore> <cluster>
collect logs [<cluster>]
backup cluster <cluster>
restore cluster [<opzioni>] <cluster>
3
Eseguire un benchmark
•
•
•
•
Alla base del performance tuning
Stabilire una baseline
Valutare l'impatto di ogni change
Mysqlslap
– Esempio: 500 query r/w da 20 utenti concorrenti
mysqlslap -h<host> -u<user> -p<password> --create-schema=mysqlslap
--auto-generate-sql --auto-generate-sql-add-autoincrement --autogenerate-sql-secondary-indexes=2 --number-char-cols=5 --number-intcols=7 --engine=ndb --auto-generate-sql-execute-number=500 -commit=10 --concurrency=20 --iterations=1
4
Scalare orizzontalmente con MCM
• add process [-B] [-s <conf-attributes>] -R
<processname>@<host>[,<processname>@<host>]* <cluster>
• start process --added <cluster>
• Data nodes
– alter [online] table <tabella> reorganize partition
– optimize table <tabella>
5
Ottimizzare schema e query
Accessi su chiave primaria sono i più efficienti O(1)
Accessi su ordered index sono O(log n)
Data types
Denormalizzazione (es. se più tabelle condividono la stessa chiave
primaria)
• Batching: set transaction_allow_batching=1 (in sessione)
• Partition pruning (distribution aware application)
•
•
•
•
6
Aggiornare a caldo un cluster con MCM
• Installare binari
• add package
• upgrade cluster -P <package> <cluster>
7
Online schema changes
• alter table <tabella> algorithm=inplace, <operazione>
• Supportato con
•
– add index
– drop index
– add column
– limitazioni
Eseguire su nodo fuori traffico
8
Grazie per l’attenzione!
direzione e sede legale
via campanini 6
20124 milano
tel: +39 02/66.732.1 – fax: +39 02/66.732.300
unità operativa
p.zza san benedetto da norcia 33
00071 pomezia (rm)
tel: +39 06/9826.9600 – fax: +39 06/9826.9680