1. Trang chủ
  2. » Ngoại Ngữ

MySql High Availability Class Part 1

214 359 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 214
Dung lượng 2,32 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

MySQL High Availability iii Conventions Used in This Training Guide This training guide uses certain typographical conventions: • TEXT IN THIS STYLE is used for SQL statements; database

Trang 1

MySQL High Availability

Trang 2

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Trang 3

MySQL High Availability

i

MySQL High Availability

This is the training guide for the MySQL High Availability training course This training guide was developed using the

MySQL 6.2 Cluster Carrier Grade edition

Sun Microsystems would like to thank the many individuals that played a part in bringing this training material to the numerous students who will benefit from the knowledge and effort that each of these contributors put into the training Even though there were a large number of contributions from many Sun Microsystems (formerly MySQL) personnel, the following list of contributors played a vital role in developing this material and ensuring that its contents were accurate, timely and most of all presented in a way that would benefit those that are utilizing it for the benefit of improving their skills with MySQL

Harrison Fisk, Course Designer, Subject Matter Expert

Max Mether, Lead Project Manager, Subject Matter Expert

Lars Thalmann, Subject Matter Expert

Mikael Ronström, Subject Matter Expert

Bernhard Ocklin, Subject Matter Expert

Morgan Tocker, Subject Matter Expert

Jeff Gorton, Course Editor

MySQL High Availability Training Guide

Copyright © 2008 by Sun Microsystems, Inc

All rights reserved No part of this training guide shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without the written permission of Sun Microsystems, Inc No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this training guide, Sun Microsystems and the associated contributors assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein

First Printing: August 2008

Trademarks

The copyright to this training guide is owned by Sun Microsystems MySQL® and the MySQL logo are registered trademarks of the Sun Microsystems MySQL product Other trademarks and registered trademarks referred to in this manual are the property of their respective owners, and are used for identification purposes only

Warning and Disclaimers

Every effort has been made to make this training guide as complete and accurate as possible to meet the needs of the training herein, but no warranty or fitness is implied The information provided is on an “as is” basis

Trang 4

MySQL High Availability

Trang 5

MySQL High Availability

iii

Conventions Used in This Training Guide

This training guide uses certain typographical conventions:

TEXT IN THIS STYLE is used for SQL statements; database, table, and column names; program listings and source code; and environment variables Example: “To reload the grant tables, use the FLUSH PRIVILEGES statement.”

Text in this style indicates input that you type in examples

• Text in this style indicates the names of executable programs and scripts, examples being mysql (the MySQL command line client program) and mysqld (the MySQL server executable)

Text in this style is used for variable input for which you should substitute a value of your own

choosing

• Filenames and directory names are written like this: “The global my.cnf file is located in the /etc directory.”

• Character sequences are written like this: “To specify a wildcard, use the '%' character.”

• Text in this style is used for emphasis

When commands are shown that are meant to be executed from within a particular program, the prompt shown preceding the command indicates which command to use For example, shell> indicates a command that you execute from your login shell, and mysql> indicates a statement that you execute from the mysql client program:

shell> type a shell command here

mysql> type a mysql statement here

The “shell” is your command interpreter On Linux, this is typically a program such as sh, csh, or bash On Windows, the equivalent program is command.com or cmd.exe, typically run in a console window

When you enter a command or statement shown in an example, do not type the prompt shown in the example

Database, table, and column names must often be substituted into statements To indicate that such substitution is

necessary, this manual uses db_name, tbl_name, and col_name For example, you might see a statement like this:

mysql> SELECT col_name FROM db_name.tbl_name;

This means that if you were to enter a similar statement, you would supply your own database, table, and column names, perhaps like this:

mysql> SELECT author_name FROM biblio_db.author_list;

SQL keywords are not case sensitive and may be written in any lettercase This training guide uses uppercase

In syntax descriptions, square brackets ('[' and ']') indicate optional words or clauses For example, in the following statement, IF EXISTS is optional:

DROP TABLE [IF EXISTS] tbl_name

When a syntax element consists of a number of alternatives, the alternatives are separated by vertical bars ('|') When one member from a set of choices may be chosen, the alternatives are listed within square brackets ('[' and ']'):

TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)

When one member from a set of choices must be chosen, the alternatives are listed within braces ('{' and '}'):

{DESCRIBE | DESC} tbl_name [col_name | wild]

An ellipsis ( ) indicates the omission of a section of a statement, typically to provide a shorter version of more

complex syntax For example, INSERT SELECT is shorthand for the form of INSERT statement that is followed

by a SELECT statement

An ellipsis can also indicate that the preceding syntax element of a statement may be repeated In the following example, multiple reset_option values may be given, with each of those after the first preceded by commas:

RESET reset_option [,reset_option]

Commands for setting shell variables are shown using Bourne shell syntax For example, the sequence to set the CC environment variable and run the configure command looks like this in Bourne shell syntax:

shell> CC=gcc /configure

If you are using csh or tcsh, you must issue commands somewhat differently:

shell> setenv CC gcc and shell> /configure

Trang 6

MySQL High Availability

iv

Supporting Images Used in This Training Guide

The following is a summary of the standard images used in this manual to support the instruction:

IMAGE NAME DESCRIPTION

Preparation This image is used to describe the

steps required to be completed prior

to performing a hands-on exercise

Written Exam This image is used to identify that

the student is going to be tested upon the material previously presented in the instructional material

InLine Lab Throughout the course the instructor

will conduct labs in line with the instruction, which are designed to help you to understand the “nuts and bolts” (inner-workings) of the topic

Further Practice Lab

This image is used to convey to the student that there is a final exercise to complete prior to the completion of the chapter

Student Notes This image identifies an area on a

page designated for students to write notes associated with the class

Slide Number Boxes

This image is used throughout the course guide to indicate the existence and number of a corresponding instruction slide

Trang 7

MySQL High Availability

v

COURSE OBJECTIVES

This course is designed for experienced database administrators and system architects that want to analyze and form

a basis of understanding different high availability options, including clustering and replication solutions within MySQL This course will provide the tools required to make the decision of what high availability solution is appropriate and how to implement a system with the correct design

At the completion of this course, you should be able to:

• Examine the design and limitations of MySQL replication

• Describe the design and limitations around a shared-disk fail over solution

• Analyze the design and limitations of MySQL cluster

• Understand the differences with third-party clustering solutions, such as m/cluster

• Develop a plan to implement the appropriate high availability solution

• Analyze the performance impact of a high availability decision

• Recognize the business decision side of the solutions, such as cost and risk

• Describe the future development path of the different solutions

• Discuss the different fail over solutions inherit in a high availability design

• Understand different cluster setups depending upon operating system choices, such as LVM, Windows Cluster Agent, Veritas Cluster Agent, etc

• Explore the impact of different backup solutions on highly available solutions

• Identify the effects of different maintenance tasks and how to maintain high availability while performing these operations

Trang 8

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Trang 9

MySQL High Availability

1.3.1 MySQL Database Products 1-4

1.3.2 MySQL GUI Tools 1-6

1.3.3 Other MySQL Tools 1-6

1.6 Supported Operating Systems 1-11

1.7 MySQL Certification Program 1-12

1.8 Training Curriculum Paths 1-13

2.4.3 Veritas Cluster Agent 2-9

2.4.4 Red Hat Cluster Suite 2-9

3.3.1 Statement Based Binary Logging 3-5

3.3.2 Row based binary logging 3-5

3.3.3 Row Based vs Statement Based Binary Logging 3-6

3.4 Replication threads and files 3-9

Trang 10

MySQL High Availability

3.6 Monitoring MySQL Replication 3-13

3.6.1 Error Log 3-14

3.6.2 Replication Slave I/O Thread States 3-15

3.6.3 Replication Slave SQL Thread States 3-16

3.7 Advantages and Disadvantages of MySQL Replication 3-20

3.8 Advanced Replication Topologies 3-21

3.10.1 Different Storage Engines 3-29

3.10.2 Different Startup Variables 3-29

3.10.3 Different Logical Structure 3-30

4.2.5 Limitations of MySQL Cluster 4-6

4.2.6 Common use cases 4-6

4.3 Setup of MySQL Cluster 4-8

4.3.1 Cluster Configuration 4-8

4.3.1.1 Other Configuration Files 4-10

4.3.2 Starting the Cluster 4-12

4.4 Managing the Cluster 4-13

4.4.1 Logging 4-15

4.5 Cluster Asynchronous Replication 4-18

4.6 Cluster Pros and Cons 4-19

5.5.1 Pros and Cons 5-8

5.5.2 Combining with Replication 5-9

6.2.2 Access Continuent uni/cluster with MySQL 6-2

6.2.3 Inside the controller 6-3

6.3 DRBD Details 6-5

6.3.1 DRBD Compared to Other Technologies 6-5

6.3.2 Configuring DRBD for MySQL 6-7

Trang 11

MySQL High Availability

6.4 DRBD and Heartbeat 6-9

6.4.1 Configuring DRBD and Heartbeat 6-9

6.4.2 Example failover scenarios 6-10

6.4.3 Node Fencing and STONITH devices 6-11

7.3.4 File system snapshots 7-7

7.3.5 Summary of full backup options 7-8

Appendix A Introduction to Linux A-1

Appendix B Basic vi commands B-1

Appendix C Test Question Keys C-1

Appendix D Further Practice Lab Solutions D-1

Appendix E Sequoia Clustering E-1

Trang 12

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Trang 13

MySQL High Availability

Trang 14

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Trang 15

MySQL High Availability

Page 1-1

_

_ _

1 INTRODUCTION

1.1 Learning Objectives

This chapter introduces you to MySQL products and services In this chapter, you will learn:

• The origin and status of the MySQL company

• The MySQL products and professional services that are available

• The definition of MySQL Enterprise and MySQL Community and their differences

• Which operating systems are currently supported

• What is available through the MySQL Community web page

• What is the MySQL Certification program

• Which courses are available to you after this course

• How to install the MySQL Cluster Carrier Grade server on a Linux operating system

Trang 16

MySQL High Availability

Page 1-2

_

_

_

1.2 The MySQL Overview

MySQL is a Relational Database Management System

(RDBMS) that was originally developed by ‘MySQL

AB’ It was (and continues to be) developed and marketed

as a family of high performance, affordable database

servers and tools Contributing to building the

mission-critical, high-volume systems and products worldwide is

what makes MySQL the world’s most popular open

source database, as well as its reliability, excellent

performance and ease of use

MySQL is not only the world’s most popular open source

database It is also the fastest growing database in the

industry, with up to 60,000 downloads per day, ranging

from large corporations to specialized embedded

applications

MySQL AB was founded in Sweden by two Swedes and

a Finn: David Axmark, Allan Larsson and Michael

"Monty" Widenius who have worked together since the

80's MySQL AB (Swedish for “Inc.”) was the sole owner of the MySQL server source code, the MySQL trademark and the mysql.com domain worldwide

Sun Acquisition:

In early 2008, MySQL AB was acquired by Sun Microsystems, Inc., giving the MySQL product line the considerable resources of a formidable company Together, Sun and MySQL will now provide global enterprise-class support 24x7x365 Our enterprise-class customers worldwide can now take advantage of our market-leading open source database on their choice of hardware, operating system and language with up to a

90% lower total cost of ownership than many traditional database solutions

MySQL has always been, and will continue to be, a strong supporter of the open source philosophy and the open source community, and strives to work with partners who share the same values and mindset This will be no different within Sun Sun is a world-leader in open source, with products and technologies such as Java, OpenSolaris, Open Office, NetBeans, OpenSparc and many more

The MySQL mission is still the same

Make superior database software available and affordable to all!

9

MySQL is installed on every continent in the world (Yes, even Antarctica!)

Trang 17

MySQL High Availability

Page 1-3

_

_ _

1.2.1 MySQL Partners

MySQL has had the privilege of forming alliances with excellent partners and attracting some of the most impressive customers in the industry! When you join our ranks, you are joining a winning team with a wide variety of MySQL implementations It never ceases to amaze us, the innovative and powerful ways in which

our tools are being used To name only a few;

Education

• AUF (Agence Universitaire de la Francophonie)

• University of California, Berkeley

World Wide Web

Trang 18

MySQL High Availability

Page 1-4

_

_ _

1.3 MySQL Products

1.3.1 MySQL Database Products

Sun provides MySQL database products to meet the needs of ISV/OEM, Enterprise, and Community Server users MySQL database products are recognized for superior ease of use, performance, and reliability

• MySQL Enterprise Server

o The most reliable, secure and up-to-date version of the world's most popular open source database for cost-effectively delivering E-commerce, Online Transaction Processing (OLTP), and multi-

terabyte Data Warehousing applications (Available only with the MySQL Enterprise subscription)

• MySQL Community Server

o The MySQL database server for open source developers and technology enthusiasts who want to get started with MySQL Supported by the large MySQL open source community Under the General Public License (GPL), benefits to the open source community include a commercial-grade framework that is free of charge

• MySQL Embedded Database

o The most popular choice for OEMs/ISVs who want to cost-effectively embed or bundle a reliable and high-performance relational database

Trang 19

MySQL High Availability

Page 1-5

_

_ _

MySQL Enterprise

A comprehensive set of enterprise-grade software, support and services to ensure the

highest levels of reliability, security and uptime As a proactive service that helps you

eliminate problems before they occur, it gives you everything you need in a single, unified

offering to successfully develop and deploy business critical applications using MySQL

• MySQL Enterprise Server

o The most reliable, secure and up-to-date version of the world's most popular open source database for cost-effectively delivering E-commerce, Online Transaction Processing (OLTP), and multi-terabyte Data Warehousing applications

• MySQL Enterprise Monitor

o Services to ensure the maximum quality, uptime, and performance of MySQL Enterprise systems

Trang 20

MySQL High Availability

Page 1-6

_

_ _

1.3.2 MySQL GUI Tools

The MySQL GUI Tools form a comprehensive graphical user interface to your MySQL database These easy to use graphical tools enable database Developers and Database Administrators

(DBAs) to be more productive

• MySQL Migration Toolkit

o Using a wizard-driven interface, the MySQL Migration Toolkit implements a proven methodology and walks you through the necessary steps to successfully complete a database migration project

• MySQL Administrator

o A powerful graphical administration console that enables you to easily administer your MySQL environment and gain significantly better visibility into how your databases are operating

• MySQL Query Browser

o An extremely user-friendly graphical tool for creating, executing, and optimizing SQL queries for your MySQL Database Server

Bundled Tools

The MySQL graphical user interface (GUI) tools discussed here come bundled together when downloaded from the MySQL website

1.3.3 Other MySQL Tools

MySQL has also developed additional tools to assist in the use of the MySQL server:

• MySQL Workbench

o MySQL Workbench is a visual database design tool developed by MySQL It is the highly anticipated successor application of the DBDesigner4 project MySQL Workbench is currently available for Microsoft Windows in a GPL licensed open source edition as well as a low-priced standard edition which includes additional time saving features for professionals

• MySQL Proxy

o MySQL Proxy is a simple program that sits between your client and MySQL server(s) that can monitor, analyze or transform their communication Its flexibility allows for unlimited uses; common ones include: load balancing;

failover; query analysis; query filtering and modification;

and many more

Trang 21

MySQL High Availability

Page 1-7

_

_ _

1.3.5 Solutions for Embedding MySQL

Apart from these Connectors that provide client side connectivity, MySQL also provides libraries to embed a MySQL database server within a program Currently the following solutions can be used to embed MySQL:

Trang 22

MySQL High Availability

Page 1-8

_

_ _

Using industry best practices and proven methodologies, your MySQL certified consultant will help you deliver on-time and on-budget

o Community Articles (http:/ / dev.mysql.com/ tech-resources/ articles)

o Bugs Database (http:/ / bugs.mysql.com/ )

o No direct access to support engineers

o PlanetMySQL Blogs (http:/ / www.planetmysql.org/ )

o MySQL Reference Manuals (http:/ / dev.mysql.com/ doc)

o MySQLForge (http:/ / forge.mysql.com/ )

• Purchased support

o Enterprise subscription

o Support for MySQL Cluster

o Support for MySQL Embedded (OEM/ISV)

o Online Knowledge Base

Trang 23

MySQL High Availability

Page 1-9

_

_ _

1.5 Community vs Enterprise

There are many things to consider when choosing between using the Community server versus the Enterprise server subscription The following charts summarize the uses and requirements for each and do a comparison to assist in understanding the differences

How does the MySQL Community work?

The left side of this chart shows what MySQL provides to the user community On the right side, is what our user

community provides back to us, and to the entire community

20

MySQL Community

New Ideas

Bug Reports…

Help, Forums…

Spread MySQL Goodwill…

Code Contributions…

Open Source

Database

Server Minimum Two

Trang 24

MySQL High Availability

Page 1-10

_

_ _

How does the MySQL Enterprise work?

The above chart shows the progression of code feature implementation into the MySQL Enterprise Server; from user input, to MySQL Community Server placement/testing, to further improvements which are placed in the MySQL

Enterprise Server product

MySQL Enterprise Server

MySQL Community Server

Community / Third Party Development

• Third party contributions

Community Purpose Enterprise Grade

• Delivery of Community and Customer

Recommendations

• Acceptance/Rejection of Community Code Contributions

• Community Testing and Validation

• “As Needed” Release Schedule, including Bug Fixes and New Features

• Selected Feature Set for Enterprise Installations

• Predictable Service Pack Schedule

• Strong Internal Quality Assurance Testing

• External Quality Assurance Testing

• Certified for Popular Platforms and Applications

• Formal Technical Support

Many Ideas / Submissions

Selected Submissions Become Features

Mature Features Only

Trang 25

MySQL High Availability

Page 1-11

_

_ _

1.6 Supported Operating Systems

MySQL runs on more than 20 platforms, giving users the kind of flexibility that

puts them in control Windows, Linux and Solaris are the most popular operating

systems for running MySQL Versions of MySQL are currently available for the

following operating systems:

• Windows (multiple) • Mac OS/X • Open BSD

This list is continually being updated For the most current information, please check our website:

http:/ / www.mysql.com Source code and special builds are also available

Trang 26

MySQL High Availability

Page 1-12

_

_ _

1.7 MySQL Certification Program

The MySQL Certification Program is a high quality certification program that provides developers and DBAs with the credentials to prove they have the knowledge, experience and skills to use and manage MySQL Server MySQL

will offer two tiers of certification for MySQL 5.0 (most recent version):

1 Certified MySQL 5.0 Developer (CMDEV) - proves mastery of the fundamental skills of using MySQL

including creating and using databases and tables, inserting, modifying, deleting, and retrieving data

2 Certified MySQL 5.0 Database Administrator (CMDBA) - proves mastery of the ability to manage

MySQL Server including such advanced areas of database management, installation, security, disaster prevention and optimization

3 Certified MySQL Cluster DBA (CMCDBA) - part of the DBA track which represents an advancement

level exceeding CMDBA certification In order to attain CMCDBA certification, you must attain CMDBA certification and pass one CMCDBA exam

The chart above shows the curriculum path for Developers, Database Administrators and Cluster They show the current course available for certification preparation, the respective exams, and the receipt of the certification

Certification web page

For more information on the certification program and the content of the exams, see our Certification web page;

http:/ / www.mysql.com/ certification/

Exam administration

All exams are administered through one of more than 3,000 Pearson VUE testing centers available world-wide And through the Linux Professional Institute proctor network Visit the MySQL certification webpage, online forum or email certification@mysql.com for more information

Trang 27

MySQL High Availability

Page 1-13

_

_ _

1.8 Training Curriculum Paths

MySQL offers the most comprehensive set of MySQL training courses that enable the building of database solutions and competitiveness now and into the future In addition to our open courses, we also offer in-house training

The MySQL training services staff has put together great courses designed for success, and an excellent training path for each individual to reach his/her training goals There are two tiers to the curriculum paths:

Developer path

• Introduction courses

o Developing Dynamic Web Applications with MySQL and PHP –This course will provide the

tools needed for the development of dynamic web application This course takes the student from the basics to the advanced features in four hands-on, heavy duty training days Each student will have

the opportunity to build a real-world application during the course Prerequisites: Basic experience with designing HTML pages including HTML forms and experience with any programming

language Basic PHP skills 4 days in length

o MySQL for Beginners – This course covers the fundamentals of SQL and relational databases,

using MySQL as a teaching tool Prerequisites: Basic computer literacy is required Previous experience with any command-line program (such as MS-DOS or the MS Windows command

prompt) is beneficial 4 Days in length

• Intermediate courses

o MySQL for Developers - This instructor-led course is designed for students planning on developing

applications that make use of MySQL 5.0 (and higher) This course covers essential SQL statements for data design, querying, and programming In addition, it will prepare students for the MySQL

Developer certification Prerequisites: Some experience with Relational Databases and SQL 5 days

in length

o MySQL 5.0 Upgrading and New Features – This instructor-led course will provide in-depth

knowledge needed to become proficient using MySQL 5.0 This training course will provide quality

time both on the topic, hands-on labs and with the expert instructor Prerequisites: Existing MySQL

users who want to become proficient using MySQL 5.0 3 Days in length

• Advanced courses

o Advanced Stored Procedures – This instructor-led course with focus on labs is designed to teach

you how to maximize the use of stored procedures along with the knowledge to discern when an

application should contain stored procedures and when they should not 2 Days in length

• Virtual courses

o MySQL Database Design - This instructor-led virtual course is designed for developers who wish

to use sound database design principles while creating MySQL databases This course will prepare each student with the skills needed to create databases that maintain data consistency, data integrity and data accuracy while improving SQL efficiency Students will be provided with demonstrations

that will support their ability to apply their learning immediately upon completion of the training 4

Trang 28

MySQL High Availability

Page 1-14

_

_ _

Database Administrator (DBA) Path

• Introduction courses

o MySQL for Beginners – This course covers the fundamentals of SQL and relational databases,

using MySQL as a teaching tool Prerequisites: Basic computer literacy is required Previous

experience with any command-line program (such as MS-DOS) is beneficial 4 Days in length

• Intermediate courses

o MySQL 5.0 Upgrading and New Features – This instructor-led course will provide in-depth

knowledge needed to become proficient using MySQL 5.0 This training course will provide quality

time both on the topic, hands-on labs and with the expert instructor Prerequisites: Existing MySQL

users who want to become proficient using MySQL 5.0 3 Days in length

o MySQL for Database Administrators – This course covers essential DBA tasks such as,

installation and upgrading, user management, disaster recovery, and optimization In addition, it will

prepare students for the MySQL Database Administrator certification Prerequisites: Some

experience with Relational Databases and SQL 5 days in length

• Advanced courses

o MySQL Performance Tuning – The MySQL Performance Tuning course is designed for Database

Administrators and others who wish to monitor and tune MySQL This course will prepare each student with the skills needed to utilize tools for monitoring, evaluating and tuning Students will evaluate the architecture, learn to use the tools, configure the database for performance, tune application and SQL code, tune the server, examine the storage engines, assess the application

architecture, and learn general tuning concepts 4 Days in Length

o MySQL Cluster - Learn how to install and configure the cluster nodes to ensure high availability

Also learn about all of the high availability features that are implemented in the new storage engine for the MySQL Cluster — fail-over between storage nodes, network partitioning protocol, two-phase

commit and much more Prerequisites: Attendance to the MySQL for Database Administrators or an

equivalent mastery of database concepts, SQL and the MySQL server 3 Days in length

Note: This is the sole course offering in the Cluster certification (CMCDBA) path

o MySQL High Availability - This course is designed for experienced database administrators and

system architects that want to analyze and form a basis of understanding different high availability options, including clustering and replication solutions within MySQL This course will provide the tools required to make the decision of what high availability solution is appropriate and how to

implement a system with the correct design 3 days in length

Trang 29

MySQL High Availability

Page 1-15

_

_ _

1.9 MySQL Website

Everything you ever wanted to know about MySQL and more can be found on our website:

http:/ / www.mysql.com From the home page, you may navigate the web site with the tabs (pull-down menus) across the top, the menu along the left side, and/or the many links on the page

Trang 30

MySQL High Availability

Page 1-16

_

_ _

1.9.1 MySQL Community Web Page

The MySQL Community web page is located at http:/ / dev.mysql.com and is maintained by Sun Microsystems, Inc/ This is the main support tool for the MySQL open source community and can provide valuable insight for Enterprise users also Information such as the following can be found:

• Product Downloads

o MySQL Products are available under the "dual licensing" model Under this model, users may choose to use MySQL products under the free software/open source GNU General Public License (commonly known as the "GPL") or under a commercial license ISVs and Resellers, who are embedding and reselling MySQL as part of their own commercial solutions, can purchase a MySQL commercial license

• MySQL Forums

o Community and Enterprise Users alike can utilize the MySQL forums to interact with each other and the staff of Sun Microsystems, Inc The forums are a great way to continue the community support for MySQL and keep both Sun Microsystems, Inc and the MySQL users in constant communication thus making MySQL even better

• Mailing Lists

o MySQL provides its customers, both community and enterprise users, a way to keep up with the latest updates to MySQL software along with many other MySQL specific issues through the use of mailing lists Mailing lists are similar to the forums but with the option to receive discussions and information about MySQL through a users local mail client If a user cannot get an answer for their questions from one of our mailing lists, one option is to pay for support from Sun Microsystems, Inc., which puts the user in direct contact with MySQL developers

Trang 31

MySQL High Availability

Page 1-17

_

_ _

Lab 1-A

In this exercise you will review some web pages on the MySQL website Make sure that your web

browser window is displayed

1 Click in the text area of the Address/Location

Toolbar

The URL currently listed will be selected

2 In the toolbar text area, type:

www.mysql.com

The MySQL Homepage is displayed

3 Click on the Products tab located at the top of

the MySQL home page

Scroll down the list to review the various product

information provided

A list of currently available products will appear, with links for further information and downloads

4 Review the details of the new MySQL

Enterprise program, by clicking on the Learn More >> link

MySQL® Enterprise™ provides a comprehensive set of enterprise-grade software, support and services directly from the developers of MySQL to ensure the highest levels of reliability, security and uptime

5 Click on the Services tab located at the top of

the MySQL home page

A list of currently available services will appear, with links for further information and downloads

6 Review the details of the new MySQL

Training program, by clicking on the Learn More >> link

Featured information on this page will be updated

periodically For specific Training sub-topics

select one of the links in the sub-menu in the left corner of the page

upper-7 From the Training web page, select the

Certification link in the sub-menu and review

the contents

Featured information on this page will be updated

periodically For specific Certification sub-topics

select one of the links in the sub-menu in the left corner of the page

upper-8 Click on the Services tab located at the top of

the MySQL home page

Returns to the top level Services page

9 Review the details of MySQL Support

programs, by clicking on the Learn More >>

link

Shows the various support programs available

10 Click on the Community tab located at the

top of the MySQL home page

The community page contains many links to more information and access to various open

communication forums

11 Click on the News & Events tab located at the

top of the MySQL home page

Shows the latest MySQL happenings, from news stories to upcoming seminars

Trang 32

MySQL High Availability

Page 1-18

_

_ _

1.10 Installing MySQL

The recommended method for downloading the MySQL Cluster Carrier Grade Edition server is from the MySQL

web site downloads page: http://dev.mysql.com/downloads/cluster There are several different platforms

supported, and there are differences in the specific installation details for each This course requires the use of Linux

so that installation method will be described

Lab 1-B

In this exercise you will follow the steps required to download and install the latest version of the MySQL Cluster Carrier Grade server

1 In your web browser's toolbar text area, type:

dev.mysql.com/downloads/cluster

This will open the download page for the MySQL Cluster Carrier Grade server

2 Choose the Linux (non RPM Packages) link from

the list of available operating system downloads

This link will place you in the Linux (non RPM

Packages) section where you will be able to download the

MySQL binary distribution

3 Choose the pick a mirror link to the right of the proper

operating system that your system is running

This step will take you to the login page for the mysql.com server

4 Choose the >> No thanks, just take me to the

downloads! link below the login box

Choosing this link will bypass the need to login to the mysql.com server It is not necessary to login to the mysql.com server; however, it is recommended that you sign up for a mysql.com account This account provides valuable resources to you as a MySQL user

5 Choose the mirror location which is closest

(physically) to your location to download the file

from

The closest location "should" be the location that will take the least amount of time to download from; however, your instructor will identify which location you should use

6 Choose the save file option and save the file to the

local temporary directory (/tmp)

Saving the file in the /tmp directory will ensure that the downloaded file is easy to locate along with ensuring that this file will be deleted (it is not necessary to keep this file once the MySQL server has been installed)

7 In the /usr/local directory, type the

following:

tar -zxvf

/tmp/mysql-cluster-gpl-6.2.##-*.tar.gz

replacing the

/tmp/mysql-cluster-gpl-6.2.#.*.tar.gz with the exact file identifier

downloaded in step 6 along with the exact location

of the download

This will extract the file downloaded in step 6 into the /usr/local directory making a new subdirectory labeled mysql-cluster-gpl-6.2.##-*

Note: You may have to login as root to accomplish the steps from this point on Please contact your instructor for further assistance if this is necessary

Trang 33

MySQL High Availability

Page 1-19

_

_ _

8 Create a symbolic link directory to the newly mysql

directory just created that will be easier to work

with:

ln -s mysql-cluster-gpl-6.2.##-*

mysql

replacing the mysql-cluster-gpl-6.2.##-

* with the exact file directory name created in step 7

This will create a directory called mysql which will be easier to work with when dealing with the MySQL server

9 With MySQL installed (accessed though the mysql

directory just created), it is time to prepare for

running MySQL The first thing that needs to be

done is to create a group that MySQL will run under

by typing the following:

/usr/sbin/groupadd mysql

To ensure security with MySQL, it is important to not run the server as root This step creates a group called mysql that will only be used for running the MySQL server

10 With the mysql group created, it is now time to

create a mysql user assigned to this group by typing

the following command:

/usr/sbin/useradd -g mysql mysql

This user, mysql, will be the user that the MySQL server will run under

11 MySQL initially has no databases installed This can

be corrected by typing the following command in

/usr/local/mysql directory:

./scripts/mysql_install_db

This script will not only install the mysql and test database, but will also provide additional information on running the MySQL server

12 Now it is time to change the ownership of MySQL

directories to ensure a level of security when running

MySQL This is accomplished by typing the

following commands:

chown -R root:mysql /usr/local/mysql

chown -R mysql:mysql

/usr/local/mysql/data

These commands provide the ownership changes required

to provide a level of security when running the MySQL server

13 The following file should be edited to add the

mysql library files to the program start-up:

Trang 34

MySQL High Availability

Page 1-20

_

_ _

14 With all the steps completed, it is time to actually

start the MySQL server Type the following

commands to start the MySQL server:

15 In the /etc/ directory, edit the following file:

vi bashrc

There are a couple of files that modify your PATH They all work but some are read all the time for everyone, some are read for each user /etc/bashrc only works for bash but it is automatic when a console is launched, no global logout required (unlike the profile files)

16 Locate the end of the file and add the following and

then save and close the file:

PATH=${PATH}:/usr/local/mysql/bin

The path for the MySQL server binary directory is added

to the path preventing us from needing to precede each command with the full path

17 To be able to use the "path-less" approach to

executing mysql commands, shut down the current

terminal window and open a new one

This will give you access to using the "path-less" approach

18 Another big issue that is important for security is the

root password By default, there is no root

password This can be corrected by issuing the

following command (with training being the

new password):

mysqadmin -u root password training

This is a step that is missed by many administrators that install MySQL By changing the password immediately upon installation, this potential security hole is closed

19 To ensure that MySQL is running as expected, type

the following command to login to the MySQL

client:

mysql -uroot -p

The MySQL client is a tool that allows us to interact with the MySQL databases directly The actual command that was issued basically said that we are logging in as root (-uroot) and want to be prompted for the password (-p)

20 At the Enter password: prompt, type in the

password that was assigned to the user root in step

17, training

The following lines (or something similar) will be displayed if you were able to login correctly to the MySQL client:

Welcome to mysql monitor Commands end with ; or \g

Your MySQL connection id is # Server version: 5.1.#-ndb-6.2.# MySQL Cluster Server (GPL)

Type 'help;' or '\h' for help Type '\c' to clear the buffer

Trang 35

MySQL High Availability

Page 1-21

_

_ _

21 To give you a taste of MySQL, enter the following

command in the MySQL client window:

| information_schema |

| mysql |

| test | + -+

22 To quit the MySQL client window, type the

following command in the MySQL client window:

Trang 36

MySQL High Availability

Page 1-22

_

_ _

1.11 Installing the "world" database

MySQL provides three example databases to be used for testing server features and training These databases can be

found on the MySQL website documentation page; http://dev.mysql.com/doc/ The ‘world’ database will be used

throughout this course

Lab 1-C

This lab requires you to use the MySQL command line client in order to load the world database In order to use the pre-made tables in the world database, you will need to create the database (empty) and then upload the file

containing the table data

1 Type the following in the MySQL command line

client:

mysql> CREATE DATABASE world;

Creates the (empty) world database Returns following

message;

Query OK, 1 row affected (#.## sec)

2 Type:

mysql> USE world;

Instructs client to use the newly created world database

Returns following message;

Database changed

3 Type: *

mysql> SOURCE /tmp/world.sql

* Instructor will give you the file path if it is different than shown here

Several Query messages will scroll passed while tables

and data is being uploaded for the world database

Trang 37

MySQL High Availability

Page 1-23

_

_ _

1.12 Chapter Summary

This chapter introduced you to MySQL products and services In this chapter, you learned:

• The origin and status of the MySQL company

• The MySQL products and professional services that are available

• The definition of MySQL Enterprise and MySQL Community and their differences

• Which operating systems are currently supported

• What is available through the MySQL Community web page

• What is the MySQL Certification program

• Which courses are available to you after this course

• How to install the MySQL Server on a Linux operating system

Trang 38

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Trang 39

MySQL High Availability

INTRODUCTION TO

MYSQL HIGH AVAILABILITY

Trang 40

Ja clyn Z ha ng

(ja czh an g@

sh op pin

gco m)

ha s

a n on -tra nsf era ble

lice nse to use

th is Stu de

nt G uid e Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates

Ngày đăng: 25/11/2016, 19:08

TỪ KHÓA LIÊN QUAN