安装环境
操作系统:CentOS 7
MariaDB版本:mariadb-5.5.33a
MariaDB数据库存储目录:/data/mysql
配置环境
1、安装系统
略
2、配置网络
略
3、配置防火墙
开启 3306 端口
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
/etc/init.d/iptables restart
firewall-cmd --list-all
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.248.0.0/28" port port=3306 protocol=tcp accept'
firewall-cmd --reload
|
4、关闭 SELINUX
vi /etc/selinux/config
SELINUX=disabled :wq! shutdown -r now
|
编译安装
规划目录
MariaDB安装包存放位置:/usr/local/src
MariaDB编译安装位置:/usr/local/mysql
下载安装包
下载MariaDB
访问官网或国内源下载
下载cmake(MariaDB编译工具)
http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
安装编译工具及库文件(使用CentOS yum命令安装,安装的比较多,方便以后编译安装php、nginx等)
yum install make apr* autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils bison
|
安装篇
一、安装cmake
cd /usr/local/src tar zxvf cmake-2.8.12.1.tar.gz cd cmake-2.8.12.1 ./configure make make install
|
二、安装MariaDB
groupadd mysql useradd -g mysql mysql -s /bin/false mkdir -p /data/mysql chown -R mysql:mysql /data/mysql mkdir -p /usr/local/mysql cd /usr/local/src tar zxvf mariadb-5.5.33a.tar.gz cd mariadb-5.5.33a cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc make make install cd /usr/local/mysql cp ./support-files/my-huge.cnf /etc/my.cnf vi /etc/my.cnf datadir = /data/mysql ./scripts/mysql_install_db --user=mysql cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld chmod 755 /etc/init.d/mysqld chkconfig mysqld on vi /etc/rc.d/init.d/mysqld basedir = /usr/local/mysql datadir = /data/mysql service mysqld start vi /etc/profile export PATH=$PATH:/usr/local/mysql/bin
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql shutdown -r now mysql_secure_installation
service mysqld restart mysql -u root -p
|
到此,MariaDB数据库安装完成!