11.1 Lamp Architecture Introduction
· LAMP = Linux + Apache (httpd) + MySQL + PHP
Three characters can be in a machine, can also be separated (httpd and PHP to be together)
Apache extracts data from MySQL via PHP module (dynamic request)
The process of website login is a dynamic request
A picture of visiting a website is a static request
11.2 MySQL, Mariadb Introduction
MySQL is a relational database developed by MySQL AB and MySQL was acquired by Sun (US $1 billion) in 2008, and Sun was acquired by Oracle Corporation (US $7.4 billion) in 2009.
MySQL official website https://www.mysql.com latest version 5.7GA/8.0DMR
MySQL5.6 change relatively large, 5.7 performance has been greatly improved
MARIADB is a branch of MySQL, official website https://mariadb.com/Latest Version 10.2
Mariadb mainly by Skysql Company (now renamed MARIADB Company) Maintenance, Skysql company by the MySQL original author led most of the original squad founded.
Mariadb5.5 version corresponds to MySQL 5.5,10.0 corresponding MySQL5.6
Community Community Version (free), Enterprise Business Edition, GA (generally Available) refers to generic version, used in production environment, DMR (development Milestone release) development milestone release, RC (Release Candidate) Release Candidate version, beta Open beta version, alpha internal beta version
11.3/11.4/11.5 MySQL Installation
several common installation packages for MySQL:rpm, source code, binary-free compilation
Binary Compiler-Free package: No compilation, just take it.
Download package to directory:/USR/LOCAL/SRC
[[Email protected] ~]# cd /usr/local/src/[[email protected] src]# ll Total dosage 22176-rw-r--r--. 1 root root 0 January 6 22:20 ]drwxr-xr-x. 12 1001 1001 4096 1 Moon 6 22:39 httpd-2.2.34-rw-r--r--. 1 root root 7684419 7 Month 10 2017 httpd-2.2.34.tar.gzdrwxr-xr-x. 17 1000 1000 4096 1 Moon 6 23:10 php-5.6.30-rw-r--r--. 1 root root 15011816 1 Month 19 2017 php-5.6.30.tar.bz2[[email protected] src]# wget http://mirrors.sohu.com/mysql/mysql-5.6/ Mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz--2018-01-29 22:30:42-- http://mirrors.sohu.com/mysql /mysql-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar. GZ Parsing host mirrors.sohu.com (mirrors.sohu.com) ... 221.236.12.140 connecting mirrors.sohu.com (mirrors.sohu.com) |221.236.12.140|:80... is connected. Issued HTTP request, waiting to respond ... 200 ok length:314581668 (300M) [application/octet-stream] saving to: "Mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz" 100%[======================================================== ====================================================================>] 314,581,668 1.37mb/s Spents 3m 45s 2018-01-29 22:34:28 (1.33 mb/s) - saved Mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz " [314581668/314581668]) unzip the GZ package and move the directory to/usr/local/, and renamed MySQL (not to be placed under MySQL) [[email protected] src]# tar -zxvf Mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [[email protected] src]# ll Total Dosage 329388- Rw-r--r--. 1 root root 0 1 Month    6 22:20 ]drwxr-xr-x. 12 1001 1001 4096 1 Month 6 22:39 httpd-2.2.34-rw-r--r--. 1 root root 7684419 7 Month 10 2017 httpd-2.2.34.tar.gzdrwxr-xr-x. 13 root root 191 1 Month 29 22:40 mysql-5.6.35-linux-glibc2.5-x86_64- Rw-r--r--. 1 root root 314581668 11 Month 28 2016 mysql-5.6.35-linux-glibc2.5-x86_64.tar.gzdrwxr-xr-x. 17 1000 1000 4096 1 month 6 23:10 php-5.6.30-rw-r--r--. 1 root root 15011816 1 Month 19 2017 php-5.6.30.tar.bz2[[email protected] src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql [[email protected] src]# cd /usr/Total dosage of Local/mysql/[[email protected] mysql]# ll 48drwxr-xr-x. 2 root Root 4096 1 Moon 29 22:40 bin-rw-r--r--. 1 7161 31415 17987 11 Month 28 2016 COPYINGdrwxr-xr-x. 3 root root 18 1 Month 29 22:40 datadrwxr-xr-x. 2 root Root 55 1 Month 29 22:40 docsdrwxr-xr-x. 3 Root root 4096 1 Month 29 22:40 includedrwxr-xr-x. 3 root root 4096 1 Month 29 22:40 libdrwxr-xr-x. 4 root root 30 1 month 29 22:40 mandrwxr-xr-x. 10 root root 4096 1 month 29 22:40 mysql-test-rw-r--r--. 1 7161 31415 2496 11 Month 28 2016 READMEdrwxr-xr-x. 2 root root 30 1 Month 29 22:40 scriptsdrwxr-xr-x. 28 root Root 4096 1 Month 29 22:40 sharedrwxr-xr-x. 4 root Root 4096 1 Month 29 22:40 sql-benchdrwxr-xr-x. 2 root root 136 1 Month 29 22:40 support-files
Initialization
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/ Mysqlfatal error: please install the following perl modules before executing ./scripts/mysql_install_db:data::D umper# #缺少perl dumper pack [[email protected] mysql]# yum list |grep perl |grep -i dumper## Try to find perl-data-dumper.x86_64 first. 2.145-3.el7 baseperl-Data-Dumper-Concise.noarch 2.020-6.el7 epelperl-Data-Dumper-Names.noarch 0.03-17.el7 epelperl-XML-Dumper.noarch 0.81-17.el7 base[[email protected] mysql]# yum install -y perl-data-dumper.x86_64 (procedure omitted) [[email protected] mysql]# ./ Scripts/mysql_install_db --user=mysql --datadir=/data/mysql (Process omission) [[Email protected] mysql] # echo $?0[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
(If the system comes with/ETC/MY.CNF, you can edit it directly)
[[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld[[email protected] mysql]# vim/etc/init.d/ Mysqld
[[email protected] mysql]# chkconfig --add mysqld# #设置服务开机启动 [[email protected] mysql]# chkconfig --list Note: This output shows only the SysV service and does not include native systemd services. sysv configuration data may be overwritten by native systemd configuration. To list systemd services, perform ' systemctl list-unit-files '. To view the services in the specific target enabled please perform ' systemctl list-dependencies [target '. Mysqld 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: Off 6: Off network 0: off 1: Off 2: Open 3: Open 4: Off 5: Off 6: Off [ [Email protected] mysql]# service mysqld startstarting mysql.logging to '/data/mysql/localhost.localdomain.err ' ... success! [[email protected] mysql]# ps aux |grep mysqldroot 1532 0.0 0.1 11768 1564 pts/0 s 22:38 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pidmysql 1667 40.8 45.2 973060 452004 pts/0 Sl 22:38 0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/ data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/ localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/ mysql.sockroot 1697 0.0 0.0 112676 984 pts/0 r+ 22:38 0:00 grep --color=auto mysqld[[email protected] mysql]# netstat -lntpactive internet connections (only sErvers) proto recv-q send-q local address Foreign Address State PID/Program nametcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 922/sshdtcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1031/mastertcp6 0 0 :::22 :::* listen 922/sshdtcp6 0 0 ::1:25 :::* listen 1031/mastertcp6 0 0 :::3306 :::* listen 1667/mysqld
If the template/etc/my.cnf is not configured, use the command line method:
[[Email protected] mysql]# service mysqld stopshutting down mysql]. success! [[Email protected] mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &[1] 1848[[email protected] mysql]# 180131 22:45:06 mysqld_safe Logging to '/data/mysql/localhost.localdomain.err '. 180131 22:45:06 mysqld_safe starting mysqld daemon with databases from /data/mysql[[email protected] mysql]# !psps aux |grep mysqldroot 1848 0.0 0.1 113264 1588 pts/0 s 22:45 0:00 /bin/sh /usr/local/ mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysqlmysql 1971 1.3 45.1 973060 451300 pts/0 sl 22:45 0:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf -- Basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user= mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/ localhost.localdomain.pid --socket=/tmp/mysql.sockroot 1994 0.0 0.0 112676 980 pts/0 R+   22:45   0:00 GREP --COLOR=AUTO MYSQLD (--defaults-file= specified configuration file)
Command line-initiated service, Killall mysqld off
process kill, data too large need to write, do not force kill-9 kill process, otherwise very easy to lose data or corrupt table
2018-2-26 9 weeks 4 lessons LAMP, MySQL installation