The Involuntary DBA Where there is Linux, you most likely will find MySQL or MariaDB. Like it or not, if you're working with Linux, you're a DBA.

Slides:



Advertisements
Similar presentations
MySQL DBA Spring Topics in the MySQL AB DBA Course I Describe the MySQL Architecture, general operational characteristics and resources utilized.
Advertisements

MySQL Access Privilege System
Database Optimization & Maintenance Tim Richard ECM Training Conference#dbwestECM Agenda SQL Configuration OnBase DB Planning Backups Integrity.
OpenVMS System Management A different perspective by Andy Park TrueBit b.v.
Cacti Workshop Tony Roman Agenda What is Cacti? The Origins of Cacti Large Installation Considerations Automation The Current.
Introduction to MySQL Administration.  Server startup and shutdown ◦ How to manually start and stop it from the command line ◦ How to arrange an automated.
Implementing ISA Server Caching. Caching Overview ISA Server supports caching as a way to improve the speed of retrieving information from the Internet.
Advanced Databases Basic Database Administration Guide to Oracle 10g 1.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Backup and Recovery Part 1.
Reliable MySQL Using Replication Issac Goldstand Mirimar Networks
AGENDA Tools used in SQL Server 2000 Graphical BOL Enterprise Manager Service Manager CLI Query Analyzer OSQL BCP.
Setting Up a Sandbox Presented by: Kevin Brunson Chief Technology Officer.
NovaBACKUP 10 xSP Technical Training By: Nathan Fouarge
Replication with MySQL 5.1 Ligaya Turmelle Senior Technical Support Engineer - MySQL
Anders Karlsson Principal Sales Engineer, MySQL MySQL Embedded - Getting started with libmysqld.
Chapter-4 Windows 2000 Professional Win2K Professional provides a very usable interface and was designed for use in the desktop PC. Microsoft server system.
Hands-On Microsoft Windows Server 2008 Chapter 5 Configuring, Managing, and Troubleshooting Resource Access.
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 14. Introduction to MySQL Administration and the MySQL Data Directory Topics: –Overview.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
CHAPTER 21 Automating Jobs. Introduction to Automating Jobs DBAs rely heavily on automating jobs. DBAs cannot be effective without automation. Listed.
MySQL Would You Like Some Transactions With That Table?
Copyright ®xSpring Pte Ltd, All rights reserved Versions DateVersionDescriptionAuthor May First version. Modified from Enterprise edition.NBL.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 15. General MySQL Administration Topics: –Securing a New MySQL Installation –MySQL Server.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database MySQL Cluster: An introduction Geert Vanderkelen MySQL AB.
Copyright 2002, Jeremy Zawodny MySQL Backup & Recovery O’Reilly Open Source Convention Jeremy Zawodny Yahoo! Finance July 24th, 2002.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
A Brief Documentation.  Provides basic information about connection, server, and client.
DATABASE ADMINISTRATION ECS Release 5 Training. 625-CD Objectives Create new database devices Allocate disk space Maintain database segments.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
MySQL Gubbins Richard Sinclair HepSysMan – 11/05/2012.
© 2009/2010 Pythian 1 mysqltuner 1.0 Author: Major Hayden Quick sanity check: » Status/system variables » Memory, Architecture, Tables Not all recommendations.
Database server Campus-Booster ID : ****** Copyright © SUPINFO. All rights reserved MySQL.
MISSION CRITICAL COMPUTING Siebel Database Considerations.
SQL SERVER 2008 Installation Guide A Step by Step Guide Prepared by Hassan Tariq.
Hyperion Artifact Life Cycle Management Agenda  Overview  Demo  Tips & Tricks  Takeaways  Queries.
2 Copyright © 2006, Oracle. All rights reserved. Configuring Recovery Manager.
Intro To Oracle :part 1 1.Save your Memory Usage & Performance. 2.Oracle Login ways. 3.Adding Database to DB Trees. 4.How to Create your own user(schema).
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
1 BCS 4 th Semester. Step 1: Download SQL Server 2005 Express Edition Version Feature SQL Server 2005 Express Edition SP1 SQL Server 2005 Express Edition.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
1 Backup and Replication Integration Techniques MySQL 6.0 Lars Thalmann, PhD Mats Kindahl, PhD Chuck Bell, PhD Replication and Backup Team Sun Microsystems.
CC ICT-SUD Installation and configuration
CHAP-1 INTRODUCTION TO LINUX 1 Created By: Asst. Prof. Ashish Shah, J.M.Patel College of Commerce.
DBMS ● What are they? ● Why used ● Examples? – Oracle – Access – MySQL – Postgres – SQLServer – Sqlite.
Calgary Oracle User Group
A Better mysqltuner Sheeri K. Cabral The Pythian Group
SQL Database Management
DBMS Programs MS SQL Server & MySQL
Fundamental of Databases
Review of IT General Controls
Jean-Philippe Baud, IT-GD, CERN November 2007
Would You Like Some Transactions With That Table?
Table spaces.
Tips for SQL Server Performance and Resiliency
SQL Replication for RCSQL 4.5
Recovery Catalog Creation and Maintenance
SQL and SQL*Plus Interaction
Introduction to Operating Systems
MCTS Guide to Microsoft Windows 7
Is 221: Database Administration
MyRocks at Facebook and Roadmaps
MySQL Cloud Service 1Z0-320 VCE
1Z0-888 Oracle - VCE Questions
Tips for SQL Server Performance and Resiliency
Configuring Internet-related services
Accounting Accounting collects information about users and processes
MAINTAINING SERVER AVAILIBILITY
Performing Database Recovery
Presentation transcript:

The Involuntary DBA Where there is Linux, you most likely will find MySQL or MariaDB. Like it or not, if you're working with Linux, you're a DBA.

Installation Use your distro's package manager (e.g. apt or yum) Download http://www.mysql.com/downloads/https://downloads .mariadb.org/ Current GA Versions MySQL Community Server 5.6.17 MariaDB 10.0.10 MySQL or MariaDB is probably already running and being used for something in your network, but if you're asked to install it, you may have to decide between the two. MySQL and MariaDB are basically the same. MariaDB is just the MySQL founder Monty Widenius's response to Oracle's acquisition and perceived closing of the open source. If you want Oracle's support, use MySQL. If you want features that Oracle is allegedly withholding from the Community, use MariaDB. You can also pay SkySQL for support of MariaDB. To install either, just use the package manager for you favorite Linux distro. Then you'll be able to keep your binaries up-to-date. The current GA version of MySQL is 5.6.17 and of MariaDB is 10.0.10.

Resetting the root password The SQL UPDATE mysql.user SET Password = PASSWORD('blah') WHERE User='root'; FLUSH PRIVILEGES; Running the SQL on startup # ./mysqld_safe --init-file=/home/root/mysql/reset_mysql_root_password.sql & If you've stumbled on a rogue installation of MySQL or MariaDB, you probably won't be able to log in, at least not with enough privileges to properly maintain and configure the system. Assuming you have OS access to stop and start the mysql service, stop the service. Then save the SQL above to a file, and invoke the file when starting the service manually with 'mysqld_safe'. Be sure that the user under which 'mysqld' is running has access to this file. Once you've verified that you can log in as root, restart the service normally. You can use this technique with any account, but the idea is that 'root' has the all important 'WITH GRANT OPTION' needed to create and change other accounts.

What's Where Binaries /usr/sbin/mysld /usr/bin/mysql /usr/bin/mysqld_safe Start up /init.d/mysql/mysql.server Configuration /etc/mysql/my.cnf Data files /var/lib/mysql Log files /var/log/mysql One way or another, MySQL or MariaDB is installed. Here's a basic guide to where the package manager put things by default. From the DBA's point of view, there's no need to touch the binaries or the start-up scripts. You will want to spend some time modifying 'my.cnf', however. In that file you can change the location of the data files and log files, possibly putting them on different storage subsystems for optimal performance. By default, all logs and data live in '/var/lib/mysql'. First enable the error log and put it in '/var/log/mysql'.You will also want to enable transaction logs and put them there as well.

Configuration - Memory Allocate as much memory as possible Boost innodb_buffer_pool and for InnoDB innodb_buffer_pool_size= up to 80% of RAM Boost key_buffer_size for MyISAM if used SELECT TABLE_SCHEMA, TABLE_NAME, ENGINE FROM information_schema.tables WHERE TABLE_SCHEMA <> 'mysql' AND ENGINE = 'MyISAM'; key_buffer_size= up to 25% of a RAM Although they can be changed dynamically, most critical MySQL configuration parameters persists in the file 'my.cnf'. On startup the daemon looks for this file in '/etc/' and then '/etc/mysql/'. Given the default configuration, there are a few parameters, you should tweak. First, give the database as much memory as you can by setting 'innodb_buffer_pool_size', if you're using the InnoDB storage engine, and 'key_buffer_size', if you're using the MyISAM storage engine. By default MySQL uses InnoDB for all new tables. The query above will tell you where you're using MyISAM if at all.

Configuration – Storage Logs and Data datadir = /var/log/mysql innodb_log_file_size = lesser of 50% of innodb_buffer_pool_size or 1GB Manage logs for loading Turn off binary (transaction) logging by commenting out log location # log_bin = /var/log/mysql/mysql-bin.log Manage logs for durability (point-in-time restore) Turn on binary logging by uncommenting log location and restarting. log_bin = /var/log/mysql/mysql-bin.log expire_logs_day=2 Move undo logs to disk subsystem that's different from the one for data files innodb_log_group_home_dir = /var/log/mysql/ Enable error logging log_error=/var/log/mysql/error.log After memory, the specification of logs and data files has the greatest impact on performance and durability. You can use 'datadir' to put data files on the fastest disk subsystem available. Assuming you're using InnoDB, specify 'innodb_log_file_size' as half the memory allocated to the innodb buffer pool up to 1GB. The larger the file the longer mysql can go without writing data to the data files, thereby reducing disk IO contention. To further reduce disk IO contention during initial database loads, turn off transaction logging by commenting out or omitting 'log_bin' which specifies the location of the transaction logs, called 'binary' logs in MySQL. Once the load is complete, re-enable logging so that the database can be rolled forward to a point in time after the last full backup. If backups run nightly, you can set these logs to expire after a minimum of two days (expire_logs_days=2). Ideally, these logs are stored on a set of disks different from the ones that contain your data. Similarly, you may want to move your InnoDB log file to a set of disks different from the ones that contain your data, using 'innodb_log_group_home_dir'. Finally, remember to enable error logging with 'log_error'.

Backups Create a database user for backups GRANT SELECT, RELOAD, LOCK TABLES, REPLICATION CLIENT, SHOW VIEW, TRIGGER ON *.* TO 'backup'@'localhost' IDENTIFIED BY PASSWORD('blah'); Use mysqldump with --master-data=2 and --single- transaction mysqldump -u backup -pblah --master-data=2 -- single-transaction --all-databases --log- error=mysqldump_error.log > mysqldump.sql Create bash script that runs 'mysqldump' Add line that copies 'mysqldump.sql' and new transaction logs off-site log_bin = /var/log/mysql/mysql-bin.log Schedule cron job to run the script at least daily Using your 'root' account create a user that has the privileges needed to perform full backups. Then create a 'bash' script that executes the command 'mysqldump' with the credentials added. Other important parameters are 'master-data=2', which will add the co-ordinates of the binary (transaction) log at the time of the backup and 'single-transaction', which will dump all InnoDB tables in a state consistent with coordinates of the binary log. Assuming you're using InnoDB, this command will produce a backup that you can use with binary logs to roll forward to a point in time. Ideally, add to this bash script a line that copies the resulting backup and binary logs specified by 'log_bin' to another system preferably at another data center for DR. Then create a cron job to run the script at least daily.

Monitoring Create database use for monitoring GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'monitor'@'localhost' IDENTIFIED BY PASSWORD('blah'); Use cron with 'mysqladmin' to monitor connections mysqladmin -u monitor -pblah ping mysqld is alive mysqladmin -u monitor -pblah status Uptime: 32 Threads: 1 Questions: 1 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.031 mysqladmin -u monitor -pblah variable | grep max_connections | max_connections | 100 If ping != “mysqld is alive” or (Threads/max_connections)*100 > 75, then send an alert Use Nagios or something comparable if you have it Monitor the usual suspects, like disk space, CPU usage and memory usage on the system running MySQL Using your 'root' account create a user that has the privileges needed to monitor server status. Then create a bash script that runs 'mysqladmin' with various arguments and evaluates the output. Based on that output, send alerts. The key metrics to monitor are whether or not 'mysqld' is running and whether or not threads connected is within 75% of the the maximum number of connections that database allows. The latter check will also verify connectivity. Any monitoring system, such as Nagios, Hyperic or Zabbix, can implement these checks and alerts and many, many more. Ganglia is also usefull graphing performance over time.

Now You Know the Basics Installation Configuration A little user access control Backups Monitoring Both MySQL and MariaDB documentation is excellent http://dev.mysql.com/doc/https://mariadb.com/kb/en /mariadb-documentation/