openwrt安装mysql冲突_Openwrt上mysql innodb的使用及相关异常情况

首先在menuconfig中配置mysql,具体是在Utilities->database->mysql-server。这样直接编译就可以了,不过这样默认是不支持innodb存储引擎的,估计是考虑openwrt一般是运行的硬件有关,不需要这么复杂的存储引擎(占用空间也比MyISAM存储引擎大)。但是,如果需要支持innodb存储引擎该怎么办?这类型的网上帖子不多,我是之前参照国外的论坛加自己测试得出的。

Openwrt支持innodb存储引擎

修改feeds/oldpackages/libs/mysql/Makefile

在--with-server之前加--with-innodb

修改feeds/oldpackages/libs/mysql/conf/my.cnf

在[mysqld]中加default-storage-engine=INNODB

在bind-address = 127.0.0.1下载添加

innodb

innodb_file_per_table = 1

innodb_flush_log_at_trx_commit = 2

/etc/init.d/mysqld脚本start函数中添加

start() {

local datadir=$(sed -n -e "s/^[[:space:]]*datadir[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" /etc/my.cnf)

local mysqldatadir="/mnt/data/mysql/"

local mysqltmpdir="/mnt/data/tmp/"

local mysqlsrvdir="/srv/mysql/"

if [ ! -d "$mysqldatadir" ]; then

echo "create dir /mnt/data/mysql/..."

mkdir -p "$mysqldatadir"

fi

if [ ! -d "$mysqltmpdir" ]; then

echo "create dir /mnt/data/tmp/..."

mkdir -p "$mysqltmpdir"

fi

if [ ! -d "$mysqlsrvdir" ]; then

echo "create dir /srv/mysql/..."

mkdir -p "$mysqlsrvdir"

fi

if [ ! -d "$datadir" ]; then

error "Error: datadir '$datadir' in /etc/my.cnf doesn't exist"

return 1

fi

if [ ! -f "$datadir/mysql/tables_priv.MYD" ]; then

mysql_install_db --force

service_stop /usr/bin/mysqld

#error "Error: I didn't detect a privileges table, you might need to run mysql_install_db --force to initialize the system tables"

#return 1

fi

service_start /usr/bin/mysqld

}        至此,基于innodb的MySQL就可以正常运行了。

在基于netgear3700v2硬件的openwrt上,会出现初始化innodb的情况,异常表现为创建socket失败,提示如Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘。其实这个是因为初始化innodb失败造成的,因为netgear3700v2的flash只有16M,不能满足innodb的运行需求,数据文件大小总和至少要达到 10 MB。通过敲入mysqld --skip-grant&命令可能会打印出类似如下的信息:

[email protected]_AP:/# mysqld --skip-grant&

[email protected]_AP:/# 150203  1:32:31  InnoDB: Initializing buffer pool, size = 8.0M

150203  1:32:31  InnoDB: Completed initialization of buffer pool

InnoDB: Error: auto-extending data file ./ibdata1 is of a different size

InnoDB: 64 pages (rounded down to MB) than specified in the .cnf file:

InnoDB: initial 640 pages, max 0 (relevant if non-zero) pages!

InnoDB: Could not open or create data files.

InnoDB: If you tried to add new data files, and it failed here,

InnoDB: you should now edit innodb_data_file_path in my.cnf back

InnoDB: to what it was, and remove the new ibdata files InnoDB created

InnoDB: in this failed attempt. InnoDB only wrote those files full of

InnoDB: zeros, but did not yet use them in any way. But be careful: do not

InnoDB: remove old data files which contain your precious data!

150203  1:32:31 [ERROR] Plugin ‘InnoDB‘ init function returned error.

150203  1:32:31 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed.

150203  1:32:31 [ERROR] Unknown/unsupported table type: INNODB

150203  1:32:31 [ERROR] Aborting

150203  1:32:31 [Note] mysqld: Shutdown complete

上述这个莫名其妙的问题经过验证确实是由于flash空间不够引起的。解决的办法是,在路由器上挂载一个U盘。挂载U盘的配置项为:

kernel modules ->filesystems->kmod-fs-vfat

kernel modules->native language support->kmod-nls-cp437/kmod-nls-iso8859-1/kmod-nls-utf-8

kernel modules->usb support->kmod-usb-core/kmod-usb-ohci/kmod-usb-storage/kmod-usb-usb2

还有,在init初始化脚本中如果顺序执行多个mysql操作的时候,如mysql_install_db --force命令之后接着mysqladmin -u root password ‘123456‘则可能会失败,因为还没等mysql_install_db执行完成就会执行mysqladmin命令。解决此问题的办法是加sleep时间,具体多长时间可以视情况而定。

原文:http://blog.csdn.net/cblou/article/details/43489837

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值