手机版
你好,游客 登录 注册
背景:
阅读新闻

OS X编译安装MariaDB

[日期:2015-07-28] 来源:Linux社区  作者:山河永寂 [字体:大 中 小]

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

很多开发环境需要我们安装数据库,随着mysql的日渐衰弱,更多的开发环境使用mariadb作为数据库,而mariadb数据库目前没有OS X的release版本,所以我们需要手动编译安装

修改代码

由于mariadb本身使用了tokudb的上游代码,而tokudb目前尚未有支持OS X的计划,所以常规安装方式是不成功的,我们需要对代码本身进行修改。
由于是tokudb引擎导致的问题,所以只需要修改两个文件
storage/tokudb/ft-index/cmake_modules/TokuSetupCompiler.cmake

-set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")
-set(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
+set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
+set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")

storage/tokudb/ha_tokudb.cc
- extern const char * const tokudb_hton_name;
+ extern const char *tokudb_hton_name;

笔者猜测最根本的原因是tokudb没有对OS X编译工具链做编译测试,OS X的编译工具是LLVM和BSD工具,而并非是gcc和GNU工具,所以在一些细节上有一些差别。如果没有改代码,会导致以下信息报错

[ 80%] Building CXX object storage/tokudb/ft-index/locktree/CMakeFiles/locktree_static.dir/locktree.cc.o
In file included from /Users/tangjiacheng/Development/server/storage/tokudb/ft-index/locktree/locktree.cc:99:
In file included from /Users/tangjiacheng/Development/server/storage/tokudb/ft-index/locktree/locktree.h:94:
/Users/tangjiacheng/Development/server/storage/tokudb/ft-index/buildheader/db.h:323:1: error: 
empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat]
struct __toku_db_lsn {
^
1 error generated.
make[2]: *** [storage/tokudb/ft-index/locktree/CMakeFiles/locktree_static.dir/locktree.cc.o] Error 1
make[1]: *** [storage/tokudb/ft-index/locktree/CMakeFiles/locktree_static.dir/all] Error 2
make: *** [all] Error 2

和

In file included from /Users/tangjiacheng/Development/server/storage/tokudb/ha_tokudb.cc:8293:
/Users/tangjiacheng/Development/server/storage/tokudb/hatoku_hton.cc:262:13: error: 
redefinition of 'tokudb_hton_name' with a different type: 'const char *'
vs 'const char *const'
const char *tokudb_hton_name = "TokuDB";
^
/Users/tangjiacheng/Development/server/storage/tokudb/ha_tokudb.cc:382:31: note: 
previous definition is here
extern const char * const tokudb_hton_name;

注:至于一些朋友说homebrew install mariadb可以安装mariadb的说法,其实是因为homebrew本身修改过mariadb的代码,增加了一个cmake选项禁用了tokudb,而tokudb本身代码是没有问题的,因噎废食的做法笔者不敢苟同,所以还是原生编译安装更加实在。Homebrew.mariadb

使用XtraBackup备份恢复MariaDB数据库  http://www.linuxidc.com/Linux/2015-07/120296.htm

在 CentOS/RHEL/Scientific Linux 6 下安装 LAMP (Apache with MariaDB and PHP) http://www.linuxidc.com/Linux/2013-07/86755.htm

MariaDB Proxy读写分离的实现 http://www.linuxidc.com/Linux/2014-05/101306.htm

Linux下编译安装配置MariaDB数据库的方法 http://www.linuxidc.com/Linux/2014-11/109049.htm

CentOS系统使用yum安装MariaDB数据库 http://www.linuxidc.com/Linux/2014-11/109048.htm

安装MariaDB与MySQL并存 http://www.linuxidc.com/Linux/2014-11/109047.htm

Ubuntu 上如何将 MySQL 5.5 数据库迁移到 MariaDB 10  http://www.linuxidc.com/Linux/2014-11/109471.htm

[翻译]Ubuntu 14.04 (Trusty) Server 安装 MariaDB  http://www.linuxidc.com/Linux/2014-12/110048htm

MariaDB 的详细介绍:请点这里
MariaDB 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-07/120707.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律��任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款