ipv6自动跳转到ipv4
sed -i 's|#net.ipv4.ip_forward=1|net.ipv4.ip_forward=1|g' /etc/sysctl.conf
创建docker容器
docker run -h mysql_master --name mysql_master -p 3306:3306 -v /data:/data -it ubuntu:14.04 /bin/bash
docker run -h mysql_slave --name mysql_slave -p 3307:3306 -v /data:/data --link=mysql_master:mysql_master -it ubuntu:14.04 /bin/bash
docker run -h atlas --name atlas -p 3305:3305 -v /data:/data --link=mysql_master:mysql_master --link=mysql_slave:mysql_slave -it ubuntu:14.04 /bin/bash
配置并安装库
echo "Asia/shanghai" > /etc/timezone
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
cat > /etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
EOF
apt-get update
apt-get install -y wget vim telnet
apt-get autoclean
apt-get clean
apt-get autoremove
mysql_master
apt-get install -y mysql-server-5.6
cp -a /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
sed -i 's|/var/log/mysql|/data/mysql_master/log|g' /etc/mysql/my.cnf
sed -i 's|/var/lib/mysql|/data/mysql_master/data|g' /etc/mysql/my.cnf
sed -i 's|bind-address|#bind-address|g' /etc/mysql/my.cnf
[mysqld]
server-id=1
max_connections=2000
log-bin=mysql-bin
binlog_ignore_db=mysql
innodb_flush_log_at_trx_commit=1
sync_binlog=1
slow-query-log-file = /data/mysql_master/log/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
mkdir -p /data/mysql_master/log
mkdir -p /data/mysql_master/data
cp -a /var/lib/mysql/* /data/mysql_master/data
chown -R mysql:mysql /data/mysql_master
service mysql start
ps -ef|grep mysql
mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';FLUSH PRIVILEGES;"
mysql -uroot -p123456 -e "show master status"
mysql_slave
apt-get install -y mysql-server-5.6
cp -a /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
sed -i 's|/var/log/mysql|/data/mysql_slave/log|g' /etc/mysql/my.cnf
sed -i 's|/var/lib/mysql|/data/mysql_slave/data|g' /etc/mysql/my.cnf
sed -i 's|bind-address|#bind-address|g' /etc/mysql/my.cnf
[mysqld]
server-id=2
max_connections=2000
slow-query-log-file = /data/mysql_slave/log/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
mkdir -p /data/mysql_slave/log
mkdir -p /data/mysql_slave/data
cp -a /var/lib/mysql/* /data/mysql_slave/data
chown -R mysql:mysql /data/mysql_slave
service mysql start
ps -ef|grep mysql
mysql -uroot -p123456 -e "stop slave";
mysql -uroot -p123456 -e "change master to master_host='mysql_master',master_user='root',master_password='123456'";
mysql -uroot -p123456 -e "start slave";
mysql -uroot -p123456 -e "show slave status\G";
atlas
apt-get install -y libmysqlclient18 mysql-client-core-5.6
wget https://github.com/Qihoo360/Atlas/releases/download/2.2/Atlas-2.2-debian7.0-x86_64.deb
dpkg -i Atlas-2.2-debian7.0-x86_64.deb
mkdir -p /data/atlas/log
cat > /usr/local/mysql-proxy/conf/atlas.cnf <<EOF
[mysql-proxy]
admin-username = root
admin-password = 123456
admin-lua-script = /usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua
proxy-backend-addresses = mysql_master:3306
proxy-read-only-backend-addresses = mysql_slave:3306
pwds = root:islyU4IfJ/k=
daemon = true
keepalive = true
event-threads = 8
log-level = message
log-path = /data/atlas/log
instance = atlas
proxy-address = 0.0.0.0:3305
admin-address = 0.0.0.0:3304
min-idle-connections = 16
charset = utf8
EOF
/usr/local/mysql-proxy/bin/mysql-proxyd atlas start
mysql -h127.0.0.1 -P3305 -uroot -p123456 -e "select * from help"
防火墙开放端口
vim /etc/iptables/rules.v4
-A INPUT -p tcp -m tcp --dport 3305 -j ACCEPT
iptables-restore < /etc/iptables/rules.v4
iptables -L -n