Linux—mysql資料庫(二)二進位制格式安裝mariadb-server
阿新 • • 發佈:2018-11-29
環境 centos7
準備:mariadb-10.2.18-linux-x86_64.tar 二進位制安裝包
二進位制格式安裝過程
[[email protected] ~]# rpm -q --scripts mariadb-server
preinstall scriptlet (using /bin/sh):
/usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || :
-g gid -o 忽略id衝突 -r 系統使用者
-M 不建立家目錄 -N 出建立私有組
-m 建立家目錄 -d 家目錄路徑 -s /shell型別 -g 指定主組
/usr/sbin/useradd -M -N -g mysql -o -r -d /var/lib/mysql -s /sbin/nologin \
-c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || :
步驟如下:
匯入 mariadb-10.2.18-linux-x86_64.tar 二進位制安裝包
[[email protected] ~]# rz rz waiting to receive. Starting zmodem transfer. Press Ctrl+C to cancel. Transferring mariadb-10.2.18-linux-x86_64.tar.gz... 100% 445449 KB 23444 KB/sec 00:00:19 0 Errors
第一步:建立邏輯卷
[[email protected]]fdisk /dev/sda
[[email protected] ~]# partprobe ###同步磁碟
[[email protected] ~]# pvcreate /dev/sda7
Physical volume "/dev/sda7" successfully created. ##建立物理卷
[[email protected] ~]# vgcreate vg_data /dev/sda7 ##把物理卷新增到卷組
Volume group "vg_data" successfully created
[ [email protected] ~]# lvcreate -n lv_mysql -l 100%FREE vg_data ##把卷組磁碟空間分配給邏輯卷
Logical volume "lv_mysql" created.
[[email protected] ~]# mkfs.xfs /dev/vg_data/lv_mysql ##格式化磁碟
[[email protected] ~]# blkid ##檢視建立情況
[[email protected] ~]# vim /etc/fstab ##編輯掛載點
:r!blkid /dev/vg_data/lv_mysql
第二步:準備使用者
[[email protected] ~]# useradd -r -s /sbin/nologin -M -d /mysql/data mysql
第三步:準備資料目錄
[[email protected] ~]#chown mysql:mysql /root/mysql
第四步:準備二進位制程式
[[email protected] local]# tar xfv mariadb-10.2.18-linux-x86_64.tar.gz -C /usr/local
[[email protected] local]# ln -s mariadb-10.2.18-linux-x86_64/ mysql ##建立軟連線
[[email protected] local]# chown -R root.mysql mysql/ ##修改檔案的所有者所屬組
[[email protected] local]# cd mysql/
[[email protected] mysql]# cd support-files/
第五步:準備配置檔案
[[email protected] support-files]# mkdir /etc/mysql
第六步:建立資料庫檔案
[[email protected] support-files]# cp my-huge.cnf /etc/mysql/my.cnf
[[email protected] support-files]# vim /etc/mysql/my.cnf
[mysqld]
datadir=/mysql/data ##增加
[[email protected] mysql]# cd .. ##執行指令碼時需退回到mysql資料夾,因為依賴與bin目錄
[[email protected] mysql]# scripts/mysql_install_db --datadir=/mysql/data --user=mysql
[[email protected] mysql]# ll /mysql/data/
第七步:準備服務指令碼,並啟動服務
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# ll /etc/init.d/mysqld
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig --list
第八步:安全初始化
[[email protected] support-files]# service mysqld start
[[email protected] bin]# echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql.sh
[[email protected] bin]# . /etc/profile.d/mysql.sh
[[email protected] ]#ss -ntl
**********************************************完成***************************************