聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长

Centos 7.2 安装MariaDB笔记

2016-11-20 23:30 浏览: 12881 次 我要评论(0 条) 字号:

MariaDB是MySQL的一个衍生版,关于MariaDB的介绍,可以回顾下:MySQL分支的选择:Percona还是MariaDB

CentOS 7.2源中自带的MariaDB版本是5.5系列,该系列的innodb引擎依然不支持full-text,这次要安装的是支持full-text的最新稳定版本10.1.19。

首先先是常规操作:

yum update
yum install epel-release

方案一:通过YUM安装

通过Yum安装是非常简单,首先在 /etc/yum.repos.d/ 目录下创建MariaDB.repo,内容如下:

# MariaDB 10.1 CentOS repository list - created 2016-11-14 07:42 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

完成后执行

yum install MariaDB-server MariaDB-client
 即可。安装完成后自动注册了服务。可以使用

systemctl start mariadb #启动mariadb
systemctl enable mariadb #设置开机自动启动mariadb

在完成后为了再进行安全设置,运行

mysql_secure_installation
 。

方案二:通过源码编译安装

源码编译安装的流畅相对要繁琐些,主要是要弄清楚一些编译参数等。

1、下载源码

可以到MariaDB官网获取最新的下载链接,然后进行下载并解压:

wget https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.1.19/source/mariadb-10.1.19.tar.gz
tar zxvf mariadb-10.1.19.tar.gz
cd mariadb-10.1.19

2、进行编译安装

为了能够数你编译,首先要安装编译工具:

yum groupinstall 'Development Tools'
 ,MariaDB 5.5及更高版本使用cmake编译。所以还需要安装 
yum install cmake

执行cmake . –LH,查看编译参数。可以看到如下信息:

-- Running cmake version 2.8.11
-- MariaDB 10.1.19
-- Packaging as: mariadb-10.1.19-Linux-x86_64
-- checking for one of the modules 'libsystemd;libsystemd-daemon'
-- Systemd features not enabled
-- Could NOT find LibXml2 (missing:  LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) 
-- Could NOT find Java (missing:  Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) (Required is at least version "1.6")
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
CMake Warning at storage/tokudb/CMakeLists.txt:32 (MESSAGE):
  TokuDB is enabled, but jemalloc is not.  This configuration is not
  supported

CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:196 (FIND_CURSES)
  CMakeLists.txt:338 (MYSQL_CHECK_READLINE)

根据上述反馈的问题,安装如下依赖:

安装JDK
wget --no-check-certificate --no-cookies      --header "Cookie: oraclelicense=accept-securebackup-cookie"      http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gztar zxvf jdk-8u111-linux-x64.tar.gzln -s /usr/local/jdk1.8.0_111 /usr/local/latest

添加环境变量:

vi /etc/profile
 ,加入如下内容:

export JAVA_HOME=/usr/local/latestexport CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin

执行

source /etc/profile
 进行更新。完成后执行

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DTMPDIR=/usr/local/mysql/tmp -DMYSQL_UNIX_ADDR=/usr/local/mysql/run/mysqld.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_TOKUDB_STORAGE_ENGINE=1 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_ARIA_STORAGE_ENGINE=1 -DWITH_FEDERATEDX_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_SPHINX_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' -DWITH_SAFEMALLOC=OFF -DWITH_DEBUG=0 -DENABLE_PROFILING=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0

然后执行:

make&&make install
编译参数详解: ue”>yum install ncurses-devel libxml2-devel openssl-devel
yum install libaio-devel libcurl-devel libarchive-devel boost boost-devel

安装jemalloc

wget https://github.com/jemalloc/jemalloc/releases/download/4.3.1/jemalloc-4.3.1.tar.bz2
tar jxvf jemalloc-4.3.1.tar.bz2
cd jemalloc-4.3.1
./configure
make && make install

安装完成后还需执行:

echo '/usr/local/jemalloc-4.3.1/lib' > /etc/ld.so.conf.d/local.conf
/sbin/ldconfig

安装JDK

wget --no-check-certificate --no-cookies 
     --header "Cookie: oraclelicense=accept-securebackup-cookie" 
     http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz
tar zxvf jdk-8u111-linux-x64.tar.gz
ln -s /usr/local/jdk1.8.0_111 /usr/local/latest

添加环境变量:

vi /etc/profile
 ,加入如下内容:

export JAVA_HOME=/usr/local/latest
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

执行

source /etc/profile
 进行更新。

然后执行make&&make install进行安装。安装后无法启动MySQL,目前正在寻找解决方案。



网友评论已有0条评论, 我也要评论

发表评论

*

* (保密)

Ctrl+Enter 快捷回复