源码编译altas mysql_MySQL安装源码mysql-5.6+Atlas读写分离

主库 192.168.2.121   端口 3306

从库 192.168.2.120   端口 33060

Atlas代理 192.168.2.120   端口 3307

c361f694c96b19b4a850ecbe0e702cea.png

安装包+主从配置文件

链接:https://pan.baidu.com/s/1-h_K-7ytmw6GsYmwZVjR3g

提取码:t179

安装数据库

解压tar包

tar -zxf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

cd /usr/local/

mv mysql-5.6.40-linux-glibc2.12-x86_64 mysql-5.6.40

创建用户

groupadd mysql

useradd -g mysql mysql -s /sbin/nologin

创建文件目录

mkdir -p /data/mysql/

chown -R mysql:mysql /data/

ln -s mysql-5.6.40 mysql

cd /usr/local/mysql/scripts/

初始数据库

yum install autoconf libaio* -y

./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/ --defaults-file=/etc/my.cnf --user=mysql

cd /usr/local/mysql

cp support-files/mysql.server /etc/init.d/mysql

service mysql start

修改初始数据库密码

mysql -p

首次登陆密码直接回车进入

>use mysql;

>update user set authentication_string=password("新密码") where user="root";

>flush privileges;

>\q

读写分离架构必须是主从复制状态

主从复制:  https://www.cnblogs.com/merely/p/9714827.html

读写分离

解压安装--自动安装到/usr/local/

rpm -ivh Atlas-2.2.1.el6.x86_64.rpm

cd /usr/local/mysql-proxy/bin

修改配置文件

77c4210983e6d6a723adf65269e9851d.png

(此脚本是配置远程访问连接加密密码)

vim /test.conf

fef07b5d7b8d563046486eebde58f505.png

a421b264ac668f6e03e74e6653cb6950.png

启动Atlas

/usr/local/mysql-proxy/bin/mysql-proxyd test start

访问代理端口数据库

[root@ conf]# mysql -uroot -P3307 -p密码 -h192.168.2.120

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4231

Server version: 5.0.81-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> select @@server_id;

+-------------+

| @@server_id |

+-------------+

| 2 |

+-------------+

1 row in set (0.00 sec)

MySQL [(none)]>

访问Atlas管理端数据库

[root@ conf]# mysql -uadmin -P2345 -p密码-h192.168.2.120

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.99-agent-admin

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> select * from backends;

+-------------+---------------------+-------+------+

| backend_ndx | address | state | type |

+-------------+---------------------+-------+------+

| 1 | 192.168.2.121:3306 | up | rw |

| 2 | 192.168.2.120:33060 | up | ro |

+-------------+---------------------+-------+------+

2 rows in set (0.00 sec)

MySQL [(none)]>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值