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

前端之家收集整理的这篇文章主要介绍了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

[root@localhost ~]# groupadd -r -g 306 MysqL###添加MysqL用户

[root@localhost ~]# useradd -r -g 306 -u 306 MysqL ###添加MysqL

[root@localhost dylan]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/

[root@localhost dylan]# cd /usr/local/

[root@localhost local]# ln -sv mariadb-5.5.46-linux-x86_64/ MysqL###创建MysqL链接

[root@localhost local]# cd MysqL

[root@localhost MysqL]# chown -R root.MysqL ./*###更改属组属组

[root@localhost MysqL]# mkdir -pv /mydata/data###创建数据目录

mkdir: 已创建目录 "/mydata"

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

[root@localhost MysqL]# chown -R MysqL.MysqL /mydata/data/###更改数据目录权限

[root@localhost MysqL]# mkdir /etc/MysqL

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

[root@localhost MysqL]# cp support-files/my-large.cnf /etc/MysqL/my.cnf

[root@localhost 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

[root@localhost MysqL]# cp support-files/MysqL.server /etc/rc.d/init.d/MysqLd

[root@localhost 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

[root@localhost MysqL]# chkconfig --add MysqLd###添加服务

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

[root@localhost MysqL]# scripts/MysqL_install_db --user=MysqL --datadir=/mydata/data

[root@localhost MysqL]# service MysqLd start

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

###编辑selinux,关闭selinux

[root@localhost MysqL]# vim /etc/selinux/config

SELINUX=disabled

[root@localhost MysqL]# getenforce

Enforcing

[root@localhost MysqL]# setenforce 0

[root@localhost MysqL]# getenforce

Permissive

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

[root@localhost /]# /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目录,需手动创建,或者将此注销掉,否则启动服务会失败。

[root@localhost 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目录

[root@localhost MysqL]# mkdir /var/log/mariadb ###此处使用第三种方法

[root@localhost MysqL]# service MysqLd start

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

###修改环境变量

[root@localhost rc.d]# vim /etc/profile.d/MysqL.sh

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

[root@localhost rc.d]# source /etc/profile.d/MysqL.sh ###重读此配置文件

###导出头文件

[root@localhost rc.d]# ln -sv /usr/local/MysqL/include/ /usr/include/MysqLd

"/usr/include/MysqLd" -> "/usr/local/MysqL/include/"

###导出库文件

[root@localhost ld.so.conf.d]# vim /etc/ld.so.conf.d/MysqL.conf

/usr/local/MysqL/lib

[root@localhost ld.so.conf.d]# ldconfig ###系统重载入系统库

[root@localhost 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安全加固

[root@localhost bin]# MysqL_secure_installation ###运行此命令进行设置

原文链接:https://www.f2er.com/centos/377107.html

猜你在找的CentOS相关文章