CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析相关的知识,希望对你有一定的参考价值。

CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz

提前准备好mariadb-5.5.46-linux-x86_64.tar.gz

[[email protected] ~]# groupadd -r -g 306 mysql                    ###添加mysql用户

[[email protected] ~]# useradd -r -g 306 -u 306 mysql              ###添加mysql组

[[email protected] dylan]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/

[[email protected] dylan]# cd /usr/local/

[[email protected] local]# ln -sv mariadb-5.5.46-linux-x86_64/ mysql    ###创建mysql链接

[[email protected] local]# cd mysql

[[email protected] mysql]# chown -R root.mysql ./*                    ###更改属组属组

[[email protected] mysql]# mkdir -pv /mydata/data                     ###创建数据目录

mkdir: 已创建目录 "/mydata"

mkdir: 已创建目录 "/mydata/data"

[[email protected] mysql]# chown -R mysql.mysql /mydata/data/        ###更改数据目录权限

[[email protected] mysql]# mkdir /etc/mysql

###将选择的配置文件复制至/etc/mysql/中,并重命名为my.cnf

[[email protected] mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf 

[[email protected] mysql]# vim /etc/mysql/my.cnf                     ###编辑添加

thread_concurrency = 8

datadir = /mydata/data                                            ###设定数据文件目录

innodb_file_per_table = ON                                        

skip_name_resolve = ON                                            ###跳过主机名解析

###复制mysqld的服务管理文件至/etc/rc.d/init.d并命名为mysqld

[[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

[[email protected] mysql]# ls -l /etc/rc.d/init.d/mysqld

-rwxr-xr-x. 1 root root 12196 6月  20 22:28 /etc/rc.d/init.d/mysqld

[[email protected] mysql]# chkconfig --add mysqld                     ###添加服务

###程序初始化,指定用户为mysql,数据目录为/mydata/data

[[email protected] mysql]# scripts/mysql_install_db  --user=mysql --datadir=/mydata/data

[[email protected] mysql]# service mysqld start

Starting MySQL. ERROR!     ###启动错误

###编辑selinux,关闭selinux

[[email protected] mysql]# vim /etc/selinux/config 

SELINUX=disabled

[[email protected] mysql]# getenforce

Enforcing

[[email protected] mysql]# setenforce 0

[[email protected] mysql]# getenforce

Permissive

###此时启动依然出错,mysql读取配置文件不仅仅有一个,mysql进程会以此去找很多个位置,并使用最后的作为最终的配置。

[[email protected] /]# /usr/local/mysql/bin/mysql --help --verbose    ###查看读取次序

/usr/local/mysql/bin/mysql  Ver 15.1 Distrib 5.5.46-MariaDB, for Linux (x86_64) using read

line 5.1Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Usage: /usr/local/mysql/bin/mysql [OPTIONS] [database]

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf                 ###读取顺序

###于是查看/etc/my.cnf文件,在log-error=/var/log/mariadb/mariadb.log中,于是查看/var/log/中不存在mariadb目录,需手动创建,或者将此注销掉,否则启动服务会失败。

[[email protected] rc.d]# vim /etc/my.cnf                 

[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log ###错误日志路径

pid-file=/var/run/mariadb/mariadb.pid

###查看/var/log/下并没有mariadb目录,于是有三种方法解决:

1.mv /etc/my.cnf  /etc/my.cnf.bak ###使/etc/my.cnf失效

2.vim /etc/my.cnf   

#log-error=/var/log/mariadb/mariadb.log ###注销掉

3.mkdir /var/log/mariadb     ###创建mariadb目录

[[email protected] mysql]# mkdir /var/log/mariadb         ###此处使用第三种方法

[[email protected] mysql]# service mysqld start

Starting MySQL... SUCCESS!     ###成功启动

###修改环境变量

[[email protected] rc.d]# vim /etc/profile.d/mysql.sh

export PATH=/usr/local/mysql/bin:$PATH

[[email protected] rc.d]# source /etc/profile.d/mysql.sh ###重读此配置文件

###导出头文件

[[email protected] rc.d]# ln -sv /usr/local/mysql/include/ /usr/include/mysqld

"/usr/include/mysqld" -> "/usr/local/mysql/include/"

###导出库文件

[[email protected] ld.so.conf.d]# vim /etc/ld.so.conf.d/mysql.conf

/usr/local/mysql/lib

[[email protected] ld.so.conf.d]# ldconfig ###系统重载入系统库

[[email protected] ld.so.conf.d]# ldconfig -p |grep mysql ###查看库文件读取

libmysqld.so.18 (libc6,x86-64) => /usr/local/mysql/lib/libmysqld.so.18

libmysqld.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqld.so

libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18

libmysqlclient.so.18 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.18

libmysqlclient.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so     

###mysql安全加固

[[email protected] bin]# mysql_secure_installation ###运行此命令进行设置


本文出自 “11290766” 博客,请务必保留此出处http://rylan.blog.51cto.com/11290766/1940437

以上是关于CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析的主要内容,如果未能解决你的问题,请参考以下文章

Mariadb 通用二进制格式安装

CentOS7安装通用二进制格式MariaDB 10.2.8

Mariadb安装和简析

二进制格式安装MySQL

Mariadb源码和二进制安装

CentOS 7 用通用二进制的格式安装方法总结