二進位安裝MariaDB5.5.36
二進位安裝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)
安裝完成!
在 CentOS/RHEL/Scientific Linux 6 下安裝 LAMP (Apache with MariaDB and PHP)
MariaDB Proxy讀寫分離的實現
Linux下編譯安裝配置MariaDB資料庫的方法
CentOS系統使用yum安裝MariaDB資料庫
安裝MariaDB與MySQL並存
Ubuntu 上如何將 MySQL 5.5 資料庫遷移到 MariaDB 10
[翻譯]Ubuntu 14.04 (Trusty) Server 安裝 MariaDB