chown -R mysql:mysql /opt/mysql
准备工作:安装基本依赖包,先用yum安装cmake、automake 、autoconf ,另MySQL 5.5.x需要最少安装的包有:bison,gcc、gcc-c++、ncurses-devel
yum -y install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
安装cmake(mysql5.5以后是通过cmake来编译的)
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/opt/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=0 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_SSL=no \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_READLINE=1 \
-DWITH_ZLIB=system \
-DINSTALL_PLUGINDIR=lib64/mysql/plugin \
-DINSTALL_LIBDIR=lib64/mysql \
-DINSTALL_INCLUDEDIR=include/mysql \
-DWITH_DEBUG=0
chkconfig --add mysqld
chkconfig mysqld on
接下来开始部署主从环境
在主服务器上配置mysql的配置文件
然后进入到mysql数据库里进行授权
grant replication slave on *.* to 'backup'@'x.x.x.x' identified by 'backup';
查询主数据库状态,并记下FILE及Position的值,这个在后面配置从服务器的时候要用到
show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000010 | 264 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
主数据库的操作就到这里,下面的操作在从服务器上操作
注: 删除mysql日志文件后报I/O error reading the header from the binary log, errno=175, io cache
data目录下日志文件很多,很烦,把mysql-bin.000001~mysql-bin.0000018都删掉了。结果报以下错误:
120914 10:23:31 [ERROR] I/O error reading the header from the binary log, errno=175, io cache code=0
120914 10:23:31 [ERROR] I/O error reading the header from the binary log
120914 10:23:31 [ERROR] Can't init tc log
120914 10:23:31 [ERROR] Aborting
解决办法:
把剩下的有关日志的文件都删掉。把ibdata1,ib_logfile0,ib_logfile1,mysql-bin.index,再启动就可以了