在centos上编译安装mariadb数据库

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

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] 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

时间: 2024-10-13 16:45:29

在centos上编译安装mariadb数据库的相关文章

【apache http server安装】CentOS上编译安装Aapche Http Server详细过程

下载apache httpd # wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz 2. 解压 apache httpd # tar xzvf httpd-2.4.10.tar.gz 编译apache httpd [[email protected]]# ./configure checkingfor chosen layout... Apache checkingfor working mkdir -p... yes

CentOS上编译安装OpenCV-2.3.1与ffmpeg-2.1.2

已测试环境: CentOS 6.3 32bit CentOS 6.5 64bit 曾经在CentOS 6.3 32bit安装过OpenCV,参见CentOS 6.3中安装OpenCV2.3.1,如今换了64bit系统,大刀阔斧,重新来一遍. 检查并安装相关程序,确保gtk安装成功,否则无法显示图片 yum install gcc-c++ # g++编译 yum install gtk-devel # 反正是gtk神马的,不一定就是gtk-devel,可以使用*gtk-devel*匹配 yum i

在CentOS上编译安装MySQL+安装问题解决+安全优化

0.说明 当然,MySQL的安装方法多种多样,在CentOS上,你可以采用YUM的方式安装,这样的好处是:快速方便.基本上,它会帮你解决所有的函数库依赖问题,正常情况下,只要YUM执行完成,那么MySQL也就可以使用了. 但我更倾向于使用编译的方式来安装MySQL,原因也很简单:除了有详细的官方文档外,你还可以非常清楚地知道你自己在做什么,这点在以后MySQL运行出现问题时将会有很大的帮助! 但即便是按照官方文档来安装,你也会遇到各种各样的问题,这里,我将呈现一个完整的过程给大家,直到完成下面的

在CentOS上编译安装Nginx+实验环境搭建+测试

0.说明 Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件,很有必要搭建实验环境来对其进行学习. 1.实验环境 本次实验的测试环境使用的宿主机操作系统为Windows 7,在Vmware虚拟机安装CentOS 6.5,说明如下: 宿主机操作系统Windows 7 虚拟机安装的操作系统CentOS 6.5 虚拟机操作系统上网方式NAT 而当使用NAT的方式进行上网时虚拟机.宿主机之间的网络连接关系可如下所示: 关于为什么网络拓扑结构是这样的,这

在Centos上编译安装nginx

实验环境: OS: CentOS 6.6 nginx:nginx-1.6.2.tar.gz 前期准备:安装开发包组件[[email protected] tmp]# yum -y groupinstall "Development tools" "Server Platform Development"[[email protected] tmp]# yum -y install pcre-devel 一. 编译安装: [[email protected] tmp]

在CentOS上编译安装PostgreSQL

http://my.oschina.net/tashi/blog 第一步:准备阶段 获取必需软件包: CentOS中查看是否安装了某个软件的命令:rpm -qa | grep 软件名.which命令可查看某个软件的安装路径.使用 yum install 包名 来安装软件包. 1.GNU make的版本3.80以上[[email protected] ~]# rpm -qa | grep makemake-3.81-20.el6.x86_64 [[email protected] ~]# make

CentOS下编译安装mariadb

下载CMAKEhttps://cmake.org/download/ 解压文件tar -zxvf cmake-3.6.0-rc3.tar.gz 安装GCCyum install gcc-c++ 切换到cmake目录cd cmake-3.6.0-rc3 执行configure文件./configure 安装make && make install 下载mariadbhttps://downloads.mariadb.org/mariadb/ 解压文件tar -zxvf mariadb-10.

编译安装MariaDB数据库

1.安装编译环境 yum install -y gcc gcc-c++ make libtool bison ncurses-devel zlib-devel automake autoconf cmake 2.编译MariaDB tar zxvf mariadb-***.tar.gz cd mariadb-***/ ./BUILD/compile-pentium64-max make install

CentOS 6上编译安装AMP详解

在CentOS 6上编译安装AMP     A:Apache(httpd)     M:MySQL or MariaDB     P:php 目录: 一.准备工作 二.编译安装Apache(httpd) 三.编译安装MariaDB 四.编译安装PHP 编译安装AMP的优点: 根据生产环境灵活定制程序 优化编译参数,提高性能 解决不必要的软件依赖 一.准备工作 1.需要的软件包及版本号: httpd-2.4.27(apr-1.5.2+ apr-util-1.5.4) + MariaDB-5.5.5