将CentOS部署MySQL需要本地配置环境、本地编译MySQL,耗时较长的情况,优化为编译成型MySQL并打包,推送并按配置部署。
首先需要在一台机器配置好环境,搭个YUM源,并将所需要的包取出备用。
环境:
CentOS-6.3-x86_64-bin-DVD1.iso
cmake-2.8.3
mysql-5.5.14.tar.gz
一、配置yum源
CentOS-Base.repo 是yum 网络源的配置文件,CentOS-Media.repo 是yum 本地源的配置文件
禁用默认的yum 网络源,将yum 网络源配置文件改名为CentOS-Base.repo.bak,否则会先在网络源中寻找适合的包,改名之后直接从本地源读取。
##挂载并修改repo文件
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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
二、取出rpm包备份
环境所需要的相关包 ncurses* glibc gcc libstdc++* libtool sysstat lrzsz,可以在/mnt/yum_source/Packages/中取出
三、安装环境
注意取出的包包含32和64的,yum的时候注意区分
yum install -y /export/jiangxu/Package/*.rpm cd /export/jiangxu//cmake-2.8.3 ./bootstrap && gmake && make install
四、编译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/
五、新建配置文件
...