Home Database Mysql Tutorial MySQL Cluster恢复过程记

MySQL Cluster恢复过程记

Jun 07, 2016 pm 05:05 PM
database

最近在项目的生产环境中使用了mysql-mmm来提高数据库的可用性和处理能力。在项目初期,mysql-mmm安装、配置和部署对我们开发人员

最近在项目的生产环境中使用了mysql-mmm来提高数据库的可用性和处理能力。在项目初期,mysql-mmm安装、配置和部署对我们开发人员一直都是透明的。于是一个“美好”的愿望开始在心中滋生:我们不需要管理数据库,一旦有问题就会系统管理人员过来修复。可是,随着项目的深入,这个愿望也在逐步破裂。由于某些开发人员不当操作(当然,开发人员是不应该具有直接操作数据库的权利的,,这是管理上的问题。),导致MySQL Cluster主从状态不统一,无法完成同步,从而造成主程序无法启动。这时,我们的最初创建环境的系统管理人员,却因为其他项目无法抽身,而他当初的警告也让我们不敢“越雷池半步”。中间的几次问题,都通过不同的方法临时解决了:邀请了其他项目组的DBA、写了脚本定时监控mysql-mmm的状态等等。可是到了9月30号这一天一切都变了。数据库又一次毫无征兆的崩溃了。这次更严重:一台slave无法启动,两台slave无法同步,只剩下master,还在苟延残喘(这个词有点过分!)。

更多关于MySQL Cluster的详细信息,或者下载地址请点这里

        难道MySQL Cluster真的有那么麻烦吗?终于忍无可忍了,不能再把希望寄托到别人身上!在把主程序的数据库读写都切换到了master上以后,开始尝试恢复MySQL Cluster的状态。

        继续之前,交代一下MySQL Cluster的配置:典型的writer/reader。db01和db02为master,db01,db02都为writer,同时db02还作为reader,db03和db04都是slave,作为reader。其中db04已经无法启动。

        为了防止万一失败不会造成更坏的影响,选择了db04作为练手的对象。

        问题1:MySQL无法启动

        现象1:使用service mysql start启动时,进度一直持续。

        备份现有的配置文件my.cnf,重新安装MySQL。安装后MySQL启动正常,将备份的my.cnf,恢复到/etc/,重新启动MySQL。出现错误:

     现象2:Starting MySQL. ERROR! Manager of pid-file quit without updating file.

     查看/var/lib/mysql/下面的*.err日志,找到相应的提示,根据错误提示进行相应的操作。由于现场丢失,只能在这里给出错误原因:

命令查看,发现该目录/opt/mysql目录已经满了,于是清空了/opt/mysql下面的所有文件,重新启动,还是同样的问题

     b. 日志文件和数据文件不存在。于是重新创建data(数据)和log(日志)两个目录,根据my.cnf里面的配置,分别将/var/lib/mysql下面的ibdata1和ib_logfile0、ib_logfile1分支复制到数据和日志目录中。重新启动,问题依旧。

     c. mysql用户无权读取data和log目录。和其他几台服务器上的目录比较结合错误日志发现,原来上面两个文件夹是由root用户创建的,mysql用户没有读写权限。chown -R mysql.mysql data修改目录所有者。重新启动,同样错误信息跃然于眼前。

     d. mysql无法在现有的数据文件和日志文件上进行操作。将ibdata1和ib_logfile0、ib_logfile1删除,重新启动。终于启动成功,回到目录下查看,已经新建了ibdata1和ib_logfile0、ib_logfile1。


     问题2:无法导入dump文件。

     服务启动成功后,下面就是按照MySQL-MMM安装指南进行配置了。从db01上dump出当前的数据库内容,然后在db04上导入。由于导入是在9月30号下午进行,当时为了不耽误班车,强行退出了导入进程,就出现这个错误 。

     今天在删除了一些比较大的并且不再使用的数据库后(一定要记得备份!!),dump出来的数据文件小了很多,可是在导出过程中直接退出了。通过ps查看,发现mysql已经停止,而且无法重启。查看错误日志,发现如下信息:

      [ERROR] /usr/sbin/mysqld: Disk is full writing './myapp/session.MYD' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)


   安装恢复db04的步骤,恢复db02和db03。前面的步骤都很顺利,可是执行CHANGE MASTER命令时出现了错误,日志中的错误信息:

     Failed to open the relay log '//opt/mysql/log/mysql-bin-slave1.005457' (relay_log_pos 147636219)。

     到/var/lib/mysql目录下,发现其中已经存在了master.info和relay-log.info两个文件。查看master.info文件,其中还是上一次同步时设置的内容。删除这两个文件。重新执行CHANGE MASTER命令。     

     由于在之前已经安装了mysql-mmm的组件,因此这次恢复过程没有涉及到mysql-mmm的配置,这个是接下来要解决的问题。

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How does Go language implement the addition, deletion, modification and query operations of the database? How does Go language implement the addition, deletion, modification and query operations of the database? Mar 27, 2024 pm 09:39 PM

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Tips and practices for handling Chinese garbled characters in databases with PHP Tips and practices for handling Chinese garbled characters in databases with PHP Mar 27, 2024 pm 05:21 PM

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

See all articles