A series of failures caused by MySQL directory migration

Source: Internet
Author: User

Environment:

Centos 6.7, MySQL 5.7, Zabbix 3.2


Background:

The Zabbix server's MySQL data directory has insufficient partition space and needs to be migrated to another partition. Look at the online articles are quite simple, in broad daylight to operate directly.

As a result, MySQL did not get up, and then Zabbix couldn't get up.


Here's how it works:

Stop MySQL Service

/etc/init.d/mysql stop

Copy the entire datadir to the new directory

CP-RVF mysqldata/home/work/

Edit My.cnf to modify the directory to a new path

DataDir =/home/work/mysqldata/data/

socket=/home/work/mysqldata/data/mysql.sock

Pid-file=/home/work/mysqldata/data/mysql.pid

Log_error =/home/work/mysqldata/log/error.log

log-bin=/home/work/mysqldata/log/bin-log

Edit/etc/init.d/mysql to modify the directory to a new path

Datadir=/home/work/mysqldata/data

Mysqld_pid_file_path=/home/work/mysqldata/data/mysql.pid

OK, start MySQL and get ready to go.

/etc/init.d/mysql start

The results appeared:

Troubleshooting process:

Go to the log to see if the binary log file cannot be found, the path to the prompt is not before the migration.

I'm sure the MY.CNF has been modified to the latest path, why do you suggest this? There is no information on the Internet, ready to let the big God shot. Ran to the binary log directory under a glance. See a Bin-log.index file, vaguely remember that the path of each binary log file is recorded inside. Go in and see, the light shines. Change the path to the latest, start MySQL, get it done!


Save Zabbix

The previous mentioned to stop the MySQL service, Zabbix naturally also automatically hang up, and then start Zabbix

/etc/init.d/zabbix_server start

Zabbix_server dead but Subsys locked

To see Zabbix_server.log

9598:20180628:173014.802 One child processdied (pid:9630,exitcode/signal:1). Exiting ...

9598:20180628:173016.802 [Z3001] connectionto database ' Zabbix ' failed: [2002] Can ' t connect to local MySQL server through Socket '/home/mysqldata/data/mysql.sock ' (2)

9598:20180628:173016.802 Got signal[signal:11 (SIGSEGV), reason:1,refaddr: (nil)]. Crashing

I look at the path is old, to the zabbix_server.conf inside the socket path to a new, Zabbix start success.

Open Zabbix page, error, prompt

Database Error

Error connecting todatabase:no such file or directory

Again to the/etc/php.ini inside the socket also modified to the latest, restart PHP-FPM, finally the page opened successfully.


A series of failures caused by MySQL directory migration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.