我有一个EC2实例设置,我试图将MySQL数据目录移动到挂载的存储。
默认的数据目录是:
/opt/bitnami/mysql/data
我已经完全复制该目录
/mnt/mysql_data
然后,我将my.cnf中的path更改为以下内容:
datadir=/mnt/mysql_data
并重新命名旧的目录,以确保我使用的是新的。
我已经给新的目录上的MySQL给予适当的权限 – 但我甚至不认为MySQL正试图到达那里。 当我尝试重新启动mysql时,我得到有关以前的数据目录的错误:
sudo /opt/bitnami/ctlscript.sh start mysql 111122 18:50:50 mysqld_safe Logging to '/opt/bitnami/mysql/data/mysqld.log'. touch: cannot touch `/opt/bitnami/mysql/data/mysqld.log': No such file or directory chown: cannot access `/opt/bitnami/mysql/data/mysqld.log': No such file or directory 111122 18:50:50 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data /opt/bitnami/mysql/bin/mysqld_safe: 739: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent eval: 1: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent 111122 18:50:50 mysqld_safe mysqld from pid file /opt/bitnami/mysql/data/ip-10-120-253-190.pid ended /opt/bitnami/mysql/bin/mysqld_safe: 783: cannot create /opt/bitnami/mysql/data/mysqld.log: Directory nonexistent
我错过了某个configuration步骤吗? 我已经看到其他有问题的人通过调整apparmor来解决它,但是我甚至没有“/etc/apparmor.d/usr.sbin.mysqld”文件,他们应该改变它。 另外,我的问题似乎并不是MySQL无法访问新的目录 – 这是它仍然使用旧的。
原来亚马逊的控制脚本“/opt/bitnami/ctlscript.sh”正在/opt/bitnami/mysql/scripts/ctl.sh执行一个mysqlconfiguration脚本
令人恼火的是,这个脚本覆盖了my.cnf文件中的几个关键设置。 在那里更新它们可以解决这个问题。
你必须configurationmysql来使用新的日志目录,请编辑/etc/mysql/my.cnf(在这种情况下,我使用的是Debian)并更新
general_log_file = /mnt/data/log
祝你好运。