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 :- '''innodb_force_recovery = 3'''
* 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
* Dump the database: mysqldump zimbra and mboxgroup DB's


   
   
Line 26: Line 28:




1) Edit the my.cnf file and put '''innodb_force_recovery = 3''' : save the file and start mysql. [mysql.server start]
#) 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) <tt></tt>mysql -NB -e "show databases" | grep mbox > /tmp/mysql.db.list    [Make a list of the existing database]
#) <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>


3) <tt> mkdir /tmp/mysql.sql </tt>


 
#) <pre> mysqldump zimbra -S /opt/zimbra/db/mysql.sock -u root --password=''password_for_mysql_root'' > /tmp/mysql.sql/zimbra.sql </pre>
4) <tt> mysqldump zimbra -S /opt/zimbra/db/mysql.sock -u root -ppassword_for_mysql_root > /tmp/mysql.sql/zimbra.sql </tt>




['''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:


5) Dumping Databases: Run the following command from the prompt:
<tt> for db in `< /tmp/mysql.db.list`; \do /opt/zimbra/mysql/bin/mysqldump $db -S /opt/zimbra/db/mysql.sock -u zimbra -ppassword_zimbra_mysql >
/tmp/mysql.sql/$db.sql; \echo -e "Dumped $db\n"; \done; </tt>


['''Mysql Zimbra Password''' You can get the password: zmlocalconfig -s -m nokey zimbra_mysql_password]
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>]


6) Drop the Database:


#) Drop the Database:


<tt> for db in `< /tmp/mysql.db.list`; \ do mysql -e "drop database $db"; \echo -e "Dropped $db"; \done; </tt>


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




7) <tt> mysql -e "drop database zimbra" </tt>
#) <pre> mysql -e "drop database zimbra" </pre>




8) Run Mysql in Non-Recovery Mode:
#) 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.




9) Create Database:
#)Create Database:




Line 76: Line 84:




10) Create the existed Database:
#) Create the existed Database:




Line 84: Line 92:




11) mysql zimbra < /tmp/mysql.sql/zimbra.sql
#) <pre>mysql zimbra < /tmp/mysql.sql/zimbra.sql</pre>
 
 
12) Update Mboxgroup:




<tt> for sql in /tmp/mysql.sql/mbox*; \  do mysql `basename $sql .sql` < $sql; \echo -e "Updated `basename $sql .sql` \n"; \done; </tt>
#) 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>


13) zmcontrol start


#) <pre>zmcontrol start</pre>


14) Check if everything is up and running.
#) 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.


  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


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


  1. )
     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']

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

]


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


  1. )
     mysql -e "drop database zimbra" 


  1. ) Run Mysql in Non-Recovery Mode:


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


  1. )Stop Mysql Server and Start again.


  1. )Create Database:


mysql -e "create database zimbra character set utf8"


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


  1. )
    mysql zimbra < /tmp/mysql.sql/zimbra.sql


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


  1. )
    zmcontrol start
  1. ) 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