学习笔记-源码安装mariadb 20210128
源码安装Mariadb数据库
安装之前先检查一下空间:
1 [15:13:16 root@centos8 ~]#free -h(#检查空间) 2 total used free shared buff/cache available 3 Mem: 7.6Gi 799Mi 6.1Gi 10Mi 672Mi 6.5Gi 4 Swap: 4.0Gi 0B 4.0Gi
安装之前的准备工作:
做准备用户和数据目录:
1.准备用户
#useradd -r -s /sbin/nologin -d /data/mysql mysql
2.准备数据目录
#chown mysql:mysql /data/mysql
3.查看源码包
[15:48:01 root@centos8 ~]#ls
anaconda-ks.cfg initial-setup-ks.cfg mariadb-10.2.31.tar.gz rz
1 [15:13:26 root@centos8 ~]# 2 [15:44:10 root@centos8 ~]#useradd -r -s /sbin/nologin -d /data/mysql mysql(#创建数据库目录) 3 [15:44:11 root@centos8 ~]#ls /data/mysql 4 ls: cannot access '/data/mysql': No such file or directory(#查看之后证明是不存在的) 5 [15:45:46 root@centos8 ~]#mkdir -pv /data/mysql(#创建文件夹) 6 mkdir: created directory '/data/mysql' 7 [15:46:18 root@centos8 ~]#chown mysql.mysql /data/mysql(#给文件夹附属性) 8 [15:48:01 root@centos8 ~]#ls 9 anaconda-ks.cfg initial-setup-ks.cfg mariadb-10.2.31.tar.gz rz(#看到红色的源码包) 10 [15:48:05 root@centos8 ~]#
4.准备二进制程序
#tar xvf mariadb-10.2.31.tar.gz -C /usr/local/src/(#此处解压缩源码包)
1 [16:23:23 root@centos8 ~]#tar xvf mariadb-10.2.31.tar.gz -C /usr/local/src/
命令回车之后,自动安装
5. 解压缩之后,到目录中查看文件大小
1 [16:23:23 root@centos8 ~]#ls 2 anaconda-ks.cfg initial-setup-ks.cfg mariadb-10.2.31.tar.gz rz 3 [16:25:03 root@centos8 ~]#cd /usr/local/src/ 4 [16:25:29 root@centos8 src]#ls 5 mariadb-10.2.31 6 [16:25:31 root@centos8 src]#cd mariadb-10.2.31/ 7 [16:26:03 root@centos8 mariadb-10.2.31]#ls 8 appveyor.yml CMakeLists.txt dbug include libmysqld mysys_ssl scripts strings VERSION 9 BUILD config.h.cmake debian INSTALL-SOURCE libservices pcre sql support-files vio 10 BUILD-CMAKE configure.cmake Docs INSTALL-WIN-SOURCE man plugin sql-bench tests win 11 client COPYING EXCEPTIONS-CLIENT KNOWN_BUGS.txt mysql-test randgen sql-common THIRDPARTY wsrep 12 cmake CREDITS extra libmariadb mysys README.md storage unittest zlib 13 [16:26:07 root@centos8 mariadb-10.2.31]#du -sh .(#解压缩之后文件是513MB) 14 513M . 15 [16:26:20 root@centos8 mariadb-10.2.31]#du -sh 16 513M . 17 [16:26:23 root@centos8 mariadb-10.2.31]#ll /root/mariadb-10.2.31.tar.gz -h 18 -rw-r--r--. 1 root root 70M Jan 26 21:39 /root/mariadb-10.2.31.tar.gz(#源码包的大小是70MB) 19 [16:31:03 root@centos8 mariadb-10.2.31]#
此处有个插曲,我的系统之前没有安装cmake,所以这里折腾了很久
提供一个链接,根据他的安装即可https://www.cnblogs.com/hans_gis/p/12347720.html,此处不详述了
6.使用cmake编译
1 [16:31:03 root@centos8 mariadb-10.2.31]#ll /root/mariadb-10.2.31.tar.gz -h 2 -rw-r--r--. 1 root root 70M Jan 26 21:39 /root/mariadb-10.2.31.tar.gz 3 [17:40:25 root@centos8 mariadb-10.2.31]#ls 4 appveyor.yml CMakeLists.txt dbug include libmysqld mysys_ssl scripts strings VERSION 5 BUILD config.h.cmake debian INSTALL-SOURCE libservices pcre sql support-files vio 6 BUILD-CMAKE configure.cmake Docs INSTALL-WIN-SOURCE man plugin sql-bench tests win 7 client COPYING EXCEPTIONS-CLIENT KNOWN_BUGS.txt mysql-test randgen sql-common THIRDPARTY wsrep 8 cmake CREDITS extra libmariadb mysys README.md storage unittest zlib
1 [17:41:56 root@centos8 mariadb-10.2.31]#cmake . \ 2 > -DCMAKE_INSTALL_PREFIX=/apps/mysql \ 3 > -DMYSQL_DATADIR=/data/mysql/ \ 4 > -DSYSCONFDIR=/etc/ \ 5 > -DMYSQL_USER=mysql \ 6 > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 7 > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 8 > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 9 > -DWITH_PARTITION_STORAGE_ENGINE=1 \ 10 > -DWITHOUT_MROONGA_STORAGE_ENGINE=1 \ 11 > -DWITH_DEBUG=0 \ 12 > -DWITH_READLINE=1 \ 13 > -DWITH_SSL=system \ 14 > -DWITH_ZLIB=system \ 15 > -DWITH_LIBWRAP=0 \ 16 > -DENABLED_LOCAL_INFILE=1 \ 17 > -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ 18 > -DDEFAULT_CHARSET=utf8 \ 19 > -DDEFAULT_COLLATION=utf8_general_ci
回车之后,开始了
1 [17:43:37 root@centos8 mariadb-10.2.31]#make -j 8 && make install (#使用8核来加速安装)