编译安装LAMP之mysql-5.6(通用二进制格式)

MySQL struggling 1454次浏览 0个评论

在mysql5.6的版本以后,配置与mysql5.5版本相比发生了细小的变化,下面就以mysql-5.6.23来编译,实验环境为CentOS6.6。

一,准备工作
先下载所需的安装包mysql-5.6.23-linux-glibc2.5-i686 ,下载地址 http://mirrors.sohu.com/mysql/MySQL-5.5/ 

编译安装的目录:/usr/local/

二,编译安装

1、准备数据存放的文件系统,与上次编译时的做法相同。

新建一个逻辑卷,并将其挂载至特定目录即可。这里创建逻辑卷的挂载目录为/mydata,而后创建/mydata/data目录做为mysql数据的存放目录。创建逻辑卷是为了方便数据的备份及转移,设置数据存放目录的大小。

<code>
[root@www ~]# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 4
First cylinder (1307-2610, default 1307): 
Using default value 1307
Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): 
Using default value 2610

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1307-2610, default 1307): 
Using default value 1307
Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): +8G

Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9f95503f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1306    10490413+  83  Linux
/dev/sdb4            1307        2610    10474380    5  Extended
/dev/sdb5            1307        2351     8393931   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

</code>
<code>
[root@www ~]# partprobe /dev/sdb
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

[root@www ~]# partprobe /dev/sdb

[root@www ~]# pvcreate /dev/sdb5
Physical volume "/dev/sdb5" successfully created

[root@www ~]# vgcreate myvg /dev/sdb5              #创建为myvg的卷组
  Volume group "myvg" successfully created

[root@www ~]# lvcreate -n  mydata -L 5G myvg
  Logical volume "mydata" created

[root@www ~]# lvs
  LV     VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  mydata myvg -wi-a----- 5.00g       
                                             
[root@www ~]# mke2fs -j /dev/myvg/mydata 
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
。。。。。。。。。。


</code>

2、新建系统用户以其运行进程:

<code>
[root@www mysql]# groupdel mysql
[root@www mysql]# groupadd -r -g 306 mysql
[root@www mysql]# useradd -r -g 306 -u  306  mysql
[root@www mysql]# id  mysql
uid=306(mysql) gid=306(mysql) groups=306(mysql)
</code>

3、安装并初始化mysql-5.6.23

<code>
[root@www ~]# tar xf mysql-5.6.23-linux-glibc2.5-i686.tar.gz -C /usr/local
[root@www ~]# cd /usr/local/
[root@www ~]# ln -sv mysql-5.6.23-linux-glibc2.5-i686  mysql
[root@www ~]# cd mysql 

[root@www ~]# chown -R mysql:mysql  .   
[root@www ~]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data   
[root@www ~]# chown -R root  .
</code>

4、为mysql提供主配置文件

5.6与5.5的不同主要在此。

执行第三步后,会在mysql目录下创建my.cnf文件。
执行# scripts/mysql_install_db –user=mysql –datadir=/mydata/data 以前mysql目录下的文件:

<code>
[root@localhost mysql]# ls
bin      data  include         lib  mysql-test  scripts  sql-bench
COPYING  docs  INSTALL-BINARY  man  README      share    support-files
</code>

执行后的文件:

<code>
[root@localhost mysql]# ls
bin      data  include         lib  my.cnf      README   share      support-files
COPYING  docs  INSTALL-BINARY  man  mysql-test  scripts  sql-bench
</code>

mysql5.6.10以后的版本不需要复制文件

<code>
[root@localhost mysql]# cp support-files/my-large.cnf  /etc/my.cnf
</code>

文件夹中有my.cnf 文件,只需修改此文件即可,也可以将support-files/my-default.cnf 文件复制过去,
但需要将文件的data选项和socket选项启用。

<code>
[root@localhost mysql]# vim my.cnf 
# These are commonly set, remove the # and set as required.
# basedir = .....
 datadir = /mydata/data
# port = .....
# server_id = .....
socket = /tmp/mysql.sock
</code>

5、修改PATH环境变量,让系统可以直接使用mysql的相关命令。

<code>
[root@www ~]# vim  /etc/profile.d/mysql.sh 
 export PATH=$PATH:/usr/local/mysql/bin/   ------>创建此文件添加此行
</code>

6、为mysql提供sys v服务脚本:

<code>
[root@www ~]# cd /usr/local/mysql
[root@www mysql]# cp support-files/mysql.server  /etc/init.d/mysqld
[root@www mysql]# chmod +x /etc/init.d/mysqld
</code>

添加至服务列表:

<code>
[root@www mysql]# chkconfig --add mysqld
[root@www mysql]# chkconfig mysqld on
</code>

而后就可以启动服务测试使用了。

三,测试结果

此处不需要将mysqld服务添加到chkconfig中,默认已经添加了。

<code>
[root@localhost ~]# service mysqld  start
Starting MySQL...................................... SUCCESS! 
[root@localhost bin]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.23 MySQL Community Server (GPL)         ------>5.6.23

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
</code>

说明已经安装成功了!


DevOps-田飞雨 》》转载请注明源地址
喜欢 (0)or分享 (0)
发表我的评论
取消评论
*

表情 贴图 加粗 链接 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址