在centos上編譯安裝mariadb資料庫

來源:互聯網
上載者:User

標籤:

一、安裝前提(準備資料檔案、安裝其他依賴的軟體)

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=13、編譯安裝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  設定線程數=核心數x2innodb_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   

 

在centos上編譯安裝mariadb資料庫

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.