SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
ExploringMySQL BestPractices for
DBA`s
About ME
Baruchosoveskiy
• Senior Consultant @brillix
• Linux/UNIXSYSADMIN(from 1999)
• DBA onoracleand MySQL.
• Working withMySQLfrom 2000.
• blogger in ildba.co.il
History of MySQL
• 1979Founded anddevelopedbyDavid Axmark,Allan Larsson,
and Michael“Monty” Widenius
• Named afterMonty'sdaughter,My
• Sun acquiredMySQLABin Jan2008for$1billiondollars
• OracleacquiredSun in 2010for $5.6billiondollars
• 4December2012 DavidAxmark,AllanLarsson,and Michael
“Monty” Widenius announcedMariaDB
MySQLVersion History
• 3.11.1First public release
• 3.23 IntegratedBerkeleyDB supportstransactions,
abstractStorageEngine
• 4.0IntegrationInnoDB
• 4.1 significantimprovements,subquery,Unicode,c /s
communicationprotocol
MySQL Version History
• 5.0storedprocedure,view,triggers,queryoptimizer
• 5.1 NDB,record replicationInnoDB plugin defaultinstall
• 5.5 OracleFirstVersionMulti processsupport,
~300% performanceimprovement
• 5.6and7.4clusterCurrentGAVersion
• 5.7CurrentDEV Version
** Productionrecommendationis 5.5 and 5.6.
Who uses MySQL?
US Navy carrier flight
operations
MySQL Server
Community:
Freelydownloadableversionopensourcedatabase.It is
availableunder the GPL license and issupportedbya huge
and activecommunityof open sourcedevelopers.
Enterprise: Free for 30 day evaluation
Paidsubscriptionincludessupportand the following:
• MySQLEnterpriseBackup (LIVE BACKUPtool)
• MySQLEnterpriseMonitor(“GRID CONTROL” like tool)
• MySQLQueryAnalyzer
• MySQLWorkbench(Free)
MySQLArchitecture vs ORACLE Architecture
is it user or schema ?
DataBase
Instance(pmon,smon…) ServerInstance(mysqld)
User User
TableSpace TableSpace
DataFile OSFile-.ibdMYI.MYD.Frm
DataBaseSchema
User
Storage Engines
why so many ?
Storage Engines
why so many ?
• handles,and retrievesinformationfrom a table
• EachStorage Enginehaveits Advantageanddisadvantage
• There is noperfectStorageEngine
• The recommended/default StorageEngineis InnoDB
Storage Engines
why so many ?
Attribute MyISAM HEAP
(Memory)
InnoDB/*XtraDB ARCHIVE
(Compressed stor
age)
Transaction NO NO YES No
LockGranularity Table Table Row row
Storage Filepre
table
In memory TableSpace / fileper
table
Files
Isolationlevel None None All None
Referential
Integrity(FK)
NO NO Yes No
Cached Data NO YES YES No
Advantageand disadvantage
* mariadb donot have INNODB
Storage Engines
why so many ?
Attribute MyISAM HEAP
(Memory)
InnoDB/*XtraDB ARCHIVE
(Compressed stor
age)
Transaction NO NO YES No
LockGranularity Table Table Row row
Storage Filepre
table
In memory TableSpace / fileper
table
Files
Isolationlevel None None All None
Referential
Integrity(FK)
NO NO Yes No
Cached Data NO YES YES No
Advantageand disadvantage
* mariadb donot have INNODB
Storage Engines
why so many ?
Attribute MyISAM HEAP
(Memory)
InnoDB/*XtraDB ARCHIVE
(Compressed stor
age)
Transaction NO NO YES No
LockGranularity Table Table Row row
Storage Filepre
table
In memory TableSpace / fileper
table
Files
Isolationlevel None None All None
Referential
Integrity(FK)
NO NO Yes No
Cached Data NO YES YES No
Advantageand disadvantage
* mariadb donot have INNODB
Storage Engines
why so many ?
Attribute MyISAM HEAP
(Memory)
InnoDB/*XtraDB ARCHIVE
(Compressed stor
age)
Transaction NO NO YES No
LockGranularity Table Table Row row
Storage Filepre
table
In memory TableSpace / fileper
table
Files
Isolationlevel None None All None
Referential
Integrity(FK)
NO NO Yes No
Cached Data NO YES YES No
Advantageand disadvantage
* mariadb donot have INNODB
Storage Engines
why so many ?
And more
• Percona XtraDB enhancedversionof the InnoDB storage
engine.
• RocksDB (LevelDB) is an persistentkey-valuestore for
faststorage.
• OQGRAPH (for MariaDB) Open QueryGRAPHengine
MySQL configuration-my.cnf,my.ini
where is my spfile?
MySQL configuration - my.cnf,my.ini
where is my spfile?
• Configurationfile name my.cnf
• ConfigurationfileLocation:
“/etc/my.cnf”, “/etc/mysql/my.cnf “ in linux,
“C:ProgramDataMySQLMySQL Server 5.6my.ini” inwindows
• mysqld_safe --defaults-file=/etc/my.cnf &
• Can run Multiple MySQLInstancesononemachine
needdifferent port
Storage and log types
what is this file? can I delete it ?
• ErrorLog:log-error (Oracle alertlog)
• BinaryLog:log-bin (Oracle Archivelogs)
• SlowQueryLog:log-slow-queries,slow-query-time,log-queries-
not-using-indexes
• GeneralLog: MySQLsessiondebug log
• .frm: MySQLrepresentseach tablebyan .frm tableformat
file, storestabledefinitionin the databasedirectory.
• .MYD: This is theextensionof theDatafiles for MyISAM
tables.
• .MYI:Thisis theextensionof the Indexfiles for MyISAM
tables.
Storage and log types
what is this file? can I delete it ?
• TABLE_NAME.ibd:If youspecify innodb_file_per_tableoption
to my.cnf,InnoDBstoreseachtable in itsown .ibd
• ibdata1: Sharedtablespace/ data file for InnoDB tables
when innodb_file_per_tableoption isnotspecifiedin my.cnf.
• ib_logfile0, ib_logfile1: InnoDBlogfiles. importantfor
performanceand recovery.
Storage and log types
what is this file? can I delete it ?
The Data Dictionary
where is v$ and DBA_ ?
The Data Dictionary
where is v$ and DBA_
• INFORMATION_SCHEMA– INFORMATIONaboutthe instance,table,
columns,views,privileges
• PERFORMANCE_SCHEMA– INFORMATIONaboutinstance
performance,topsql,top tableIO
• Showcommand– get systemvariablesinformation,oracle
:show parameters
show process list select * from v$sessions ;
show tables select table_name from user_tables;
show variables like ‘%size%’ show parameters size
SELECT TABLE_SCHEMA, SUM((DATA_LENGTH + INDEX_LENGTH) /
(1024 * 1024)) AS SIZE_MB FROM INFORMATION_SCHEMA.TABLES
GROUP BY TABLE_SCHEMA ORDER BY SIZE_MB DESC
SELECT ROUTINE_TYPE, ROUTINE_NAME FROM
INFORMATION_SCHEMA.ROUTINES WHERE
ROUTINE_SCHEMA='dbname';
SELECT EVENT_ID, EVENT_NAME, TIMER_WAIT
FROM PERFORMANCE_SCHEMA.events_waits_history
WHERE THREAD_ID = 13
ORDER BY EVENT_ID;
The Data Dictionary
where is v$ and DBA_
MySQL User account
• MySQLuser accountis basedon username and hostname
For example:
select user,host from mysql.user;
+--------+---------------------+
| user | host |
+--------+---------------------+
| baruch| % |
| root | 127.0.0.1 |
| root | 192.168.10.40 |
| root | ::1 |
| root | localhost |
+--------+--------------------+
The Userroot@127.0.0.1 cannotconnect from 192.168.10.40
And theuserbaruch@% asconnectfrom all clients
Tips for
Developer
Tips for Developer
what the F***, no Sequences ?
• NoSequences - useAUTO_INCREMENT
id INT NOT NULL AUTO_INCREMENT
- Must be tied toa [table].[column]
- Only one per table
- No systemwide capability
- LAST_INSERT_ID()
- No getnextcapability
Tips for Developer
Character Set/Collation
• Every character column hasa column characterset and a
column collation
CREATE TABLE t1
(
col1 CHAR(10) CHARACTER SET utf8,
COLLATE utf8_unicode_ci,
col2 TEXT
) CHARACTER SET latin1 COLLATE
latin1_bin;
Tips for Developer
• EscapedReservedWords areallowed
CREATE TABLE `workers` (...);
CREATE TABLE “workers” (...); (depend on sql_mode)
• Spaceandother specialcharactersallowed
CREATE TABLE `My Table Name` (...);
(depend on OS for file creation )
Tips for Developer
can I use PL/SQL ?
• NoPL/SQL - StoredProcedureswith limited Functionality
NO - Types,Overloading,namedparameters,pinning,
packagesBuilt-in Packages
• MySQLProvide proceduresand functions
Tips for Developer
inserts and dual
• noneedof dual
• Multi valueinsert
INSERT INTO example
VALUES (100, 'Name 1', 'Value 1', 'Other 1'),
(101, 'Name 2', 'Value 2', 'Other 2');
• INSERTON DUPLICATEKEY
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
• StoreIP Addressas UNSIGNEDINT
SELECT INET_ATON('10.0.5.9');
167773449
select 1 select 1 from dual
Tips for Developer
SQL_MODE
• EmulateOracleBehavior
SET SQL_MODE=TRADITIONAL,ORACLE
Example :
Use concatin mysql :
SELECT CONCAT('A','B');
SET sql_mode='PIPES_AS_CONCAT';
SELECT 'A'||'B';
http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html
MySQL Cluster
MySQLReplication – Master Slave(n)
MySQL and NoSQL
NoSQL API
Q & A
Thanks for attending!
Baruch osoveskiy
baruch@brillix.co.il

Contenu connexe

Tendances

MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)Colin Charles
 
When is Myrocks good? 2020 Webinar Series
When is Myrocks good? 2020 Webinar SeriesWhen is Myrocks good? 2020 Webinar Series
When is Myrocks good? 2020 Webinar SeriesAlkin Tezuysal
 
Cool MariaDB Plugins
Cool MariaDB Plugins Cool MariaDB Plugins
Cool MariaDB Plugins Colin Charles
 
Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Jesang Yoon
 
MariaDB 10 and what's new with the project
MariaDB 10 and what's new with the projectMariaDB 10 and what's new with the project
MariaDB 10 and what's new with the projectColin Charles
 
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebMysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebAlkin Tezuysal
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialColin Charles
 
Mysql cluster
Mysql clusterMysql cluster
Mysql clusterJS Lee
 
Hong Qiangning in QConBeijing
Hong Qiangning in QConBeijingHong Qiangning in QConBeijing
Hong Qiangning in QConBeijingshen liu
 
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonMariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonIvan Zoratti
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good? Alkin Tezuysal
 
MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores Mydbops
 
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007eLiberatica
 
OpenStack LA meetup Feb 18, 2015
OpenStack LA meetup Feb 18, 2015OpenStack LA meetup Feb 18, 2015
OpenStack LA meetup Feb 18, 2015Tesora
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesInsight Technology, Inc.
 
MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014Colin Charles
 
MariaDB 10: A MySQL Replacement - HKOSC
MariaDB 10: A MySQL Replacement - HKOSC MariaDB 10: A MySQL Replacement - HKOSC
MariaDB 10: A MySQL Replacement - HKOSC Colin Charles
 
Configure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveConfigure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveRama Krishna B
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012Colin Charles
 

Tendances (20)

MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)
 
When is Myrocks good? 2020 Webinar Series
When is Myrocks good? 2020 Webinar SeriesWhen is Myrocks good? 2020 Webinar Series
When is Myrocks good? 2020 Webinar Series
 
Cool MariaDB Plugins
Cool MariaDB Plugins Cool MariaDB Plugins
Cool MariaDB Plugins
 
Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기Amazon Aurora로 안전하게 migration 하기
Amazon Aurora로 안전하게 migration 하기
 
MariaDB 10 and what's new with the project
MariaDB 10 and what's new with the projectMariaDB 10 and what's new with the project
MariaDB 10 and what's new with the project
 
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebMysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete Tutorial
 
Mysql cluster
Mysql clusterMysql cluster
Mysql cluster
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
 
Hong Qiangning in QConBeijing
Hong Qiangning in QConBeijingHong Qiangning in QConBeijing
Hong Qiangning in QConBeijing
 
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonMariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good?
 
MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores MyDUMPER : Faster logical backups and restores
MyDUMPER : Faster logical backups and restores
 
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
 
OpenStack LA meetup Feb 18, 2015
OpenStack LA meetup Feb 18, 2015OpenStack LA meetup Feb 18, 2015
OpenStack LA meetup Feb 18, 2015
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
 
MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014
 
MariaDB 10: A MySQL Replacement - HKOSC
MariaDB 10: A MySQL Replacement - HKOSC MariaDB 10: A MySQL Replacement - HKOSC
MariaDB 10: A MySQL Replacement - HKOSC
 
Configure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveConfigure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack Trove
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 

Similaire à iloug2015.Mysql.for.oracle.dba.V2

MySQL Ecosystem in 2020
MySQL Ecosystem in 2020MySQL Ecosystem in 2020
MySQL Ecosystem in 2020Alkin Tezuysal
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfMySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfAlkin Tezuysal
 
Maria db 10 and the mariadb foundation(colin)
Maria db 10 and the mariadb foundation(colin)Maria db 10 and the mariadb foundation(colin)
Maria db 10 and the mariadb foundation(colin)kayokogoto
 
The MySQL ecosystem - understanding it, not running away from it!
The MySQL ecosystem - understanding it, not running away from it! The MySQL ecosystem - understanding it, not running away from it!
The MySQL ecosystem - understanding it, not running away from it! Colin Charles
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)Gustavo Rene Antunez
 
The Complete MariaDB Server tutorial
The Complete MariaDB Server tutorialThe Complete MariaDB Server tutorial
The Complete MariaDB Server tutorialColin Charles
 
The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015Colin Charles
 
Build MySQL virtual enviroment
Build MySQL virtual enviromentBuild MySQL virtual enviroment
Build MySQL virtual enviromentTaras Vasylyuk
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksMariaDB plc
 
OSDC 2017 | Lessons from database failures by Colin Charles
OSDC 2017 | Lessons from database failures by Colin CharlesOSDC 2017 | Lessons from database failures by Colin Charles
OSDC 2017 | Lessons from database failures by Colin CharlesNETWAYS
 
What is MariaDB Server 10.3?
What is MariaDB Server 10.3?What is MariaDB Server 10.3?
What is MariaDB Server 10.3?Colin Charles
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlsqlhjalp
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...Insight Technology, Inc.
 
[B14] A MySQL Replacement by Colin Charles
[B14] A MySQL Replacement by Colin Charles[B14] A MySQL Replacement by Colin Charles
[B14] A MySQL Replacement by Colin CharlesInsight Technology, Inc.
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersRonald Bradford
 

Similaire à iloug2015.Mysql.for.oracle.dba.V2 (20)

MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
MySQL Ecosystem in 2020
MySQL Ecosystem in 2020MySQL Ecosystem in 2020
MySQL Ecosystem in 2020
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfMySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
 
Maria db 10 and the mariadb foundation(colin)
Maria db 10 and the mariadb foundation(colin)Maria db 10 and the mariadb foundation(colin)
Maria db 10 and the mariadb foundation(colin)
 
The MySQL ecosystem - understanding it, not running away from it!
The MySQL ecosystem - understanding it, not running away from it! The MySQL ecosystem - understanding it, not running away from it!
The MySQL ecosystem - understanding it, not running away from it!
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)
 
MySQL database
MySQL databaseMySQL database
MySQL database
 
The Complete MariaDB Server tutorial
The Complete MariaDB Server tutorialThe Complete MariaDB Server tutorial
The Complete MariaDB Server tutorial
 
The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015
 
Build MySQL virtual enviroment
Build MySQL virtual enviromentBuild MySQL virtual enviroment
Build MySQL virtual enviroment
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 
Mysql database
Mysql databaseMysql database
Mysql database
 
Fudcon talk.ppt
Fudcon talk.pptFudcon talk.ppt
Fudcon talk.ppt
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocks
 
OSDC 2017 | Lessons from database failures by Colin Charles
OSDC 2017 | Lessons from database failures by Colin CharlesOSDC 2017 | Lessons from database failures by Colin Charles
OSDC 2017 | Lessons from database failures by Colin Charles
 
What is MariaDB Server 10.3?
What is MariaDB Server 10.3?What is MariaDB Server 10.3?
What is MariaDB Server 10.3?
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
 
[B14] A MySQL Replacement by Colin Charles
[B14] A MySQL Replacement by Colin Charles[B14] A MySQL Replacement by Colin Charles
[B14] A MySQL Replacement by Colin Charles
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and Developers
 

iloug2015.Mysql.for.oracle.dba.V2

  • 1.
  • 3. About ME Baruchosoveskiy • Senior Consultant @brillix • Linux/UNIXSYSADMIN(from 1999) • DBA onoracleand MySQL. • Working withMySQLfrom 2000. • blogger in ildba.co.il
  • 4. History of MySQL • 1979Founded anddevelopedbyDavid Axmark,Allan Larsson, and Michael“Monty” Widenius • Named afterMonty'sdaughter,My • Sun acquiredMySQLABin Jan2008for$1billiondollars • OracleacquiredSun in 2010for $5.6billiondollars • 4December2012 DavidAxmark,AllanLarsson,and Michael “Monty” Widenius announcedMariaDB
  • 5. MySQLVersion History • 3.11.1First public release • 3.23 IntegratedBerkeleyDB supportstransactions, abstractStorageEngine • 4.0IntegrationInnoDB • 4.1 significantimprovements,subquery,Unicode,c /s communicationprotocol
  • 6. MySQL Version History • 5.0storedprocedure,view,triggers,queryoptimizer • 5.1 NDB,record replicationInnoDB plugin defaultinstall • 5.5 OracleFirstVersionMulti processsupport, ~300% performanceimprovement • 5.6and7.4clusterCurrentGAVersion • 5.7CurrentDEV Version ** Productionrecommendationis 5.5 and 5.6.
  • 8. US Navy carrier flight operations
  • 9. MySQL Server Community: Freelydownloadableversionopensourcedatabase.It is availableunder the GPL license and issupportedbya huge and activecommunityof open sourcedevelopers. Enterprise: Free for 30 day evaluation Paidsubscriptionincludessupportand the following: • MySQLEnterpriseBackup (LIVE BACKUPtool) • MySQLEnterpriseMonitor(“GRID CONTROL” like tool) • MySQLQueryAnalyzer • MySQLWorkbench(Free)
  • 10. MySQLArchitecture vs ORACLE Architecture is it user or schema ? DataBase Instance(pmon,smon…) ServerInstance(mysqld) User User TableSpace TableSpace DataFile OSFile-.ibdMYI.MYD.Frm DataBaseSchema User
  • 12. Storage Engines why so many ? • handles,and retrievesinformationfrom a table • EachStorage Enginehaveits Advantageanddisadvantage • There is noperfectStorageEngine • The recommended/default StorageEngineis InnoDB
  • 13. Storage Engines why so many ? Attribute MyISAM HEAP (Memory) InnoDB/*XtraDB ARCHIVE (Compressed stor age) Transaction NO NO YES No LockGranularity Table Table Row row Storage Filepre table In memory TableSpace / fileper table Files Isolationlevel None None All None Referential Integrity(FK) NO NO Yes No Cached Data NO YES YES No Advantageand disadvantage * mariadb donot have INNODB
  • 14. Storage Engines why so many ? Attribute MyISAM HEAP (Memory) InnoDB/*XtraDB ARCHIVE (Compressed stor age) Transaction NO NO YES No LockGranularity Table Table Row row Storage Filepre table In memory TableSpace / fileper table Files Isolationlevel None None All None Referential Integrity(FK) NO NO Yes No Cached Data NO YES YES No Advantageand disadvantage * mariadb donot have INNODB
  • 15. Storage Engines why so many ? Attribute MyISAM HEAP (Memory) InnoDB/*XtraDB ARCHIVE (Compressed stor age) Transaction NO NO YES No LockGranularity Table Table Row row Storage Filepre table In memory TableSpace / fileper table Files Isolationlevel None None All None Referential Integrity(FK) NO NO Yes No Cached Data NO YES YES No Advantageand disadvantage * mariadb donot have INNODB
  • 16. Storage Engines why so many ? Attribute MyISAM HEAP (Memory) InnoDB/*XtraDB ARCHIVE (Compressed stor age) Transaction NO NO YES No LockGranularity Table Table Row row Storage Filepre table In memory TableSpace / fileper table Files Isolationlevel None None All None Referential Integrity(FK) NO NO Yes No Cached Data NO YES YES No Advantageand disadvantage * mariadb donot have INNODB
  • 17. Storage Engines why so many ? And more • Percona XtraDB enhancedversionof the InnoDB storage engine. • RocksDB (LevelDB) is an persistentkey-valuestore for faststorage. • OQGRAPH (for MariaDB) Open QueryGRAPHengine
  • 18.
  • 20. MySQL configuration - my.cnf,my.ini where is my spfile? • Configurationfile name my.cnf • ConfigurationfileLocation: “/etc/my.cnf”, “/etc/mysql/my.cnf “ in linux, “C:ProgramDataMySQLMySQL Server 5.6my.ini” inwindows • mysqld_safe --defaults-file=/etc/my.cnf & • Can run Multiple MySQLInstancesononemachine needdifferent port
  • 21. Storage and log types what is this file? can I delete it ? • ErrorLog:log-error (Oracle alertlog) • BinaryLog:log-bin (Oracle Archivelogs) • SlowQueryLog:log-slow-queries,slow-query-time,log-queries- not-using-indexes • GeneralLog: MySQLsessiondebug log
  • 22. • .frm: MySQLrepresentseach tablebyan .frm tableformat file, storestabledefinitionin the databasedirectory. • .MYD: This is theextensionof theDatafiles for MyISAM tables. • .MYI:Thisis theextensionof the Indexfiles for MyISAM tables. Storage and log types what is this file? can I delete it ?
  • 23. • TABLE_NAME.ibd:If youspecify innodb_file_per_tableoption to my.cnf,InnoDBstoreseachtable in itsown .ibd • ibdata1: Sharedtablespace/ data file for InnoDB tables when innodb_file_per_tableoption isnotspecifiedin my.cnf. • ib_logfile0, ib_logfile1: InnoDBlogfiles. importantfor performanceand recovery. Storage and log types what is this file? can I delete it ?
  • 24. The Data Dictionary where is v$ and DBA_ ?
  • 25. The Data Dictionary where is v$ and DBA_ • INFORMATION_SCHEMA– INFORMATIONaboutthe instance,table, columns,views,privileges • PERFORMANCE_SCHEMA– INFORMATIONaboutinstance performance,topsql,top tableIO • Showcommand– get systemvariablesinformation,oracle :show parameters show process list select * from v$sessions ; show tables select table_name from user_tables; show variables like ‘%size%’ show parameters size
  • 26. SELECT TABLE_SCHEMA, SUM((DATA_LENGTH + INDEX_LENGTH) / (1024 * 1024)) AS SIZE_MB FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_SCHEMA ORDER BY SIZE_MB DESC SELECT ROUTINE_TYPE, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='dbname'; SELECT EVENT_ID, EVENT_NAME, TIMER_WAIT FROM PERFORMANCE_SCHEMA.events_waits_history WHERE THREAD_ID = 13 ORDER BY EVENT_ID; The Data Dictionary where is v$ and DBA_
  • 27. MySQL User account • MySQLuser accountis basedon username and hostname For example: select user,host from mysql.user; +--------+---------------------+ | user | host | +--------+---------------------+ | baruch| % | | root | 127.0.0.1 | | root | 192.168.10.40 | | root | ::1 | | root | localhost | +--------+--------------------+ The Userroot@127.0.0.1 cannotconnect from 192.168.10.40 And theuserbaruch@% asconnectfrom all clients
  • 29. Tips for Developer what the F***, no Sequences ? • NoSequences - useAUTO_INCREMENT id INT NOT NULL AUTO_INCREMENT - Must be tied toa [table].[column] - Only one per table - No systemwide capability - LAST_INSERT_ID() - No getnextcapability
  • 30. Tips for Developer Character Set/Collation • Every character column hasa column characterset and a column collation CREATE TABLE t1 ( col1 CHAR(10) CHARACTER SET utf8, COLLATE utf8_unicode_ci, col2 TEXT ) CHARACTER SET latin1 COLLATE latin1_bin;
  • 31. Tips for Developer • EscapedReservedWords areallowed CREATE TABLE `workers` (...); CREATE TABLE “workers” (...); (depend on sql_mode) • Spaceandother specialcharactersallowed CREATE TABLE `My Table Name` (...); (depend on OS for file creation )
  • 32. Tips for Developer can I use PL/SQL ? • NoPL/SQL - StoredProcedureswith limited Functionality NO - Types,Overloading,namedparameters,pinning, packagesBuilt-in Packages • MySQLProvide proceduresand functions
  • 33. Tips for Developer inserts and dual • noneedof dual • Multi valueinsert INSERT INTO example VALUES (100, 'Name 1', 'Value 1', 'Other 1'), (101, 'Name 2', 'Value 2', 'Other 2'); • INSERTON DUPLICATEKEY INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; • StoreIP Addressas UNSIGNEDINT SELECT INET_ATON('10.0.5.9'); 167773449 select 1 select 1 from dual
  • 34. Tips for Developer SQL_MODE • EmulateOracleBehavior SET SQL_MODE=TRADITIONAL,ORACLE Example : Use concatin mysql : SELECT CONCAT('A','B'); SET sql_mode='PIPES_AS_CONCAT'; SELECT 'A'||'B'; http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html
  • 38. Q & A
  • 39. Thanks for attending! Baruch osoveskiy baruch@brillix.co.il