Atlas 是一个用于数据库负载均衡 ,读写分离的中间件,他实现了mysql 的语法,对于普通调用DAL 层来说的话,和mysql 是一样的。
一,安装
1,从源码安装 , 可以参考 http://blog.qixingzhong.com/2013/09/centos-install-atlas.html ,但是我装了半天还是不行,glib库搞不定,所以放弃了。
二,从rpm 安装
1,
一行命令搞定:
shell>> rpm -ivh Atlas-2.2.el5.x86_64.rpm
配置按照 https://github.com/Qihoo360/Atlas/wiki/Atlas%E7%9A%84%E5%AE%89%E8%A3%85 这里的配置,但是到了这一步
“./encrypt mypwd” ,说是找不到 libcrypto.so.6
我疯了,这又怎么了,我首先就安装了openssl
yum install openssl-devel
还是不行, 结果googel 之,牛人有了解决方案,
for 32 bit:
ln-sf /usr/lib/libssl.so.10 /usr/lib/libssl.so.6
ln-sf /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so.6
for 64bit
for 64 bit:
ln-sf /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.6
ln-sf /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.6
简单来说就是搞个链接,不然不能运行。
2, 运行起来:
查看日志发现:
ical) proxy-plugin.c.1454: I have no server backend, closing connection
2014-11-06 15:06:41: (critical) network-mysqld.c.1383: plugin_call(CON_STATE_READ_QUERY) failed
我有犯愁了,结果返现是mysql版本太低, 应该是5.6 ,所以换成了5.6.
把原来的mysql 找到,yum remove 掉。怎么找了,你yum install mysql ,他会提示你安装了那个包,然后你就yum remove **.rpm 具体的那个包。
5.6 安装好了,发现启动不起来,接着查看日志。 先找日志 find /-name mysqld.log ,
55 15957 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2014-11-06 15:49:55 15957 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2014-11-06 15:49:55 15957 [ERROR] Plugin 'InnoDB' init function returned error.
2014-11-06 15:49:55 15957 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2014-11-06 15:49:55 15957 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-11-06 15:49:55 15957 [ERROR] Aborting
原来是要找到原来安装mysql 的目录,删除几个文件夹就可以了,/var/lib/mysql, 一般是,不行就你find 一下。ibdata1 ib_logfile0 ib_logfile1 这个几个文件夹要删掉。在service mysqld start
3, 满心欢喜,可以运行了。用navicat 工具连上之后,发现,只能读,不能写。
需要设置 /usr/local/mysql-proxy/conf/test.cnf
proxy-backend-addresses = 172.16.13.100:3306
不要设置为127.0.0.1
4 ,看到了主数据库可以写入了,但是从数据库没有数据,我就纳闷了。原来是我2,原来还需要手动设置 mysql 的主从复制 ,这个是mysql 自己的功能。
http://dev.mysql.com/doc/refman/5.6/en/replication-howto.html