MySQL多实例的好处就不多说了 这里直接进入主题
一、格式化并挂载文件系统
将/dev/sdb 格式化为ext4
mkfs.ext4 -L DB /dev/sdb mkdir /disk2 mount /dev/sdb /disk2在配置文件fstab中添加如下内容
/dev/sdb /disk2 ext4 defaults 0 0
二、建立如下格式目录
/disk2/mysql5.1/data/3316,3317,3318
/disk2/mysql5.2/data/3326,3327,3328
/disk2/mysql5.5/data/3356,3357,3358
三、分别编译安装mysql 5.1 5.2 5.5三个包
下载地址分别为:
tar xf mysql-5.1.60.tar.gz cd mysql-5.1.60 ./configure --prefix=/disk2/mysql5.1/ --with-charset=gb2312 --with-extra-charsets=utf8,gb2312 --with-extra-charsets=gbk,gb2312 make make install ./configure --prefix=/disk2/mysql5.2/ --with-charset=gb2312 --with-extra-charsets=utf8,gb2312 --with-extra-charsets=gbk,gb2312 make make install tar xf /mysql-5.5.25a.tar.gz tar xf cmake-2.8.6.tar.gz tar xf cmake-2.8.6.tar.gz cd cmake-2.8.6 ./configure make make install cd .. tar xf mysql-5.5.25a.tar.gz cd mysql-5.5.25a cmake -DCMAKE_INSTALL_PREFIX=/disk2/mysql5.5 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3306 -DWITH_DEBUG=OFF -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock make make install cd /usr/local/webserver/mysql
四、分别初始化以上九个数据目录
cd /disk2/mysql5.1/bin ./mysql_install_db --datadir=/disk2/mysql5.1/data/3316 --user=mysql ./mysql_install_db --datadir=/disk2/mysql5.1/data/3317 --user=mysql ./mysql_install_db --datadir=/disk2/mysql5.1/data/3318 --user=mysql cd /disk2/mysql5.5/scripts ./mysql_install_db --datadir=/disk2/mysql5.5/data/3356 --user=mysql ./mysql_install_db --datadir=/disk2/mysql5.5/data/3356 --user=mysql ./mysql_install_db --datadir=/disk2/mysql5.5/data/3356 --user=mysql chown -R mysql:mysql /disk2/mysql5.1/data/* chown -R mysql:mysql /disk2/mysql5.2/data/* chown -R mysql:mysql /disk2/mysql5.5/data/*