將CentOS部署MySQL須要本地配置環境、本地編譯MySQL,耗時較長的狀況,優化爲編譯成型MySQL並打包,推送並按配置部署。mysql
首先須要在一臺機器配置好環境,搭個YUM源,並將所須要的包取出備用。c++
環境:sql
CentOS-6.3-x86_64-bin-DVD1.isobootstrap
cmake-2.8.3緩存
mysql-5.5.14.tar.gz網絡
1、配置yum源ide
CentOS-Base.repo 是yum 網絡源的配置文件,CentOS-Media.repo 是yum 本地源的配置文件
禁用默認的yum 網絡源,將yum 網絡源配置文件更名爲CentOS-Base.repo.bak,不然會先在網絡源中尋找適合的包,更名以後直接從本地源讀取。oop
##掛載並修改repo文件測試
mkdir /mnt/yum_source/ mount -o rw,remount /export/jiangxu/CentOS-6.3-x86_64-bin-DVD1.iso /mnt/yum_source -o loop ##掛載並可讀寫 echo " [software] name=software baseurl=file:///mnt/yum_source gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6" > /etc/yum.repos.d/yumsource_local.repo echo " # CentOS-Media.repo # # This repo is used to mount the default locations for a CDROM / DVD on # CentOS-6. You can use this repo and yum to install items directly off the # DVD ISO that we release. # # To use this repo, put in your DVD and use it with the other repos too: # yum --enablerepo=c6-media [command] # # or for ONLY the media repo, do this: # # yum --disablerepo=\* --enablerepo=c6-media [command] [c6-media] name=CentOS-$releasever - Media #baseurl=file:///media/CentOS/ # file:///media/cdrom/ # file:///media/cdrecorder/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 baseurl=file:///mnt/yum_source" > /etc/yum.repos.d/CentOS-Media.repo
##清緩存並測試優化
yum clean all yum install -y dos2unix
2、取出rpm包備份
環境所須要的相關包 ncurses* glibc gcc libstdc++* libtool sysstat lrzsz,能夠在/mnt/yum_source/Packages/中取出
3、安裝環境
注意取出的包包含32和64的,yum的時候注意區分
yum install -y /export/jiangxu/Package/*.rpm cd /export/jiangxu//cmake-2.8.3 ./bootstrap && gmake && make install
4、編譯MySQL
-DCMAKE_INSTALL_PREFIX=/export/data/
-DSYSCONFDIR=/export/servers/mysql/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DENABLED_LOCAL_INFILE=ON
cd /export/jiangxu/mysql-5.5.14/ cmake . -DCMAKE_INSTALL_PREFIX=/export/servers/mysql/ -DSYSCONFDIR=/export/servers/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON make && make install
/export/jiangxu/mysql-5.5.14/scripts/mysql_install_db --user=mysql --basedir=/export/servers/mysql/ --datadir=/export/data/mysql/data/
5、新建配置文件
...