标签:curses 标准 you term blog Fix 进制 pat nload
一、源码包下载:下载源码包:mariadb-10.2.35.tar.gz包 //源码包比二进制包小好多73.9mb左右
2、安装环境:
mariadb版本:10.2.35
centos版本:centos7.6.1810
官方提示:不要在生产环境中使用beta和alpha版本的数据库;他们的主要功能一般是用来测试和排错的,不稳定,我们选择10.2.35系列的stable数据库
二、源码编译安装mariadb(官方建议使用cmake编译安装)
1、源码编译安装mariadb10.2.35的stable版本数据库:
//1、安装相关的软件依赖包:
[root@localhost ~]# yum install -y bison bison-devel zlib-devel libcurl-devel libarchive-devel
boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel
libevent-devel libaio-devel
Installed:
bison.x86_64 0:3.0.4-2.el7 bison-devel.x86_64 0:3.0.4-2.el7
boost-devel.x86_64 0:1.53.0-28.el7 cmake.x86_64 0:2.8.12.2-2.el7
gcc.x86_64 0:4.8.5-39.el7 gcc-c++.x86_64 0:4.8.5-39.el7
gnutls-devel.x86_64 0:3.3.29-9.el7_6 libaio-devel.x86_64 0:0.3.109-13.el7
libarchive-devel.x86_64 0:3.1.2-14.el7_7 libcurl-devel.x86_64 0:7.29.0-57.el7_8.1
libevent-devel.x86_64 0:2.0.21-4.el7 libxml2-devel.x86_64 0:2.9.1-6.el7.4
ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 openssl-devel.x86_64 1:1.0.2k-19.el7
zlib-devel.x86_64 0:1.2.7-18.el7
//2、准备用户和数据的存放目录
[root@localhost ~]# useradd -r -s /sbin/nologin mysql //创建mysql用户
[root@localhost ~]# mkdir -pv /data/mysqldb //创建数据存放目录
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/mysqldb’
[root@localhost ~]# chown mysql.mysql /data/mysqldb //把mysqldb目录的所有者,改为mysql
[root@localhost ~]# ll /data/
drwxr-xr-x 2 mysql mysql 6 Nov 7 17:07 mysqldb
2、解压并执行cmake
//3、解压、编译源码包;
[root@localhost ~]# tar -zxvf mariadb-10.2.35.tar.gz
[root@localhost ~]# cd mariadb-10.2.35/
[root@localhost mariadb-10.2.35]#cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql \ //mysql安装程序的目录
-DMYSQL_DATADIR=/data/mysqldb/ \ //数据库数据存放目录
-DSYSCONFDIR=/etc \ //指定配置文件所在目录
-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock \ //指定soket文件目录;默认情况下是在/tmp/mysql.sock
//自定义目录后需要给该目录授予mysql用户读写执行权限
//执行如果出错,执行rm -f CMakeCache.txt文件
[root@localhost mariadb-10.2.35]# make && make install
[root@localhost mariadb-10.2.35]# make -j 4 && make install
//-j4 与m-j8的意思就是多线程运行,
(线程的意思请参考操作系统)即4个进程去竞争多核cpu,或者8个线程去竞争cpu
3、cmake标准文件
cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/data/mysqldb/ -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITHOUT_MROONGA_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
4、环境变量及启动脚本配置:
//4、准备环境变量:
[root@localhost ~]# echo PATH=/app/mysql/bin:$PATH > /etc/profile.d/mysql.sh
[root@localhost ~]# . /etc/profile.d/mysql.sh
//5、生成数据库文件w
[root@localhost mariadb-10.2.35]# cd /app/mysql/
[root@localhost mysql]# scripts/mysql_install_db --datadir=/data/mysqldb/ --user=mysql
--basedir=/app/mysql //执行之前确定mysql用户创建完成
ok
//6、准备配置文件:
[root@localhost mysql]# cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@localhost mysql]# vim /etc/my.cnf
socket = /app/mysql/mysql.sock //指定sock文件地址
//7、准备自启动脚本:
[root@localhost mysql]# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
5、启动服务:
//8、启动服务:
[root@localhost mysql]# chkconfig --add mysqld;service mysqld start
[root@localhost mysql]# systemctl start mysqld.service
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process
exited with error code. See "systemctl status mysqld.service" and "journalctl -xe"
for details.
[FAILED]
//解决思路:查看日志:
[root@localhost mysqldb]# cat /data/mysqldb/localhost.localdomain.err
//查看日志报错;/app/mysql目录没有为用户mysql设置权限;
[ERROR] Can‘t start server : Bind on unix socket: Permission denied
[ERROR] Do you already have another mysqld server running on socket: /app/mysql/mysql.sock ?
//启动服务时会报错:因为没有读写权限:
//解决方案:
[root@localhost ~]# setfacl -R -m u:mysql:rwx /app/mysql/
//为/app/mysql目录设置mysql用户具有读写权限
[root@localhost mysqldb]# systemctl restart mysqld.service
[root@localhost mysqldb]# mysql
Server version: 10.2.35-MariaDB-log
MariaDB [(none)]> show variables like "basedir";
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| basedir | /app/mysql |
//9、设置开机自启动
[root@localhost ~]# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6、设置root账号口令
//10、为mysql数据库程序设置root账号口令:
[root@localhost ~]# mysql_secure_installation
NO.A.0004——mysql/mariadb——make安装/配置
标签:curses 标准 you term blog Fix 进制 pat nload
原文地址:https://blog.51cto.com/15005403/2552279