dba tales from the front: from oracle to mysql

35
DBA Tales from t he Front: from O racle to MySQL Ben Krug DBA, Adapt Technologies [email protected] OSCON July 2007

Upload: quilla

Post on 14-Jan-2016

29 views

Category:

Documents


2 download

DESCRIPTION

DBA Tales from the Front: from Oracle to MySQL. Ben Krug DBA, Adapt Technologies [email protected] OSCON July 2007. Who I am:. DBA at Adapt Technologies database experience (chronologically): SAS, Mumps (!), Sybase, *Oracle*, DB2, mSQL,(PostgreSQL),now MySQL - PowerPoint PPT Presentation

TRANSCRIPT

Page 2: DBA Tales from the Front: from Oracle to MySQL

Who I am:- DBA at Adapt Technologies

- database experience (chronologically): SAS, Mumps (!), Sybase, *Oracle*, DB2, mSQL,(PostgreSQL), now MySQL

- As a DBA, helped build an Oracle application that won a Smithsonian Award for Excellence in Computing

- Trivia: was once in an ad for Oracle, for the same system

Page 3: DBA Tales from the Front: from Oracle to MySQL

What I’ll talk about:- what happened to me? (from Oracle to

MySQL)

- Oracle gestalt vs MySQL gestalt

- gotchas (battle wounds - maybe you can learn from our mistakes)

Page 4: DBA Tales from the Front: from Oracle to MySQL

Slides are just an outline- handouts have more details

- for soft copies, email [email protected]

Page 5: DBA Tales from the Front: from Oracle to MySQL

DBA at Adapt – from Oracle to MySQL- Accepted position looking for RAC mastery...

got “Ask Tom's” book, Tales from the Oak Table, CBO book by Jonathan Lewis.

- Read in Tales from the Oak Table how when systems get heavily instrumented, it’s great, but it shows maturity, and is a sign newer systems are coming around the corner... few days later – find out my company is dropping Oracle for an open source database.

Page 6: DBA Tales from the Front: from Oracle to MySQL

Oracle to MySQL: from no eyebrows to eyebrows…

Page 7: DBA Tales from the Front: from Oracle to MySQL

Q: Are the differences in their websites symptomatic?- Oracle website (in my experience) was alway

slow, confusing, overblown

- MySQL website relatively simple, quick, and easy

Page 8: DBA Tales from the Front: from Oracle to MySQL

What’s in a word?- Terminology is different

- (eg, schema vs tablespace vs database)

- (cheat sheet in handouts)

Page 9: DBA Tales from the Front: from Oracle to MySQL

Differences in getting the scoop:

- Wading through Oracle PR gobbledy-gook vs having to research each item to find out about its existence or features.

- (eg storage engines, to see what they can actually do)

Page 10: DBA Tales from the Front: from Oracle to MySQL

Differences in what they are- different products - be-all end-all vs a database

- oracle seemed more complicated - RAC, interconnects, fusion, etc etc - always new pieces and teasers and mystifying PR

- MySQL appeared more simple - a database. less confusing PR but also less documentation. (OTOH, user comments in docs.)

- oracle - which features do you buy - DB, which components, other products (Oracle Identity, etc etc)

- MySQL - buy (or don’t buy!) the DB

Page 11: DBA Tales from the Front: from Oracle to MySQL

Different Philosophies?- Open source vs closed

- Who are they serving

- What are they trying to achieve

- Etc…

Page 12: DBA Tales from the Front: from Oracle to MySQL

Different communities- Open source community vs proprietary source

community

- Knowledge of inner-workings of DB

- Mood of excitement with MySQL

- Who are the customers? (web 2.0!)

- Etc…

Page 13: DBA Tales from the Front: from Oracle to MySQL

Different support experiences- Oracle - hated it

- log a tar, if it's not severity 1, good luck getting competent help if you ever hear back

- once had to make threats to get help with a mission-critical sev 1 (Oracle v7, to be fair)

- MySQL - love it!

- have always had timely help, almost always very knowledgeable, helpful, and interested

- don't need to try to get past level 1 support

Page 14: DBA Tales from the Front: from Oracle to MySQL

Different scaling strategies- “scaling out” vs “scaling up”

Page 15: DBA Tales from the Front: from Oracle to MySQL

OK, so go get it! - went to mysqlab.com and downloaded community

edition rpm's and installed them.

- build from source if you're hardcore

Page 16: DBA Tales from the Front: from Oracle to MySQL

Get your developer / DBA tools- not like Oracle 10g with its instrumentation

(but can set up advisors, if you pay)

- MySQL GUI tools - MySQL Query Browser, MySQL Administrator, etc

Page 17: DBA Tales from the Front: from Oracle to MySQL

Our first GOTCHA – storage engines- choose a storage engine! Eg…

- MyISAM - default, good performance, no FKs no ACID transactions

- NDB (for clustering) - in-memory only on 5.0

- InnoDB - FKs and ACID-compliant transactions (InnoBase owned by Oracle now)

- Falcon - coming...

- etc

Page 18: DBA Tales from the Front: from Oracle to MySQL

Scaling strategies (scaling out)- replication configurations - master/slave

- if you're going to use sharding, beware issues for auto_increments, FKs, global views (failures if a host fails), etc

Page 19: DBA Tales from the Front: from Oracle to MySQL

Set up your backups- mysqldump (exports)

- no hot backups for InnoDB? – linux can use LVM

- can also use mysqldumps and then binary logs to roll forward

- (but beware statement-based vs row-based logging, especially if you use auto-increments)

Page 20: DBA Tales from the Front: from Oracle to MySQL

Set up your permissions- No roles

- can be based on where someone is coming from (what host or subnet)

- networking issues? IP-based vs name-based authentication

Page 21: DBA Tales from the Front: from Oracle to MySQL

Build your DB! Issues…- InnoDB tables are clustered by PK, other keys

point to PK values

- beware that FKs in InnoDB can cause locking issues (lock wait timeouts)

Page 22: DBA Tales from the Front: from Oracle to MySQL

Let the users in- users' connection settings

- @@autocomit - on by default

- can use init_connect settings to change

- beware - superusers bypass this!

Page 23: DBA Tales from the Front: from Oracle to MySQL

Our next GOTCHA- collations

- default is latin1_swedish_ci

- 'a'='A'

- we use utf8, utf8_bin

- 'a'<>'A'

Page 24: DBA Tales from the Front: from Oracle to MySQL

GOTCHA 3- autocommit=1 by default

- wanted autocommit turned off for most code, but on for one user

Page 25: DBA Tales from the Front: from Oracle to MySQL

GOTCHA 3- autocommit=1 by default

- wanted autocommit turned off for most code, but on for one user

- 3a: init_connect and auto_commit, and that superusers bypass init_connect (which can be good)

Page 26: DBA Tales from the Front: from Oracle to MySQL

GOTCHA 3- autocommit=1 by default

- wanted autocommit turned off for most code, but on for one user

- 3a: init_connect and auto_commit, and that superusers bypass it

- 3b: security information for users is spread between information_schema and mysql databases. ‘super’ is in mysql.user, not in information_schema tables. (In case you get bitten by 3a.)

Page 27: DBA Tales from the Front: from Oracle to MySQL

Our next GOTCHA- SQL_MODEs -

- Inserting inserting bad data by default, rather than giving errors

- How 0’s can be used for null dates

Page 28: DBA Tales from the Front: from Oracle to MySQL

GOTCHA- error messages that are not informative or are

misleading

- eg, errors involving foreign keys, indexes, and altering tables – you’d never guess the problem from the errors:

- MySQL Error Number 1005Can’t create table ‘.\mydb\#sql-328_45.frm’ (errno: 150)

Page 29: DBA Tales from the Front: from Oracle to MySQL

GOTCHA- Locks are different! InnoDB locks... deal with

it:

- Writers blocking readers, readers blocking writers

- (row-level, not like Oracle block-level)

- Issues with foreign keys

- isolation levels

Page 30: DBA Tales from the Front: from Oracle to MySQL

GOTCHA- using "force index" in a select doesn't really

"force" the use of the index

- InnoDB optimizes using a set number of "random dives" into a table to estimate statistics, and can still decide not to use a “forced” index

- (not like histograms or choosing how many rows to sample for statistics in Oracle)

Page 31: DBA Tales from the Front: from Oracle to MySQL

Care for your database- GOTCHA: optimizing for an InnoDB table

prevents updates

- "large" table can take a long time

- one multi-Gig table took hours to optimize, but then query times were cut in half

Page 32: DBA Tales from the Front: from Oracle to MySQL

Performance…- performance can suffer over time for inserts and

updates in large tables

- use optimize if possible (in spite of the GOTCHA)

- "insert on duplicate key update" (like Oracle's "merge")

Page 33: DBA Tales from the Front: from Oracle to MySQL

So why do I love MySQL?- you can read the code, so people know how it

works (including support staff)

- (I can understand it - it's not a black box)

- enjoy the community (including Marten Mickos vs Larry Ellison)

- love the support

- it's a database - not middleware, Application server, etc. I like databases; that’s why I became a DBA.

Page 34: DBA Tales from the Front: from Oracle to MySQL

And where do you go for help?- Buy support! It’s worth it – cheap and very useful.

- Read the docs, the blogs, watch planetmysql.com.

- Do a lot of googling

- Books I recommend: Pro MySQL by Jay Pipes (Apress) is like an “Ask Tom” type book. Sasha Pachev’s Understanding MySQL internals (O’Reilly) is a nice introduction to reading the code (if you want to)

- (With Oracle, you have to work to read the tomes – the docs and the few good books. With MySQL, you have to work to find what you’re going to read.)

Page 35: DBA Tales from the Front: from Oracle to MySQL

Q&A- Ben Krug

- DBA, Adapt Technologies

- [email protected]

- OSCON July 2007