set up mysql on centos/linux

6 篇文章 0 订阅
3 篇文章 0 订阅
Refer to:
http://smilemonkey.iteye.com/blog/673848
http://heimuad.iteye.com/blog/129932
http://www.cnblogs.com/smalldirector/archive/2011/12/27/2303648.html # port

set up mysql 5.5 using by make
http://icooke.blog.51cto.com/4123148/764796

http://www.j927.net/lamp/centos-6-3-minimal%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85mysql-5-5-27.html


.src.rpm文件解压缩及MySql的安装

http://dev.mysql.com/downloads/mysql/5.6.html#downloads 下载5.6版本
安装参照如下:

1、用rpm解压

# rpm -ivh MySQL-5.5.8-1.linux2.6.src.rpm




2、第1步完成后,在/usr/src/redhat目录下,生成了两个新目录。

# pwd
/usr/src/redhat
# ls -rlt
drwxr-xr-x 2 root root 4096 Jan 15 07:20 SPECS
drwxr-xr-x 2 root root 4096 Jan 15 07:20 SOURCES
#



3、进入SOURCES目录。

# cd SOURCES/
# ls -lrt
-rw-r--r-- 1 root root 24258297 Dec 3 13:32 mysql-5.5.8.tar.gz
# tar zxvf ./mysql-5.5.8.tar.gz




4、安装

1)、CMAKE的下载和安装【CMAKE是一个跨平台的编译工具,C代表 CROSS-PLATFORM】:

http://www.cmake.org/cmake/resources/software.html

# tar zxvf cmake-2.8.3.tar.gz
# cd cmake-2.8.3
# ./configure

# make

# make install


2)、mysql的安装
# cd mysql-5.5.8
# cmake .

此时,就生成了 Makefile文件,这就好办了。这里我们看到,cmake的作用就是为了生成Makefile文件。

# make
# make install
缺省就安装在 /usr/local/mysql目录下。



系统:centos 5.5
需要的软件包:mysql-5.5.22.tar.gz
1.安装前准备
1
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
2
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel \
3
glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel cmake \
# yum install glibc
4
ncurses ncurses-devel curl curl-devel vim ntsysv make libtool
# yum install ncurses ncurses-devel
1
wget http://download.slogra.com/mysql/mysql-5.5.22.tar.gz
2
useradd -M -r -s /sbin/nologin mysql


2.安装配置第1个mysql
tar zxf mysql-5.5.22.tar.gz && cd mysql-5.5.22
01
cmake . \
02
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
03
-DMYSQL_DATADIR=/data0/mysql/3306/data \
04
-DMYSQL_UNIX_ADDR=/data0/mysql/3306/mysqld.sock \
05
-DWITH_MYISAM_STORAGE_ENGINE=1 \
06
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
07
-DWITH_BLACKHOLE_STORAGE_ENGINE=0 \
08
-DWITH_ARCHIVE_STORAGE_ENGINE=0 \
09
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
10
-DENABLED_LOCAL_INFILE=1 \
11
-DMYSQL_TCP_PORT=3306 \
12
-DEXTRA_CHARSETS=all \
13
-DDEFAULT_CHARSET=utf8 \
14
-DDEFAULT_COLLATION=utf8_general_ci \
15
-DWITH_DEBUG=0 \
16
-DWITH_EMBEDDED_SERVER=1 \
17
-DWITH_SSL=system \
18
-DWITH_READLINE=1

这里的编译参数有几项你们可以根据自己的情况设置.我将第1个mysql运行在3306端口,安装目录是/usr/local/mysql,数据库存放位置是/data0/mysql/3306/data,mysql启动文件位置是/data0/mysql/3306/mysqld.sock.
然后执行编译和安装命令
make
make install
然后配置目录权限
chmod +w /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
这里要创建下mysql的数据库存放目录
mkdir -p /data0/mysql/3306/data/
mkdir -p /data0/mysql/3306/binlog/
mkdir -p /data0/mysql/3306/relaylog/
chown -R mysql.mysql /data0/mysql/
然后执行数据初始化
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data0/mysql/3306/data --user=mysql

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf

原来mysql默认的配置文件放在/etc/my.cnf,现在多个版本同时运行,需要每个版本都将配置文件单独放在自己的安装目录内.
cp support-files/mysql.server /etc/init.d/mysql06
原来mysql默认采用mysqld脚本,现在每个mysql需要有自己的启动脚本,并通过修改启动脚本来为每个mysql指定采用的配置文件.
chmod 755 /etc/init.d/mysql06
修改/etc/init.d/mysql06,用来指定采用的配置文件位置.
vi /etc/init.d/mysql06

找到conf=/etc/my.cnf

改成conf=/usr/local/mysql/my.cnf
service mysql06 start
chkconfig mysql06 on

好了,可以看到第1个mysql已经成功启动了,接下来我们来编译安装第2个mysql.

2.编译安装第2个mysql
第2个mysql的编译参数跟第1个只是有点不相同罢了.
先删除编译过的mysql包:
rm -fr mysql-5.5.22 && tar zxf mysql-5.5.22.tar.gz && cd mysql-5.5.22
01
cmake . \
02
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql07/ \
03
-DMYSQL_DATADIR=/data0/mysql/3307/data \
04
-DMYSQL_UNIX_ADDR=/data0/mysql/3307/mysqld.sock \
05
-DWITH_MYISAM_STORAGE_ENGINE=1 \
06
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
07
-DWITH_BLACKHOLE_STORAGE_ENGINE=0 \
08
-DWITH_ARCHIVE_STORAGE_ENGINE=0 \
09
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
10
-DENABLED_LOCAL_INFILE=1 \
11
-DMYSQL_TCP_PORT=3307 \
12
-DEXTRA_CHARSETS=all \
13
-DDEFAULT_CHARSET=utf8 \
14
-DDEFAULT_COLLATION=utf8_general_ci \
15
-DWITH_DEBUG=0 \
16
-DWITH_EMBEDDED_SERVER=1 \
17
-DWITH_SSL=system

这里就不再给大家说明了,自己看吧.
chmod +w /usr/local/mysql07
chown -R mysql.mysql /usr/local/mysql07
mkdir -p /data0/mysql/3307/data/
mkdir -p /data0/mysql/3307/binlog/
mkdir -p /data0/mysql/3307/relaylog/
chown -R mysql.mysql /data0/mysql/
/usr/local/mysql07/scripts/mysql_install_db --basedir=/usr/local/mysql07/ --datadir=/data0/mysql/3307/data --user=mysql
cp support-files/my-medium.cnf /usr/local/mysql07/my.cnf
cp support-files/mysql.server /etc/init.d/mysql07
chmod 755 /etc/init.d/mysql07
vi /etc/init.d/mysql07
找到conf=/etc/my.cnf
改成conf=/usr/local/mysql07/my.cnf
这里还要对my.cnf文件进行修改:
vi /usr/local/mysql07/my.cnf
01
[client]
02
port = 3307
03
socket = /data0/mysql/3307/mysql.sock
04

05
[mysqld]
06
port = 3307
07
socket = /data0/mysql/3307/mysql.sock
08
basedir = /usr/local/mysql07
09
datadir = /data0/mysql/3307/data
10
log-error = /data0/mysql/3307/mysql_error.log
11
pid-file = /data0/mysql/3307/mysql.pid
12
log-bin = /data0/mysql/3307/binlog/binlog
13
relay-log-index = /data0/mysql/3307/relaylog/relaylog
14
relay-log-info-file = /data0/mysql/3307/relaylog/relaylog
15
relay-log = /data0/mysql/3307/relaylog/relaylog

然后启动mysql07
service mysql07 start
chkconfig mysql07 on

好了,大家可以看到两个mysql都已经运行起来了.

mysql cluster:

http://www.cnblogs.com/bigshuai/archive/2012/02/29/2373865.html



yum install libaio.x86_64 libaio-devel.x86_64 perl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值