在centos上编译安装mariadb数据库

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

1、准备数据存放的目录

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

[root@localhost ~]# 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):

[root@localhost ~]# pvcreate /dev/sdb1(创建逻辑卷)
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# vgcreate myng /dev/sdb1
Volume group "myng" successfully created
[root@localhost ~]# lvcreate -L 1G -n mydata /dev/myng
Logical volume "mydata" created.
[root@localhost ~]# 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.
[root@localhost ~]# mkdir -pv /mydata/data
mkdir: 已创建目录 "/mydata"
mkdir: 已创建目录 "/mydata/data"

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

[root@localhost ~]# 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、安装依赖的软件包

[root@localhost ~]# yum -y install readline-devel zlib-devel openssl-devel cmake gcc-c++ gcc boost boost-devel bison bison-devel

二、编译安装mariadb

1、软件下载

[root@localhost ~]# wget http://archive.mariadb.org//mariadb-5.5.45/source/mariadb-5.5.45.tar.gz

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

[root@localhost ~]# tar xf mariadb-5.5.45.tar.gz
[root@localhost ~]# cd mariadb-5.5.45
[root@localhost 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
[root@localhost 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

[root@localhost mariadb-5.5.45]# make && make install

三、配置maridb服务

1、创建mysql用户与组

[root@localhost ~]#groupadd -r mysql     创建mysql组

[root@localhost ~]#useradd -g mysql -r -d /mydata/data 创建mysql用户
[root@localhost ~]#chown mysql:mysql /mydata/data 更改数据目录的属主属组
2、准备mariadb的脚本及配置文件
初始化数据库
[root@localhost ~]#cd /usr/local/mysql
[root@localhost mysql]#chown -R mysql:mysql *  更改属主属组
[root@localhost mysql]#scripts/mysql_install_db --datadir=/mydata/data --user=mysql 初始化库文件
[root@localhost mysql]#chown -R root * 更改属主为root
提供脚本
[root@localhost ~]#cd /usr/local/mysql
[root@localhost mysql]#cp support-files/mysql.server  /etc/rc.d/init.d/mysqld 提供脚本
[root@localhost mysql]#chmod +x /etc/rc.d/init.d/mysqld   赋予执行权限
[root@localhost mysql]#chkconfig --add mysqld   添加mysqld为系统服务
[root@localhost mysql]#chkconfig mysqld on      添加为开机启动
提供配置文件
[root@localhost ~]#cd /usr/local/mysql
[root@localhost mysql]#cp support-files/my-large.cnf  /etc/my.cnf
[root@localhost mysql]#vim /etc/my.cnf 编辑配置文件[mysqld]段填写如下内容
[mysqld]
datadir = /mydata/data  数据目录
thread_concurrency = 4  设置线程数=核心数x2
innodb_file_per_table=no
提供二进制文件
[root@localhost mysql]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost 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数据库服务
[root@localhost mysql]#service mysqld start
[root@localhost mysql]#ss -ntl | grep :3306
 
 
 
上一篇:Android图文具体解释属性动画


下一篇:Android -- 自定义ViewGroup+贝塞尔+属性动画实现仿QQ点赞效果