Preparing the Data Catalog
For the convenience of data security and later expansion, I chose to create the MySQL Data directory on the LVM .
[Email protected] ~]# echo "---" >/sys/class/scsi_host/host2/scan Virtual machine Add a new disk you can perform a disk scan of a virtual machine by executing the following command. Makes it possible to recognize new disks without restarting the machine [email protected] ~]# Pvcreate/dev/sdb # Create a physical volume Physical volume "/dev/sdb" successfully created. [email protected] ~]# vgcreate vg_dbdata/dev/sdb Create a volume group named Vg_dbdata Volume Group "Vg_dbdata" successfully created [email protected] ~]# lvcreate-l 10g-n lv_data vg_dbdata create a logical volume on the volume group with a capacity of 10G , the space is not enough words can be enlarged. Logical volume "Lv_data" created. [email protected] ~]# Mkfs.xfs/dev/vg_dbdata/lv_data # creating a file system [email protected] ~]# mkdir-p/mydata/data # set up the data directory and then mount it. It is best to mount with the UUID of the partition , because the file name of the disk changes due to some factors. [Email protected] ~]# ll/dev/dm-2 BRW-RW----1 root disk 253, 2 Sep 03:25/dev/dm-2 [Email protected] ~]# blkid/dev/dm-2 /dev/dm-2: uuid= "fcd13fae-9245-4ff1-9b0f-2723f157dd0d" type= "XFS" [Email protected] ~]# Mount–a |
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A5/FF/wKioL1nHWsnQACnGAABODE8zl6k014.png "title=" Mysq.png "width=" 650 "height=" 231 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:650px;height:231px; "alt=" Wkiol1nhwsnqacngaabode8zl6k014.png "/>
Create users and Groups
[[email protected] ~]# ID mysql id: mysql:no such user [[email protected] ~]# useradd-r-u 306 mysql [[email protected] ~]# ID mysql uid=306 (MySQL) gid=306 (MySQL) groups =306 (MySQL) [[email protected] ~]# chown–r mysql.mysql/mydata/data Modify Data Directory owner |
Installing MARIADB
[[email protected] tools]# tar xf mariadb-10.2.8-linux-x86_64.tar.gz-c/usr/local/ [[email protected] tools]# cd/usr/local/ You must establish a soft connection, or extract the previous step directly to the/usr/local/mysql directory mysql ' ' mariadb-10.2.8-linux-x86_64 ' [[email protected] local]# CD mysql/ |
The installation package in the binary common format is the program that the official has packaged after compiling the source package for the corresponding platform. So just copy the corresponding file to the corresponding directory to do a simple configuration.
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/07/4E/wKiom1nHWzXQ__y9AAAqECb4SLU652.png "title=" 1.png "Width=" 650 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:650px;height:73px; "alt=" wkiom1nhwzxq__ Y9aaaqecb4slu652.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/07/4E/wKiom1nHW0CATOZ_AABq3iFnEZo105.png "title=" 2.png "alt=" Wkiom1nhw0catoz_aabq3ifnezo105.png "/>
Installing the Database
[email protected] mysql]#./scripts/mysql_install_db--datadir=/mydata/data The data directory created by the system's default database security device, do not enter the scripts directory. Installing Mariadb/mysql system tables in '/mydata/data ' ... [Email protected] mysql]# ls/mydata/data/ aria_log.00000001 ib_buffer_pool ib_logfile0 MySQL test Aria_log_control ibdata1 Ib_logfile1 Performance_schema under this directory One directory for a database |
Install the service script
Copy the service script to /etc/init.d and rename it to mysqld service This allows you to manage the MYSQLD service by using the system's default management method .
[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld [email protected] mysql]# chkconfig--add mysqld Join system service Management |
Install the configuration file
There are multiple configuration files under the/usr/local/mysql/support-files/directory. Different profiles can be used depending on the requirements.
[Email protected] mysql]# Mkdir/etc/mysql [Email protected] mysql]# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-LARGE.CNF/ETC/MYSQL/MY.CNF [email protected] mysql]# vim/etc/mysql/my.cnf edit the configuration file. |
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A5/FF/wKioL1nHWxLyRWbkAABHWFsAuMI227.png "title=" 3.png "Width=" 650 "height=" 217 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:650PX;HEIGHT:217PX; "alt=" Wkiol1nhwxlyrwbkaabhwfsaumi227.png "/>
Configuring Environment variables
[email protected] mysql]# cat >/etc/profile.d/mysql.sh <<eof > Path=/usr/local/mysql/bin: $PATH > EOF [Email protected] mysql]#. /etc/profile.d/mysql.sh |
Configuration log files
[[email protected] ~]# mkdir/var/log/mariadb must create a log directory [Email protected] ~]# chown-r mysql.mysql/var/log/mariadb [[Email protected] ~]# service mysqld start Starting mysqld (via Systemctl): [ OK ] |
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A5/FF/wKioL1nHWx6i26ORAAA5j9jaMss799.png "title=" 4.png "Width=" 650 "height=" 229 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:650PX;HEIGHT:229PX; "alt=" Wkiol1nhwx6i26oraaa5j9jamss799.png "/>
The database is now installed. However, when the data is not secure enough, any user can log in with root or use an anonymous account, so some security initialization settings are required. In mariadb 's generic binary installation package, there is a script that performs security initialization directly.
Secure initialization
Initialize script path /usr/local/mysql/bin/mysql_secure_installation
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/07/4E/wKiom1nHW2Th1ibvAABV14yZVZ8649.png "title=" 5.png "Width=" 650 "height=" 335 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:650px;height:335px; "alt=" Wkiom1nhw2th1ibvaabv14yzvz8649.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A5/FF/wKioL1nHWzbAMRDVAABlNLlihdw964.png "title=" 6.png "Width=" 650 "height=" 342 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:650px;height:342px; "alt=" Wkiol1nhwzbamrdvaablnllihdw964.png "/>
This article is from the "Keep Simple Keep Stupid" blog, make sure to keep this source http://yangzhiheng.blog.51cto.com/11586378/1968185
Install MARIADB or MySQL using the Universal binary method