Mysql Crash Recovery: Difference between revisions

No 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
innodb_force_recovery = 3
:in the [mysqld] section
 


* Dump the database: mysqldump zimbra and mboxgroup DB's
* Dump the database: mysqldump zimbra and mboxgroup DB's
   
   
* Drop all Database's.
* Drop all Database's.


* Create all Database's.
* Create all Database's.


* Restore dump data.
* Restore dump data.
Line 31: Line 25:
:Save the file and start mysql with ''mysql.server start''
:Save the file and start mysql with ''mysql.server start''


2) <pre>mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list</pre>    [Make a list of the existing databases]


2) <pre>mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list</pre>    [Make a list of the existing database]
3) <pre>mkdir /tmp/mysql.sql </pre>
3) <pre>mkdir /tmp/mysql.sql </pre>


4) <pre> mysqldump zimbra -S /opt/zimbra/db/mysql.sock -u root --password=''password_for_mysql_root'' > /tmp/mysql.sql/zimbra.sql </pre>
4) <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 zimbra_mysql_password'']
['''Mysql Root Password''' you can get this by 'zmlocalconfig -s -m nokey mysql_root_password']


5) Dumping Databases: Run the following command from the prompt:
5) Dumping Databases: Run the following command from the prompt:
Line 50: Line 42:
  done
  done


['''Mysql Zimbra Password''' You can get the password: <pre>zmlocalconfig -s -m nokey zimbra_mysql_password</pre>]
['''Mysql Zimbra Password''' You can get the password: ''zmlocalconfig -s -m nokey zimbra_mysql_password'']




Line 79: Line 71:




<tt> mysql -e "create database zimbra character set utf8" </tt>
<pre> mysql -e "create database zimbra character set utf8" </pre>




Line 85: Line 77:




<tt> for db in `< /tmp/mysql.db.list`; \ do mysql -e "create database $db character set utf8"; \
<pre>
echo -e "Created $db \n";done</tt>
for db in `< /tmp/mysql.db.list`
do
    mysql -e "create database $db character set utf8"
    echo -e "Created $db \n"
done
</pre>





Revision as of 19:17, 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.


1) 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

2)

mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list

[Make a list of the existing databases] 3)

mkdir /tmp/mysql.sql 

4)

 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 zimbra_mysql_password]

5) 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]


6) 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

7)

 mysql -e "drop database zimbra" 


8) Run Mysql in Non-Recovery Mode:


Remove the innodb_force_recovery = 3 from the /opt/zimbra/conf/my.cnf file.


9)Stop Mysql Server and Start again.


10)Create Database:


 mysql -e "create database zimbra character set utf8" 


11) 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


12)

mysql zimbra < /tmp/mysql.sql/zimbra.sql


13) Update Mboxgroup:

for sql in /tmp/mysql.sql/mbox*
do
    mysql `basename $sql .sql` < $sql
    echo -e "Updated `basename $sql .sql` \n"
done


14)

zmcontrol start

15) Check if everything is up and running.


Verified Against: Zimbra Collaboration Suite 4.5.6 Date Created: 8/13/2007
Article ID: https://wiki.zimbra.com/index.php?title=Mysql_Crash_Recovery Date Modified: 2007-11-01



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search