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