Mysql Crash Recovery: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
* Edit /opt/zimbra/conf/my.cnf: Put an entry | * Edit /opt/zimbra/conf/my.cnf: Put an entry | ||
innodb_force_recovery = 3 | |||
:in the [mysqld] section | |||
* Dump the database: | * Dump the database: mysqldump zimbra and mboxgroup DB's | ||
Line 26: | Line 28: | ||
#) Edit the /opt/zimbra/conf/my.cnf file and put '''innodb_force_recovery = 3''' under the '''[mysqld]''' section | |||
:Save the file and start mysql with ''mysql.server start'' | |||
#) <pre>mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list</pre> [Make a list of the existing database] | |||
#) <pre>mkdir /tmp/mysql.sql </pre> | |||
#) <pre> mysqldump zimbra -S /opt/zimbra/db/mysql.sock -u root --password=''password_for_mysql_root'' > /tmp/mysql.sql/zimbra.sql </pre> | |||
['''Mysql Root Password''' you can get this by 'zmlocalconfig -s -m nokey mysql_root_password'] | ['''Mysql Root Password''' you can get this by 'zmlocalconfig -s -m nokey mysql_root_password'] | ||
#) Dumping Databases: Run the following command from the prompt: | |||
for db in `< /tmp/mysql.db.list`; | |||
do | |||
/opt/zimbra/mysql/bin/mysqldump $db -S /opt/zimbra/db/mysql.sock -u root --password=''password_for_mysql_root'' > /tmp/mysql.sql/$db.sql | |||
echo -e "Dumped $db\n" | |||
done | |||
['''Mysql Zimbra Password''' You can get the password: <pre>zmlocalconfig -s -m nokey zimbra_mysql_password</pre>] | |||
#) Drop the Database: | |||
<pre> | |||
for db in `< /tmp/mysql.db.list` | |||
do | |||
mysql -u root --password=''password_for_mysql_root'' -e "drop database $db" | |||
echo -e "Dropped $db" | |||
done | |||
</pre> | |||
#) <pre> mysql -e "drop database zimbra" </pre> | |||
#) Run Mysql in Non-Recovery Mode: | |||
Remove the '''innodb_force_recovery = 3''' from the my.cnf file. | Remove the '''innodb_force_recovery = 3''' from the /opt/zimbra/conf/my.cnf file. | ||
Stop Mysql Server and Start again. | #)Stop Mysql Server and Start again. | ||
#)Create Database: | |||
Line 76: | Line 84: | ||
#) Create the existed Database: | |||
Line 84: | Line 92: | ||
#) <pre>mysql zimbra < /tmp/mysql.sql/zimbra.sql</pre> | |||
#) Update Mboxgroup: | |||
<pre> | |||
for sql in /tmp/mysql.sql/mbox* | |||
do | |||
mysql `basename $sql .sql` < $sql | |||
echo -e "Updated `basename $sql .sql` \n" | |||
done | |||
</pre> | |||
#) <pre>zmcontrol start</pre> | |||
#) Check if everything is up and running. | |||
Revision as of 19:11, 1 November 2007
Mysql Crash Recovery
BUG "http://bugzilla.zimbra.com/show_bug.cgi?id=15797"
Mysql Crash recovery is performed when Mysql stops responding and there is error in the /opt/zimbra/db/data/hostname.err [Please check the BUG above for more information]
Steps to perform Recovery:
- Edit /opt/zimbra/conf/my.cnf: Put an entry
innodb_force_recovery = 3
- in the [mysqld] section
- Dump the database: mysqldump zimbra and mboxgroup DB's
- Drop all Database's.
- Create all Database's.
- Restore dump data.
- ) Edit the /opt/zimbra/conf/my.cnf file and put innodb_force_recovery = 3 under the [mysqld] section
- Save the file and start mysql with mysql.server start
- )
mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list
[Make a list of the existing database]
- )
mkdir /tmp/mysql.sql
- )
mysqldump zimbra -S /opt/zimbra/db/mysql.sock -u root --password=''password_for_mysql_root'' > /tmp/mysql.sql/zimbra.sql
[Mysql Root Password you can get this by 'zmlocalconfig -s -m nokey mysql_root_password']
- ) Dumping Databases: Run the following command from the prompt:
for db in `< /tmp/mysql.db.list`; do /opt/zimbra/mysql/bin/mysqldump $db -S /opt/zimbra/db/mysql.sock -u root --password=password_for_mysql_root > /tmp/mysql.sql/$db.sql echo -e "Dumped $db\n" done
[Mysql Zimbra Password You can get the password:
zmlocalconfig -s -m nokey zimbra_mysql_password
]
- ) Drop the Database:
for db in `< /tmp/mysql.db.list` do mysql -u root --password=''password_for_mysql_root'' -e "drop database $db" echo -e "Dropped $db" done
- )
mysql -e "drop database zimbra"
- ) Run Mysql in Non-Recovery Mode:
Remove the innodb_force_recovery = 3 from the /opt/zimbra/conf/my.cnf file.
- )Stop Mysql Server and Start again.
- )Create Database:
mysql -e "create database zimbra character set utf8"
- ) Create the existed Database:
for db in `< /tmp/mysql.db.list`; \ do mysql -e "create database $db character set utf8"; \
echo -e "Created $db \n";done;
- )
mysql zimbra < /tmp/mysql.sql/zimbra.sql
- ) Update Mboxgroup:
for sql in /tmp/mysql.sql/mbox* do mysql `basename $sql .sql` < $sql echo -e "Updated `basename $sql .sql` \n" done
- )
zmcontrol start
- ) Check if everything is up and running.