通用二进制格式安装MariaDB
通用二进制格式安装MariaDB
安装的mariadb-5.5.43-linux-x86_64.tar.gz这个软件包;
可以把mariadb安装到逻辑卷中:
创建一个20G的LVM磁盘
# fdisk /dev/sda
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 4
First cylinder (7859-15665, default 7859):
Using default value 7859
Last cylinder, +cylinders or +size{K,M,G} (7859-15665, default 15665):
Using default value 15665
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (7859-15665, default 7859):
Using default value 7859
Last cylinder, +cylinders or +size{K,M,G} (7859-15665, default 15665): +20G
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
创建一个10G大小的逻辑卷:
# pvcreate /dev/sda5
Physical volume "/dev/sda5" successfully created
# vgcreate myvg /dev/sda5
Volume group "myvg" successfully created
# lvcreate -L 10G -n mydata myvg
Logical volume "mydata" created
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
mydata myvg -wi-a----- 10.00g
root vg0 -wi-ao---- 20.00g
swap vg0 -wi-ao---- 2.00g
usr vg0 -wi-ao---- 10.00g
var vg0 -wi-ao---- 20.00g
格式化逻辑卷:(并创建卷标)
# mke2fs -t ext4 -L MYDATA /dev/myvg/mydata
开机自动挂载:
# vim /etc/fstab
LABEL=MYDATA/databaseext4defaults0 0
# mkdir /database/mydata/ -pv
# mount -a
#mount
/dev/mapper/myvg-mydata on /database type ext4 (rw)
开始安装 mariadb 数据库:
# tar xf mariadb-5.5.40-linux-x86_64.tar.gz -C /usr/local/
# cd /usr/local
# ln -sv mariadb-5.5.40-linux-x86_64 mysql
# cd mysql
# groupadd -r -g 306 mysql
# useradd -r -g 306 -u 306 mysql
# chown -R root.mysql ./*
# chown -R mysql.mysql /database/mydata/
# cd mysql/
# mkdir /etc/mysql
# cp support-files/my-large.cnf /etc/mysql/my.cnf
初始化数据库:
# scripts/mysql_install_db --user=mysql --datadir=/database/mydata/
初始化后:/database/mydata会生成很多数据库文件:
# ls /database/mydata/
aria_log.00000001 ib_logfile0 mysql mysql-bin.000003 test
aria_log_control ib_logfile1 mysql-bin.000001 mysql-bin.index
ibdata1 localhost.localdomain.pid mysql-bin.000002 performance_schema
#vim /etc/mysql/my.cnf
在[mysqld]下面随便找个位置添加下面的内容:
datadir = /database/mydata
innodb_file_per_table = on
这是安装包提供的服务脚本support-file/mysql.server
添加mysqld服务脚本,到系统默认的启动位置;
# cp support-file/mysql.server /etc/rc.d/init.d/mysqld
添加执行权限,添加到开机自动挂着:
# chmod +x /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list mysqld
现在就可以使用 mysqld 启动mysql 服务了;
# service mysqld start
# ss -tnl
把/etc/profile.d/mysql.sh这个路径加入环境变量:
# vim /etc/profile.d/mysql.sh
添加:exprot PATH=/usr/local/mysql/bin:$PATH
# . /etc/profile.d/mysql.sh
现在就可以使用mysql启动数据库了;
# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.43-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> select version(); 显示当前内置的版本;
+--------------------+
| version() |
+--------------------+
| 5.5.43-MariaDB-log |
+--------------------+
1 row in set (0.00 sec)
本文出自 “blue” 博客,请务必保留此出处http://sailove.blog.51cto.com/3215562/1641443
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。