Compile and install dbproxy altas and compile dbproxyaltas

Source: Internet
Author: User
Tags stop script

Compile and install dbproxy altas and compile dbproxyaltas

Preface: there are already many mysql middle layers, such as dbproxy of baidu, tddl of taobao, corba of 126 and alibaba, altas of 360, mysql-proxy, oneproxy of Lou fangxin, and dbproxy of sohu, fabric. Some support database/table sharding, and some do not. Select an appropriate one. However, be careful when selecting technologies. Exercise caution when selecting independent R & D or using existing third-party products. (If you understand libevent, you can develop it on your own. However, to develop a stable version, it may take some time to develop it and put it online. This may cause many pitfalls and personal experience, do not use products that have been running online for 2 years. We once developed it ourselves and ran for about three years. It was not until 12 years that it stabilized, and bugs kept going forward)

# Install dbproxy altas. Basically, install http://github.com/qihoo360/atlas/wiki/atlasby following the instructions written by Zhu Chao.

1. Download
Mkdir-p/data/software & cd/data/software
Wget https://github.com/Qihoo360/Atlas/archive/2.2.1.tar.gz
Mv 2.2.1.tar.gz atlas.2.2.1.tar.gz
Tar zxvf atlas.2.2.1.tar.gz

Ii. Install the library file
# Install the library file, gcc, and other compiling environments. You need to configure them in advance. Here we will go over.
Yum install-y libevent-devel lua-devel openssl-devel flex mysql-devel
Yum install-y xz gettext-devel

# Libffi, glib (> 2.32)
Yum-y install libffi *
Cd/data/software
Wget http://ftp.acc.umu.se/pub/gnome/sources/glib/2.33/glib-2.33.6.tar.xz
Xz-d glib-2.33.6.tar.xz
Cd glib-2.33.6
./Configure
Make
Make install
Ldconfig

# Jemalloc
Cd/data/software
Wget http://www.canonware.com/download/jemalloc/jemalloc-3.1.0.tar.bz2
Tar xvf jemalloc-3.1.0.tar.bz2
Make
Make install
Cp/data/software/jemalloc-3.1.0/lib/libjemalloc. so.1/usr/local/lib/
Ldconfig

3. Compile and install Atlas
Cd/data/software/Atlas-2.2.1
# Modify the installation directory -- prefix =/home/mysql/dbproxy
Vim bootstrap. sh
#! /Bin/sh
Base = $ (cd "$ (dirname" $0 ")"; pwd)
Cd $ base
PKG_CONFIG_PATH =/usr/local/lib/pkgconfig. /configure -- with-mysql =/usr -- prefix =/home/mysql/dbproxy CFLAGS = "-DHAVE_LUA_H-O2" LDFLAGS = "-lm-ldl-lcrypto-ljemalloc" LUA_CFLAGS = "-I/usr/local/include/" LUA_LIBS = "-L/usr/local/lib-llua"
# Used to it. We used to install dbproxy in/home/mysql/dbproxy.

./Bootstrap. sh
Make & make install
# Check the config. the information recorded in the log is generally caused by problems such as the absence of jemalloc, low version, libffi *, glib-2.32, and low or uninstalled library version.

Iv. Configuration
1. Configure the stop script mysql-proxyd
Vim/home/mysql/dbproxy/bin/mysql-proxyd
Modify proxydir =/usr/local/mysql-proxy to proxydir =/home/mysql/dbproxy
# Or sed-I's % proxydir =/usr/local/mysql-proxy % proxydir =/home/mysql/dbproxy % G'/home/mysql/dbproxy/bin/mysql -proxyd

2. modify the configuration file. The suffix must be. cnf. If you do not want to use. cnf, you can modify the mysql-proxyd script by yourself.
Vim/home/mysql/dbproxy/conf/dbproxy. cnf
[Mysql-proxy]
Admin-username = user
Admin-password = pwd
Admin-address = 0.0.0.0: 2345
Proxy-backend-addresses = 192.168.0.220: 9858
Proxy-read-only-backend-addresses = 192.168.1.221: 9858,192.168 .0.14: 9858
Pwds = dbproxy_longxibendi_w:/iZxz + 0 GRoA =, dbproxy_longxibendi_r:/iZxz + 0 GRoA =
Daemon = true
Keepalive = true
Event-threads = 4
Log-level = message
Log-path =/home/mysql/dbproxy/log
SQL-log = ON
SQL-log-slow = 10
Wait-timeout = 10
Proxy-address = 0.0.0.0: 12340
Charset = utf8
Client-ips = 127.0.0.1, 192.168.1, 192.168.0.220, 192.168.1.221

3. Add an account on mysql and slave
Master: 192.168.0.220
Slave: 192,168.1 .221, 192.168.0.14

On the master: mysql-uroot-p-h127.0.0.1-P5858
Mysql-> grant select, update, delete, insert on longxibendi. * to dbproxy_longxibendi_w@192.168.0.220 identified by '20140901 ';

Same authorization on slave. Note that the IP address is the address of dbproxy.

5. Start
1. Start dbproxy
Cd/home/mysql/dbproxy/bin
./Mysql-proxyd dbproxy start

2. Access Test
Mysql-udbproxy_longxibendi_w-h192.168.0.220-p123456-P10240
Mysql-> show databases;

# You can test transactions, read/write splitting, master database downtime, slave database downtime failover, and so on.

# Finally, I would like to thank the 360 web platform team


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.