频道栏目
首页 > 资讯 > MySQL > 正文

【MySQL学习笔记】CentOS6.6上源码编译方式安装MySQL5.6

16-08-24        来源:[db:作者]  
收藏   我要投稿

一、安装源码编译配置工具:cmake

先下载cmake工具的源代码:
 

[root@ggg2 Desktop]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
--2016-08-21 22:09:21--  http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Resolving www.cmake.org... 66.194.253.19
Connecting to www.cmake.org|66.194.253.19|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
--2016-08-21 22:09:22--  http://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Resolving cmake.org... 66.194.253.19
Connecting to cmake.org|66.194.253.19|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz [following]
--2016-08-21 22:09:23--  https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Connecting to cmake.org|66.194.253.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5477628 (5.2M) [application/x-gzip]
Saving to: “cmake-2.8.4.tar.gz”

100%[=========================================================>] 5,477,628    101K/s   in 63s     

2016-08-21 22:10:27 (84.8 KB/s) - “cmake-2.8.4.tar.gz” saved [5477628/5477628]

然后切换目录,进行 配置,需要注意的是 ./configure 是源码安装的很重要的一步,对要安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系:

 

 

[root@ggg2 Desktop]# cd cmake-2.8.4
[root@ggg2 cmake-2.8.4]# ./configure
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.

---------------------------------------------
Log of errors: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

 

 

---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on this system is: cc 
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /root/Desktop/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

 

从上面的输出,发现是报错了,仔细查看报错信息,发现是 没有找到合适的c、c++编译器,所以接下来要安装编译器:

 

[root@ggg2 ~]# yum -y install gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-17.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-11.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-17.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-11.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-17.el6 will be an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch            Version                 Repository     Size
================================================================================
Installing:
 gcc                x86_64          4.4.7-17.el6            base           10 M
Installing for dependencies:
 cloog-ppl          x86_64          0.15.7-1.2.el6          base           93 k
 cpp                x86_64          4.4.7-17.el6            base          3.7 M
 mpfr               x86_64          2.4.1-6.el6             base          157 k
 ppl                x86_64          0.10.2-11.el6           base          1.3 M
Updating for dependencies:
 libgcc             x86_64          4.4.7-17.el6            base          103 k
 libgomp            x86_64          4.4.7-17.el6            base          134 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       2 Package(s)

Total size: 16 M
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
 Package: centos-release-6-6.el6.centos.12.2.x86_64 (@anaconda-CentOS-201410241409.x86_64/6.6)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libgcc-4.4.7-17.el6.x86_64                                   1/9 
  Installing : ppl-0.10.2-11.el6.x86_64                                     2/9 
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                              3/9 
  Updating   : libgomp-4.4.7-17.el6.x86_64                                  4/9 
  Installing : mpfr-2.4.1-6.el6.x86_64                                      5/9 
  Installing : cpp-4.4.7-17.el6.x86_64                                      6/9 
  Installing : gcc-4.4.7-17.el6.x86_64                                      7/9 
  Cleanup    : libgomp-4.4.7-11.el6.x86_64                                  8/9 
  Cleanup    : libgcc-4.4.7-11.el6.x86_64                                   9/9 
  Verifying  : libgcc-4.4.7-17.el6.x86_64                                   1/9 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                     2/9 
  Verifying  : gcc-4.4.7-17.el6.x86_64                                      3/9 
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                      4/9 
  Verifying  : libgomp-4.4.7-17.el6.x86_64                                  5/9 
  Verifying  : cpp-4.4.7-17.el6.x86_64                                      6/9 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                              7/9 
  Verifying  : libgcc-4.4.7-11.el6.x86_64                                   8/9 
  Verifying  : libgomp-4.4.7-11.el6.x86_64                                  9/9 

Installed:
  gcc.x86_64 0:4.4.7-17.el6                                                     

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6          cpp.x86_64 0:4.4.7-17.el6          
  mpfr.x86_64 0:2.4.1-6.el6                  ppl.x86_64 0:0.10.2-11.el6         

Dependency Updated:
  libgcc.x86_64 0:4.4.7-17.el6           libgomp.x86_64 0:4.4.7-17.el6          

Complete!
[root@ggg2 cmake-2.8.4]# yum -y install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Processing Dependency: libstdc++ = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.4.7-11.el6 will be updated
---> Package libstdc++.x86_64 0:4.4.7-17.el6 will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-17.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package                     Arch               Version                     Repository        Size
===================================================================================================
Installing:
 gcc-c++                     x86_64             4.4.7-17.el6                base             4.7 M
Installing for dependencies:
 libstdc++-devel             x86_64             4.4.7-17.el6                base             1.6 M
Updating for dependencies:
 libstdc++                   x86_64             4.4.7-17.el6                base             295 k

Transaction Summary
===================================================================================================
Install       2 Package(s)
Upgrade       1 Package(s)

Total download size: 6.6 M
Downloading Packages:
(1/3): gcc-c++-4.4.7-17.el6.x86_64.rpm                                      | 4.7 MB     00:21     
(2/3): libstdc++-4.4.7-17.el6.x86_64.rpm                                    | 295 kB     00:00     
(3/3): libstdc++-devel-4.4.7-17.el6.x86_64.rpm                              | 1.6 MB     00:11     
---------------------------------------------------------------------------------------------------
Total                                                              195 kB/s | 6.6 MB     00:34     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libstdc++-4.4.7-17.el6.x86_64                                                   1/4 
  Installing : libstdc++-devel-4.4.7-17.el6.x86_64                                             2/4 
  Installing : gcc-c++-4.4.7-17.el6.x86_64                                                     3/4 
  Cleanup    : libstdc++-4.4.7-11.el6.x86_64                                                   4/4 
  Verifying  : gcc-c++-4.4.7-17.el6.x86_64                                                     1/4 
  Verifying  : libstdc++-4.4.7-17.el6.x86_64                                                   2/4 
  Verifying  : libstdc++-devel-4.4.7-17.el6.x86_64                                             3/4 
  Verifying  : libstdc++-4.4.7-11.el6.x86_64                                                   4/4 

Installed:
  gcc-c++.x86_64 0:4.4.7-17.el6                                                                    

Dependency Installed:
  libstdc++-devel.x86_64 0:4.4.7-17.el6                                                            

Dependency Updated:
  libstdc++.x86_64 0:4.4.7-17.el6                                                                  

Complete!

安装完成后,可以查看一下c编译器的版本:

 

 

[root@ggg2 ~]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

然后,再次尝试配置,且进行编译、安装:

 

 

[root@ggg2 cmake-2.8.4]# ./configure
此处省略1w行

[root@ggg2 cmake-2.8.4]# gmake && make install
此处省略1k行
至此,cmake工具安装完成, 不容易大笑

 

二、修改mysql用户的限制

主要是在 /etc/security/limits.conf 文件的最后,加上4行,这4行主要是设置mysql用户,能打开的文件个数、能打开的进程数:

 

mysql		 soft    nproc           2047
mysql            hard    nproc           16384
mysql            soft    nofile          1024
mysql            hard    nofile          65536

 

 

[root@ggg2 Desktop]# cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#            
#
#Where:
# can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
# can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
# can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#                 
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

mysql		 soft    nproc           2047
mysql            hard    nproc           16384
mysql            soft    nofile          1024
mysql            hard    nofile          65536

# End of file

三、下载mysql源代码

 

 

[root@ggg2 Desktop]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.12.tar.gz
--2016-08-21 23:01:28--  http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.12.tar.gz
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.12.tar.gz [following]
--2016-08-21 23:01:29--  http://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.12.tar.gz
Resolving cdn.mysql.com... 23.77.240.248
Connecting to cdn.mysql.com|23.77.240.248|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35874671 (34M) [application/x-tar-gz]
Saving to: “MySQL-5.6.12.tar.gz”

100%[=========================================================>] 35,874,671   504K/s   in 72s     

2016-08-21 23:02:41 (487 KB/s) - “MySQL-5.6.12.tar.gz” saved [35874671/35874671]

四:用cmake工具配置mysql源代码

 

不过运行中报错了:

 

[root@ggg2 mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPLILATION_COMMENT='ggg for mysql' \
-DWITH_READLINE=0N \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock


-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:128 (FIND_CURSES)
  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)


-- Configuring incomplete, errors occurred!

从报错信息中可以看出,要删除 CMakeCache.txt文件,然后,对于rehat以及派生的版本,要安装 ncurses-devel:

 

 

[root@ggg2 Desktop]# yum -y install ncurses-devel

 

再次运行cmake:

 

[root@ggg2 mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BALACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPLILATION_COMMENT='ggg for mysql' \
-DWITH_READLINE=0N \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock
.....................
.....................
-- Check size of wchar_t
-- Check size of wchar_t - done
-- Check size of wctype_t
-- Check size of wctype_t - done
-- Check size of wint_t
-- Check size of wint_t - done
-- Found Curses: /usr/lib64/libcurses.so 
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Performing Test HAVE_DECL_TGOTO
-- Performing Test HAVE_DECL_TGOTO - Success
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Looking for include files HAVE_LIBAIO_H
-- Looking for include files HAVE_LIBAIO_H - not found.
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
-- Looking for sched_getcpu
-- Looking for sched_getcpu - found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64 - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Looking for asprintf
-- Looking for asprintf - found
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Using cmake version 2.8.4
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
CMake Warning: The variable, 'COMPLILATION_COMMENT', specified manually, was not used during the generation.
CMake Warning: The variable, 'WITH_BALACKHOLE_STORAGE_ENGINE', specified manually, was not used during the generation.
CMake Warning: The variable, 'WITH_READLINE', specified manually, was not used during the generation.
-- Build files have been written to: /root/Desktop/mysql-5.6.12

五:编译安装

 

整个国产大概要20分钟左右:

 

[root@ggg2 mysql-5.6.12]# make && make install

至此,安装完成大笑
相关TAG标签
上一篇:Mysql学习总结(32)——阿里云centos配置MySQL主从复制
下一篇:MySQL单表数据记录查询
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站