二进制安装MariaDB5.5.36
1.获取源码包解压,确定rpm包的mysql-server和mysql未安装
[root@http1 mysql]# rpm -qa mysql
[root@http1 mysql]# rpm -qa mysql-server
[root@http1 ~]# ls
anaconda-ks.cfg apr-util-1.5.3.tar.bz2 install.log
apr-1.5.0 httpd24 install.log.syslog
apr-1.5.0.tar.bz2 httpd-2.4.9 mariadb-5.5.36-linux-x86_64.tar.gz
apr-util-1.5.3 httpd-2.4.9.tar.bz2
[root@http1 ~]# tar xf mariadb-5.5.36-linux-x86_64.tar.gz
[root@http1 ~]# ls
anaconda-ks.cfg apr-util-1.5.3.tar.bz2 install.log
apr-1.5.0 httpd24 install.log.syslog
apr-1.5.0.tar.bz2 httpd-2.4.9 mariadb-5.5.36-linux-x86_64
apr-util-1.5.3 httpd-2.4.9.tar.bz2 mariadb-5.5.36-linux-x86_64.tar.gz
2.移动到程序安装目录并创建软链接
[root@http1 ~]# mv mariadb-5.5.36-linux-x86_64 /usr/local
[root@http1 ~]# cd /usr/local/
[root@http1 local]# ln -s mariadb-5.5.36-linux-x86_64/ mysql
3.创建mysql属主属组
[root@http1 local]# /usr/sbin/groupadd -r mysql
[root@http1 local]# /usr/sbin/useradd -r -g mysql mysql
4.创建数据存放目录
格式化磁盘,设置为LVM
[root@http1 mysql]#echo "p\nn\np\n3\n\n+30G\nt\n3\n8e\nw" |fdisk /dev/sda
[root@http1 mysql]# partx -a /dev/sda
创建LVM卷组及逻辑卷
[root@http1 mysql]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@http1 mysql]# vgcreate myvg /dev/sda3
Volume group "myvg" successfully created
[root@http1 mysql]# lvcreate -L 10G -n mylv myvg
Logical volume "mylv" created
5.文件系统xfs的支持
[root@http1 mysql]# yum install xfsprogs
[root@http1 mysql]# mkfs -t xfs /dev/myvg/mylv
6.实现自动挂载
[root@http1 mysql]# blkid /dev/myvg/mylv
/dev/myvg/mylv: UUID="b7aa948b-89d7-40d6-887b-9821a257c408" TYPE="xfs"
[root@http1 mysql]# vim /etc/fstab
UUID="b7aa948b-89d7-40d6-887b-9821a257c408" /mydata xfs defaults 0 0
[root@http1 mysql]# mkdir /mydata
[root@http1 mysql]# mount -a
7.创建数据在逻辑卷上的存放目录创建,更改目录属主属组
[root@http1 mysql]# mkdir /mydata/data
[root@http1 mysql]# chown -R mysql:mysql /mydata/data
8.初始化安装mariadb
[root@http1 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
[root@http1 mysql]# ls /mydata/data
aria_log.00000001 aria_log_control mysql performance_schema test
9.mariadb配置文件创建,有模版
[root@http1 mysql]# mkdir /etc/mysql
[root@http1 mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf
修改配置文件:
[root@http1 mysql]# vim /etc/mysql/my.cnf
# The MariaDB server
[mysqld]
data_dir = /mydata/data #数据库数据存放目录
port = 3306 #监听端口
socket = /tmp/mysql.sock #套接字文件路径
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
innodb_file_per_table = on #每个innodb文件一个表空间
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8 #线程数量,是cpu核心数*2
10.mariadb服务脚本创建
因为mariadb和mysql是兼容的,直接命名成mysql好记忆
[root@http1 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@http1 mysql]# chkconfig --list mysqld
service mysqld supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add mysqld')
[root@http1 mysql]# chkconfig --add mysqld
11.启动mysqld服务
[root@http1 mysql]# service mysqld start
Starting MySQL... [ OK ]
[root@http1 ~]# ls /mydata/data/
aria_log.00000001 ibdata1 mysql performance_schema
aria_log_control ib_logfile0 mysql-bin.000001 test
http1.stu31.com.pid ib_logfile1 mysql-bin.index
12.测试启动
加入mysql路径进环境变量
[root@http1 mysql]# vim /etc/profile.d/mysqld.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@http1 mysql]# source /etc/profile.d/mysqld.sh
[root@http1 mysql]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.36-MariaDB-log MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select version();
+--------------------+
| version() |
+--------------------+
| 5.5.36-MariaDB-log |
+--------------------+
1 row in set (0.00 sec)
安装完成!