在centos上编译安装mariadb数据库

author author     2022-08-02     774

关键词:

一、安装前提(准备数据文件、安装其他依赖的软件)

1、准备数据存放的目录

[[email protected] ~]# fdisk /dev/sdb  (fdisk /dev/sdb 创建一个逻辑分区/dev/sdb1)
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa592b386.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won‘t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
switch off the mode (command ‘c‘) and change display units to
sectors (command ‘u‘).

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +2G

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks

[[email protected] ~]# fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bd13b

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1959 15215616 8e Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa592b386

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux

Disk /dev/mapper/VolGroup-lv_root: 14.0 GB, 13967032320 bytes
255 heads, 63 sectors/track, 1698 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 1610 MB, 1610612736 bytes
255 heads, 63 sectors/track, 195 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal):

[[email protected] ~]# pvcreate /dev/sdb1(创建逻辑卷)
Physical volume "/dev/sdb1" successfully created
[[email protected] ~]# vgcreate myng /dev/sdb1
Volume group "myng" successfully created
[[email protected] ~]# lvcreate -L 1G -n mydata /dev/myng
Logical volume "mydata" created.
[[email protected] ~]# mke2fs -t ext4 /dev/myng/mydata (格式化逻辑卷)
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] ~]# mkdir -pv /mydata/data
mkdir: 已创建目录 "/mydata"
mkdir: 已创建目录 "/mydata/data"

[[email protected] ~]# mkdir -pv /mydata/data (创建数据目录)
mkdir: 已创建目录 "/mydata"
mkdir: 已创建目录 "/mydata/data"

[[email protected] ~]# vim /etc/fstab (挂载逻辑卷到数据目录,并添加到开机自动挂载)

#
# /etc/fstab
# Created by anaconda on Thu Dec 31 06:00:39 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=8da37a95-1c26-48ab-8f4c-216c4eab8c18 /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/myng/mydata /mydata/data ext4 defaults 0 0

2、安装依赖的软件包

[[email protected] ~]# yum -y install readline-devel zlib-devel openssl-devel cmake gcc-c++ gcc boost boost-devel bison bison-devel

二、编译安装mariadb

1、软件下载

[[email protected] ~]# wget http://archive.mariadb.org//mariadb-5.5.45/source/mariadb-5.5.45.tar.gz

2、如何查看maridb编译的参数

[[email protected] ~]# tar xf mariadb-5.5.45.tar.gz
[[email protected] ~]# cd mariadb-5.5.45
[[email protected] mariadb-5.5.45]# cmake . -LH

常见的编译参数如下:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/data/mysql
-DSYSCONFDIR=/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_ZLIB=system
-DWITH_LIBWRAP=0
-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_DEBUG=0
-DENABLE_PROFILING=1
3、编译安装mariadb
[[email protected] mariadb-5.5.45]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data/ -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

[[email protected] mariadb-5.5.45]# make && make install

 

三、配置maridb服务

1、创建mysql用户与组

[[email protected] ~]#groupadd -r mysql     创建mysql组

[[email protected] ~]#useradd -g mysql -r -d /mydata/data 创建mysql用户
[[email protected] ~]#chown mysql:mysql /mydata/data 更改数据目录的属主属组
2、准备mariadb的脚本及配置文件
初始化数据库
[[email protected] ~]#cd /usr/local/mysql
[[email protected] mysql]#chown -R mysql:mysql *  更改属主属组
[[email protected] mysql]#scripts/mysql_install_db --datadir=/mydata/data --user=mysql 初始化库文件
[[email protected] mysql]#chown -R root * 更改属主为root
提供脚本
[[email protected] ~]#cd /usr/local/mysql
[[email protected]calhost mysql]#cp support-files/mysql.server  /etc/rc.d/init.d/mysqld 提供脚本
[[email protected] mysql]#chmod +x /etc/rc.d/init.d/mysqld   赋予执行权限
[[email protected] mysql]#chkconfig --add mysqld   添加mysqld为系统服务
[[email protected] mysql]#chkconfig mysqld on      添加为开机启动
提供配置文件
[[email protected] ~]#cd /usr/local/mysql
[[email protected] mysql]#cp support-files/my-large.cnf  /etc/my.cnf
[[email protected] mysql]#vim /etc/my.cnf 编辑配置文件[mysqld]段填写如下内容
[mysqld]
datadir = /mydata/data  数据目录
thread_concurrency = 4  设置线程数=核心数x2
innodb_file_per_table=no
提供二进制文件
[[email protected] mysql]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ > /etc/profile.d/mysql.sh
[[email protected] mysql]# source /etc/profile.d/mysql.sh
(问题1:

Linux命令行报bash:.....:command not found的解决办法

Linux命令行输入命令执行后报“bash:....:command not found”这是由于系统PATH设置问题,PATH没有设置对,系统就无法找到精确命令了。 

 
1、在命令行中输入:export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin  这样可以保证命令行命令暂时可以使用。命令执行完之后先不要关闭终端
2、正确编写path文件
(提供库文件
# echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
提供头文件
# ln -sv /usr/local/include /usr/include/mysql
提供man手册
# echo ‘MANPATH /usr/local/mysql‘ >> /etc/man.config
# man -M /usr/local/mysql/man mysqld 让man手册立刻生效为最新)
启动mysql数据库服务
[[email protected] mysql]#service mysqld start
[[email protected] mysql]#ss -ntl | grep :3306
 
 
 

 

在centos6.7操作系统上编译安装httpd2.4

功能描述:  在CentOS6.7操作系统上,编译安装apache服务,实现定制功能等一、安装前提 1)安装编译httpd需要的软件包 [[email protected]~]# yum-yinstallwgetgcc-c++ncursesncurses-develcmakemakeperlbisonopensslopenssl-develgcc*libxm 查看详情

在centos6.7操作系统上编译安装mysql-5.6.31

功能概述:  由于在centos6.7下通过yum安装的mysql是5.1版本的,不满足需求,因此经常性需要编译安装mysql服务等。一、安装mysql 1、安装前提    1)安装编译mysql代码所依赖的包  [[email protected]~]#yum-yi... 查看详情

sh在rhel/centos7上编译并安装tmux2.9a(代码片段)

查看详情

在centos7.2上编译gcc4.1.2

1.下载安装gcc4.1.2安装包 wgetftp://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2注:其他版本的安装包可以在上级目录寻找到。2.执行以下命令,查看是否安装“makeinfo”makeinfo--version已安装,则记录版本号,然后执行“步骤 3”。未... 查看详情

在centos6上编译tor。 libevent 的问题

】在centos6上编译tor。libevent的问题【英文标题】:compiletoroncentos6.Problemswithlibevent【发布时间】:2017-10-1711:05:03【问题描述】:我有干净的centos6系统,尝试从源代码编译tor。第一种方式(通过yum安装libevent)。我愿意:yuminstalllibe... 查看详情

在centos6.9上编译安装lamp并搭建个人博客

准备阶段:1、两台安装了centos6.9的机器,A和B;A:192.168.1.100B:192.168.1.102其中A机器上跑http和php,B机器是mysql服务器2、准备软件包apr-1.6.2.tar.gz   apr-util-1.6.0.tar.gz #Apache可移植运行库,为上层应用程序提供一个可以... 查看详情

centos6上编译安装httpd2.4

在CentOS6上无法直接使用rpm包安装httpd2.4,因为httpd2.4依赖于: apr-1.4及以上版本 apr-util-1.4及以上版本而直接升级apr和apr-util会覆盖直接版本的程序,影响其他程序的依赖关系,所以一般使用编译安装的方式安装apr和apr-util... 查看详情

centos上编译运行pkr(代码片段)

CentOS上编译运行PKR安装编译工具相关包sudoyumgroupinstall-y"DevelopmentTools"sudoyuminstall-yepel-releasewgetwhichopenmpiopenmpi-developenmpi3openmpi3-devel安装gcc-11yuminstall-ycentos-release-sclyuminstall-yd 查看详情

centos上编译运行pkr(代码片段)

CentOS上编译运行PKR安装编译工具相关包sudoyumgroupinstall-y"DevelopmentTools"sudoyuminstall-yepel-releasewgetwhichopenmpiopenmpi-developenmpi3openmpi3-devel安装gcc-11yuminstall-ycentos-release-sclyuminstall-yd 查看详情

在centos7.2上编译gcc4.4.7

1.前置首先,可以参考我的上篇文章,在centOS7.2上编译gcc4.1.2,过程基本一致,这里只对可能遇到的错误情况进行说明。2.安装texinfo4.8我的centos7.2版本,自带的是gcc4.8,texinfo5.1,在编译gcc的过程中主要遇到的是texinfo5.1版本过高,... 查看详情

使用 cmake 在 windows 上编译 c++ 数据库时出错

】使用cmake在windows上编译c++数据库时出错【英文标题】:Errorcompilingac++databaseonwindowswithcmake【发布时间】:2019-10-2112:32:45【问题描述】:对于我的硕士学位,我需要在一个名为daddb的数据库上工作(它在github上)。通常在Linux上,... 查看详情

在 windows 64 位上编译和安装 openssl

】在windows64位上编译和安装openssl【英文标题】:CompilingandinstallingopensslOnwindows64bit【发布时间】:2012-08-2006:16:01【问题描述】:我想在Windows7HomePremium64位上安装openssl,我已经下载了openssl包并将其解压缩到c目录中,但是我找不到... 查看详情

无法在新的 Homestead 安装上编译 Laravel 资产

】无法在新的Homestead安装上编译Laravel资产【英文标题】:CannotcompileLaravelassetsonnewHomesteadinstall【发布时间】:2021-01-0800:02:53【问题描述】:更新3(最新)根据以下建议(来自justanothereddie),将驱动器配置为NFS解决了问题。不过... 查看详情

在 64 位 Arm 上编译和安装 Chez 方案?

】在64位Arm上编译和安装Chez方案?【英文标题】:CompilingandInstallingChezSchemeon64BitArm?【发布时间】:2021-03-2417:02:47【问题描述】:我尝试编译和安装ChezScheme编译器的Racket后端变体,因为它现在似乎支持aarch64Arm64架构,不像mainlineCh... 查看详情

centos上编译运行pkr(代码片段)

CentOS上编译运行PKR安装编译工具相关包sudoyumgroupinstall-y"DevelopmentTools"sudoyuminstall-yepel-releasewgetwhichopenmpiopenmpi-developenmpi3openmpi3-devel安装gcc-11yuminstall-ycentos-release-sclyuminstall-ydevtoolset-11-gcc*ln-s/opt/rh/devtoolset-11/root/bin/gcc/usr/bin/gcc-... 查看详情

在macos上编译ffmpeg(代码片段)

本文转自:在MacOS上编译FFmpeg|www.samirchen.com安装Xcode和CommandLineTools从AppStore上安装Xcode,并确保在Xcode的 Preferences->Downloads->Components 下安装好CommandLineTools。当然你也可以从 https://developer.apple. 查看详情

无法在 Windows 7 上编译 restbed

】无法在Windows7上编译restbed【英文标题】:Can\'tcompilerestbedonWindows7【发布时间】:2017-04-2715:08:41【问题描述】:我已经结束了16个小时的配置、安装、删除、修改和多次敲击我的键盘......我想使用restbed进行独立于平台的C++编程,... 查看详情

CentOS下编译libev(dev)

...【问题描述】:我想知道是否有关于如何在Linux(CentOS)64位上编译libev-dev的说明。我找不到与libev相关的开发包,也找不到任何关于其编译的教程。p.s:请不要包管理器-因为我是在没有特权的情况下安装在云上的。【问题讨论】:... 查看详情