OS X編譯安裝MariaDB
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.oIn 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 1make[1]: *** [storage/tokudb/ft-index/locktree/CMakeFiles/locktree_static.dir/all] Error 2make: *** [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 hereextern const char * const tokudb_hton_name;
註:至於一些朋友說homebrew install mariadb
可以安裝mariadb的說法,其實是因為homebrew本身修改過mariadb的代碼,增加了一個cmake選項禁用了tokudb,而tokudb本身代碼是沒有問題的,因噎廢食的做法筆者不敢苟同,所以還是原生編譯安裝更加實在。Homebrew.mariadb
使用XtraBackup備份恢複MariaDB資料庫
在 CentOS/RHEL/Scientific Linux 6 下安裝 LAMP (Apache with MariaDB and PHP)
MariaDB Proxy讀寫分離的實現
Linux下編譯安裝配置MariaDB資料庫的方法
CentOS系統使用yum安裝MariaDB資料庫
安裝MariaDB與MySQL並存
Ubuntu 上如何將 MySQL 5.5 資料庫遷移到 MariaDB 10
[翻譯]Ubuntu 14.04 (Trusty) Server 安裝 MariaDB