00 实验环境

  1. # 发行版信息
  2. [root@localhost ~]# cat /etc/redhat-release
  3. CentOS Linux release 7.6.1810 (Core)
  4. # 内核
  5. [root@localhost ~]# uname -r
  6. 3.10.0-957.el7.x86_64
  7. # 时间
  8. [root@localhost ~]# date
  9. Tue Jan 8 23:27:19 CST 2019

01 实验目的

在本机上通过编译安装的方式安装mysql多实例并配置

02 实验软件选择

020 nginx选择版本

nginx-1.14.2.tar.gz 源码编译
软件地址: http://nginx.org/download/nginx-1.14.2.tar.gz

03 准备安装

030 准备安装环境目录(也可以在安装好后配置)

  1. [root@localhost ~]# tree /data
  2. /data
  3. ├── 3306
  4. │ ├── data # 数据文件
  5. │ ├── my.cnf # 配置文件
  6. │ └── mysql # 启动文件
  7. └── 3307
  8. ├── data
  9. ├── my.cnf
  10. └── mysql
  11. 4 directories, 4 files

031 首先获取mysql的源代码

  1. [root@localhost ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.41.tar.gz
  2. [root@localhost ~]# ls
  3. anaconda-ks.cfg mysql-5.6.41.tar.gz onepiece

032 解压

  1. [root@chery ~]# mkdir tools
  2. [root@chery ~]# cp mysql-5.6.41.tar.gz tools/
  3. [root@chery ~]# cd tools/
  4. [root@chery tools]# ls
  5. mysql-5.6.41.tar.gz
  6. [root@chery tools]# tar xf mysql-5.6.41.tar.gz
  7. [root@chery tools]#

033 安装依赖包和工具包

  1. [root@chery mysql-5.6.41]# yum install -y ncurses-devel libaio-devel
  2. [root@chery mysql-5.6.41]# yum install gcc gcc-c++
  3. [root@chery mysql-5.6.41]# yum install ncurses-devel
  4. [root@chery mysql-5.6.41]# yum install bison
  5. [root@chery mysql-5.6.41]# yum install cmake -y
  6. [root@chery mysql-5.6.41]# yum install autoconf -y

如果不安装autoconf就在初始化数据库的时候,就报错了
例如:
[root@chery scripts]# ./mysql_install_db —basedir=/application/mysql/ —datadir=/data/3306/data —user=mysql
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper

034 创建用户

  1. [root@chery ~]# useradd mysql -s /sbin/nologin -M
  2. [root@chery ~]# id mysql-5.6.41
  3. id: mysql-5.6.41: no such user
  4. [root@chery ~]# id mysql
  5. uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
  6. [root@chery ~]#

04 开始安装

041 cmake初始化参数

  1. cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6 \
  2. -DMYSQL_DATADIR=/application/mysql-5.6/data \
  3. -DMYSQL_UNIX_ADDR=/application/mysql-5.6/tmp/mysql.sock \
  4. -DDEFAULT_CHARSET=utf8 \
  5. -DDEFAULT_COLLATION=utf8_general_ci \
  6. -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
  7. -DENABLED_LOCAL_INFILE=ON \
  8. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  9. -DWITH_FEDERATED_STORAGE_ENGINE=1 \
  10. -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
  11. -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
  12. -DWITHOUT_PARTITION_STORAGE_ENGINE=0 \
  13. -DWITH_FAST_MUTEXES=1 \
  14. -DWITH_ZLIB=bundled \
  15. -DENABLED_LOCAL_INFILE=1 \
  16. -DWITH_READLINE=1 \
  17. -DWITH_EMBEDDED_SERVER=1 \
  18. -DWITH_DEBUG=0

关于配置参数: https://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

042 make和make install

  1. [root@chery mysql-5.6.41]# make

过程很慢 如果没有报错就是最好的结果

如果编译成功 就可以 编译安装

  1. [root@chery mysql-5.6.41]# make install

043 查看安装目录并创建软连接

  1. [root@chery mysql-5.6.41]# ln -s /application/mysql-5.6/ /application/mysql
  2. [root@chery mysql-5.6.41]# ls -l /application/mysql
  3. lrwxrwxrwx. 1 root root 23 Jan 8 20:42 /application/mysql -> /application/mysql-5.6/
  4. [root@chery mysql-5.6.41]#
  5. [root@chery mysql-5.6.41]# ls -l /application/mysql/
  6. total 48
  7. drwxr-xr-x. 2 root root 4096 Jan 8 20:36 bin
  8. -rw-r--r--. 1 root root 17987 Jun 15 2018 COPYING
  9. drwxr-xr-x. 3 root root 18 Jan 8 20:36 data
  10. drwxr-xr-x. 2 root root 55 Jan 8 20:36 docs
  11. drwxr-xr-x. 3 root root 4096 Jan 8 20:36 include
  12. drwxr-xr-x. 3 root root 4096 Jan 8 20:36 lib
  13. drwxr-xr-x. 4 root root 30 Jan 8 20:36 man
  14. drwxr-xr-x. 10 root root 4096 Jan 8 20:36 mysql-test
  15. -rw-r--r--. 1 root root 2496 Jun 15 2018 README
  16. drwxr-xr-x. 2 root root 30 Jan 8 20:36 scripts
  17. drwxr-xr-x. 28 root root 4096 Jan 8 20:36 share
  18. drwxr-xr-x. 4 root root 4096 Jan 8 20:36 sql-bench
  19. drwxr-xr-x. 2 root root 136 Jan 8 20:36 support-files
  20. [root@chery mysql-5.6.41]#

044 查看配置文件

  1. [root@chery mysql-5.6.41]# ls support-files/my*.cnf
  2. support-files/my-default.cnf
  3. [root@chery mysql-5.6.41]#

pass

yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl openssl-devel -y

快速安装Nginx的步骤(root用户)

  1. # 快速安装Nginx的步骤(root用户)
  2. yum install pcre pcre-devel lsof -y
  3. rpm -qa pcre pcre-devel
  4. yum install openssl openssl-devel -y
  5. rpm -qa openssl openssl-devel
  6. mkdir -p /root/tools
  7. cd /root/tools
  8. wget -q http://nginx.org/download/nginx-1.14.2.tar.gz
  9. ls
  10. tar xf nginx-1.14.2.tar.gz
  11. cd nginx-1.14.2
  12. useradd www -s /sbin/nologin -M
  13. ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/opt/nginx-1.14.2
  14. echo $?
  15. make
  16. make install
  17. ln -s /opt/nginx-1.14.2 /opt/nginx
  18. ##start Nginx
  19. /opt/nginx/sbin/nginx
  20. ##check Port 80
  21. netstat -lntup|grep 80
  22. lsof -i :80
  23. hostname -I

ln -s /opt/nginx-1.14.2/sbin/nginx /usr/bin/nginx

echo 'alias nginx="/opt/nginx/sbin/nginx"'>>~/.bashrc
#这里是快速批处理命令,粘贴复制到终端命令行即可,注意先调整成为root用户
yum install pcre pcre-devel -y
rpm -qa pcre pcre-devel
yum install openssl openssl-devel -y
rpm -qa openssl openssl-devel
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
ls
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
useradd www -s /sbin/nologin -M
./configure —user=www —group=www —with-http_ssl_module —with-http_stub_status_module —prefix=/application/nginx-1.6.3/
echo $?
make
make install
ln -s /application/nginx-1.6.3/ /application/nginx
##start Nginx
/application/nginx/sbin/nginx
##check Port 80
netstat -lntup|grep 80
lsof -i :80
ifconfig|awk -F “[ :]+” ‘NR==2’’{print $4}’

这里是快速批处理命令,粘贴复制到终端命令行即可,注意先调整成为root用户
yum install pcre pcre-devel -y
rpm -qa pcre pcre-devel
yum install openssl openssl-devel -y
rpm -qa openssl openssl-devel
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
ls
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
useradd www -s /sbin/nologin -M
./configure —user=www

—group=www —with-http_ssl_module —with-http_stub_status_module —prefix=/application/nginx-1.6.3/
echo $?
make
make install
ln -s /application/nginx-1.6.3/ /application/nginx
##start Nginx
/application/nginx/sbin/nginx
##check Port 80
netstat -lntup|grep 80
lsof -i :80
ifconfig|awk -F “[ :]+” ‘NR==2’’{print $4}’