+ All Categories
Home > Internet > Rootconf admin101

Rootconf admin101

Date post: 21-Jan-2018
Category:
Upload: ligaya-turmelle
View: 205 times
Download: 0 times
Share this document with a friend
45
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Administration 101 Ligaya Turmelle Principal Technical Support Engineer - MySQL [email protected] @lig
Transcript
Page 1: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLAdministration101

LigayaTurmellePrincipalTechnicalSupportEngineer-MySQLligaya.turmelle@oracle.com@lig

Page 2: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLAdministration101

LigayaTurmellePrincipalTechnicalSupportEngineer-MySQLligaya.turmelle@oracle.com@lig

Page 3: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SafeHarborStatement

Thefollowingisintendedtooutlineourgeneralproductdirection.Itisintendedforinformationpurposesonly,andmaynotbeincorporatedintoanycontract.Itisnotacommitmenttodeliveranymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions.Thedevelopment,release,andtimingofanyfeaturesorfunctionalitydescribedforOracle’sproductsremainsatthesolediscretionofOracle.

3

Page 4: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

ProgramAgenda

AccessControl

DiagnosticData

LogFiles

Backups

1

2

3

4

4

Page 5: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

AccessControl

5

Page 6: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

AccessControl

• 2stage– Stage1-connecting• Whoareyou?– host– user

6

Page 7: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

UserAccounts

• CREATE USER

• ALTER USER

7

mysql> CREATE USER 'sha256'@'localhost' -> IDENTIFIED WITH sha256_password BY 'S3cr3t!' -> REQUIRE SSL -> PASSWORD EXPIRE INTERVAL 90 DAY; Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER 'sha256'@'localhost' -> IDENTIFIED WITH sha256_password BY ‘T4D4h?' -> REQUIRE SSL -> PASSWORD EXPIRE INTERVAL 180 DAY; Query OK, 0 rows affected (0.01 sec)

Page 8: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

AccessControl

• 2stage– Stage1-connecting• Whoareyou?– host– user

• Proveit!

8

(con’t)

Page 9: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Passwords

• Expiration–Manually(5.6)andwithaPolicy(5.7)

• Hashing–Multipleauthenticationpluginsavailable

• Policy– Usepasswordvalidationplugin(validate_password)• Cleartextsuppliedpasswordcheckedagainstpasswordpolicy• 3levelsofpasswordcheckingwhichcanbemodified

9

Page 10: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

AccessControl

• 2stage– Stage1-connecting• Whoareyou?– host– user

• Proveit!– Stage2-request• Foreachrequest–Whatareyoudoing?– Areyouallowedtodothat?

10

(con’t)

Page 11: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

GRANT

• Definesprivilegesandaccountcharacteristics• Multipleprivileges– Ex:SUPER, CREATE, ALTER, SELECT, INSERT

• Multiplelevels– Ex:Global,Database,Table,Column

• Accountcharacteristics– Ex:REQUIRE SSL, WITH MAX_QUERIES_PER_HOUR

11

Page 12: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

GRANTExamples

12

mysql> SHOW GRANTS;+---------------------------------------------------------------------+| Grants for root@localhost                                           |+---------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION || GRANT ALL PRIVILEGES ON `mysql`.* TO 'root'@'localhost'             || GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |+---------------------------------------------------------------------+3 rows in set (0.00 sec)

mysql> SHOW GRANTS FOR 'test'@'localhost';+--------------------------------------------------------+| Grants for test@localhost                              |+--------------------------------------------------------+| GRANT USAGE ON *.* TO 'test'@'localhost'               || GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'localhost' |+--------------------------------------------------------+2 rows in set (0.00 sec)

Page 13: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

REVOKE

• RemovestheprivilegesGRANTed– Doesnotextrapolate

• Doesnotremovetheuser• Ifnohostisgiven–%isused– Again-doesnotextrapolate

13

Page 14: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

REVOKEExamples

14

mysql> SHOW GRANTS FOR 'test'@'localhost';+--------------------------------------------------------+| Grants for test@localhost                              |+--------------------------------------------------------+| GRANT USAGE ON *.* TO 'test'@'localhost'               || GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'localhost' |+--------------------------------------------------------+2 rows in set (0.00 sec)

mysql> REVOKE DELETE ON test.t1 FROM 'test'@'localhost';ERROR 1147 (42000): There is no such grant defined for user 'test' on host 'localhost' on table 't1'

mysql> REVOKE USAGE ON *.* FROM 'test'@'localhost';Query OK, 0 rows affected (0.02 sec)

Page 15: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

DiagnosticData

15

Page 16: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SHOW

• MySQLspecificcommand• Commandsfor–Metadata– Statusinformation

• Metriccrap-ton

16

Page 17: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Examples Metadata

SHOWDATABASES SHOWTRIGGERS SHOWPLUGINS

SHOWCREATEPROCEDURE SHOWENGINES SHOWGLOBALVARIABLES

SHOWINDEXES SHOWGRANTS SHOWBINARYLOGS

17

Status

SHOWSLAVESTATUS SHOWOPENTABLES SHOWTABLESTATUS

SHOWENGINEINNODBSTATUS SHOWFULLPROCESSLIST SHOWGLOBALSTATUS

Page 18: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

INFORMATION_SCHEMA

• Mostlymetadata– PROCESSLIST– GLOBAL_VARIABLES / GLOBAL_STATUS– FILES / INNODB_SYS_TABLESPACES / INNODB_SYS_DATAFILES

• But– INNODB_TRX / INNODB_LOCKS / INNODB_LOCK_WAITS– INNODB_TEMP_TABLE_INFO

18

Page 19: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SYSSchema

• Includedin5.7.7– Installedbydefaultwith--initialize

• Originallyknownasps_helper–OriginallycreatedbyMarkLeith– http://www.markleith.co.uk/ps_helper– Canworkwith5.6-downloadfromGitHub• https://github.com/mysql/mysql-sys

• Easy,humanreadableaccesstoP_SandI_Sinfofortypicalusecases

19

Page 20: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SYSSchema

• Pairviews– Ex:host_summary_by_file_ioandx$host_summary_by_file_io

• Exampleviews– statements_with_full_table_scans– statements_with_runtimes_in_95th_percentile– io_by_thread_by_latency– memory_by_user_by_current_bytes– schema_redundent_indexes

(con’t)

20

Page 21: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Workbench-SYSReports

21

Page 22: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

PERFORMANCE_SCHEMA

• Monitorsatalowlevel• UsesPERFORMANCE_SCHEMAstorageengine• Available– Currentevents– Eventhistories/Eventsummations

• Configurationisdynamic• QueryusingSQL

22

Page 23: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

PERFORMANCE_SCHEMA

• UsingthePERFORMANCE_SCHEMA–Manual• General-https://dev.mysql.com/doc/refman/5.7/en/performance-schema.html• DiagnoseProblems-https://dev.mysql.com/doc/en/performance-schema-examples.html• QueryProfiling–https://dev.mysql.com/doc/en/performance-schema-query-profiling.html

– Blogposts• MySQLServerBlog-http://mysqlserverteam.com/category/mysql/performance-schema/

–Manypresentations/Webinars• MySQLOnDemandWebinars-https://www.mysql.com/news-and-events/on-demand-webinars/

(con’t)

23

Page 24: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

LogFiles

24

Page 25: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

ErrorLog

• --log-error[=file_name]• Defaultlocation:host_name.errindatadir• Examplesofinformationlogged– Startandstops&Criticalerrors– CrashedMyISAMtablesthatneedtobecheckedandrepaired– SomeOS’s-stacktraceifmysqldcrashes

• (5.7)log_syslogtosendMySQLerrorlogtosyslog• (5.7)log_error_verbosity

25

Page 26: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SlowQueryLog

• Firstlineofdefensefortuningqueries• Why?– Performanceusually

• Enableddynamicallyorwith--slow-query-log– Defaultfilelocation:host_name-slow.logindatadir– Canalsobeatable

• Multipleoptionsforcontrollingit• Usemsyqldumpslowutilitytoaggregatethedatainthelog

26

Page 27: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

GeneralQueryLog

• Generalrecord• Why–Orderinisimportant– Exactquerythatcamein–Minimalauditofwhataconnectiondid

• Enabledynamicallyorwith—general-log– Defaultlocation:host-name.loginthedatadir

• Multipleoptionsforcontrollingit

27

Page 28: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

BinaryLog

• Logsdatabasechangeevents• Why– Replication– Datarecovery

• Enablewith--log-bin• ALOTofoptions• “Read”withmysqlbinlog• Todisablebinaryloggingforthecurrentsession,usesql_log_bin

28

Page 29: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Backups

29

Page 30: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

BackupTypes

Logical

Physical

1

2

30

Page 31: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

LogicalBackups

• Saved– Logicalstructure– Content

• Machineindependent• Slower• Serverup/warm• Fullgranularity

31

Page 32: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

mysqldump

• Logical• Commandlineclient• Commonlyused• Generateseditabletextfiles• Veryflexible• Questionablescalability

32

Page 33: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Workbench-DataExport

33

Page 34: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

mysqlpump

• Logical• Similartomysqldump

• Alsocommandlineclient• Parallelprocessingtospeedupdumpprocess• DumpuseraccountswithCREATE USER / GRANT• Default:I_S, P_S, ndbinfoandSYSnotincluded• Reloading:fastersecondaryindexcreationinInnoDB

34

Page 35: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

SELECT… INTO OUTFILEandLOAD DATA INFILE

• Logical• MySQLcommand• Dataonly• Becareful!Youwantaconsistentbackup• Columnandlineterminatorscanbespecified• LOTSofdetails-seethemanual

35

Page 36: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

BackupTypes

Logical

Physical

1

2

36

Page 37: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

PhysicalBackup

• Rawcopies• Fasterthenlogical(ordersofmagnitude)• Compact• Filebasedgranularity• Usuallyserverisdownandlocked

37

Page 38: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

FilesystemSnapshot

• Physical• OSDependent• BasicSteps– FLUSH TABLES WITH READ LOCK– Takethesnapshot– UNLOCK TABLES– Copyfilesfromsnapshot

38

Page 39: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLEnterpriseBackup

• Officialphysicalbackupsolution–MySQL5.0to5.7– CanhandleallofficialMySQLsupportedstorageengines

• Multi-platform• Commandlineclient• BinlogandRelaylogbackup(Optional)• Fastrecovery

39

Page 40: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLEnterpriseBackup

• Features:– Partialandincrementalbackups– Streaming,directtotapeandsinglefilebackups– Throttlingandparallelbackupoperations– Compression– Encryption– Validation– SupportsTDE

(con’t)

40

Page 41: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

WorkbenchandMEB

41

Page 42: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Don’tForgetYourBinaryLogs

• Incrementalbackup– Holdschangessincethefullbackup-rollitforward

• Physicalfilecopy– RotatebinarylogwithFLUSH LOGS– Copythefile

• Logicalcopytoremoteserver– Staticorstreaming• mysqlbinlog --read-from-remote-server

42

Page 43: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

Questions?

43

Page 44: Rootconf admin101

Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|

MySQLAdministration101

LigayaTurmellePrincipalTechnicalSupportEngineer-MySQLligaya.turmelle@oracle.com@lig

Page 45: Rootconf admin101

Recommended