os:centos 7.4
mysql: 5.7
proxysql: 1.4.10

ip 规划如下:

192.168.56.101 node1 (proxysql)

192.168.56.102 node2 (mysql master)
192.168.56.103 node3 (mysql slave)
192.168.56.104 node4 (mysql slave)

安装mysql 5.7

node2、node3、node4 安装 mysql 5.7 software
详细过称略,参考另外一篇博客。

初始化mysql 5.7,配置好master slave

node2、node3、node4 各个节点先初始化 mysql 5.7,再配置 master/slave

master 修改密码

mysql> set password for 'root'@'localhost'= password('2wsx3edc');
mysql> flush privileges;

master 创建复制用户

mysql> create user 'replicator'@'192.168.56.%' identified by '2wsx3edc';
mysql> grant replication slave on *.* to 'replicator'@'192.168.56.%';
mysql> flush privileges;

master 使用 mysqldump 出集合,再在slave端导入

# mysqldump -uroot -p --master-data=2 --single-transaction -R --triggers -A > mysql_all.sql

其中
–master-data=2代表备份时刻记录master的Binlog位置和Position,
–single-transaction意思是获取一致性快照,
-R意思是备份存储过程和函数,
–triggres的意思是备份触发器,
-A代表备份所有的库。

mysql> change master tomaster_host='192.168.56.102',master_user='replicator',master_password='2wsx3edc',master_port=3306,master_log_file='mysql-bin.000001',master_log_pos=154;
mysql> start slave;  

salve设置为 read only,从库对外提供读服务,只所以没有写进配置文件,是因为随时slave会提升为master。

mysql> set global read_only=1;
mysql> set global relay_log_purge=0;

至此,已经配置好了1master、2slave

配置本地免密登录

登录主机后,登录mysql需要输入密码,配置个密码文件。免得每次都需要输入密码。
node2、node3、node4节点都需要操作

# vi ~/.my.cnf[client]
host=localhost
user='root'
password='2wsx3edc'# chmod 700 ~/.my.cnf

下载、安装 proxysql

node1 节点安装mysql 5.7 client,mysql 5.7 lib

# yum install mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs mysql-community-libs-compat 

node1 节点安装 proxysql
下载地址如下:
https://github.com/sysown/ProxySQL
或者
https://www.percona.com/downloads/proxysql/

安装依赖包

# yum install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL
# cd /etc/yum.repos.d/
# cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL YUM repository
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasever
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
# yum install proxysql
=======================================================================================================================================
 Package                        Arch                         Version                         Repository                           Size
=======================================================================================================================================
Installing:
 proxysql                       x86_64                       1.4.10-1                        proxysql_repo                       5.7 MTransaction Summary
=======================================================================================================================================

查看 proxysql-1.4.10-1.x86_64 涉及到哪些文件

# rpm -ql proxysql-1.4.10-1.x86_64
/etc/init.d/proxysql
/etc/proxysql.cnf
/usr/bin/proxysql
/usr/share/proxysql/tools/proxysql_galera_checker.sh
/usr/share/proxysql/tools/proxysql_galera_writer.pl
# systemctl status proxysql.service
● proxysql.service - LSB: High Performance Advanced Proxy for MySQLLoaded: loaded (/etc/rc.d/init.d/proxysql; bad; vendor preset: disabled)Active: inactive (dead)Docs: man:systemd-sysv-generator(8)
# cat /etc/init.d/proxysql

/etc/init.d/proxysql 脚本涉及到如下目录、文件

OLDDATADIR="/var/run/proxysql"
DATADIR="/var/lib/proxysql"
OPTS="-c /etc/proxysql.cnf -D $DATADIR"
PIDFILE="$DATADIR/proxysql.pid"

/run/systemd/generator.late/proxysql.service

# more /run/systemd/generator.late/proxysql.service
# Automatically generated by systemd-sysv-generator[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/rc.d/init.d/proxysql
Description=LSB: High Performance Advanced Proxy for MySQL
Before=runlevel2.target
Before=runlevel3.target
Before=runlevel4.target
Before=runlevel5.target
Before=shutdown.target
After=network-online.target
Conflicts=shutdown.target[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/rc.d/init.d/proxysql start
ExecStop=/etc/rc.d/init.d/proxysql stop
ExecReload=/etc/rc.d/init.d/proxysql reload

配置文件 /etc/proxysql.cnf

检查版本

# which proxysql
/usr/bin/proxysql
# proxysql --version
ProxySQL version v1.4.10-1-g5eb0f3e, codename Truls# proxysql --help
High Performance Advanced Proxy for MySQLUSAGE: proxysql [OPTIONS]OPTIONS:-c, --config ARG             Configuraton file
-D, --datadir ARG            Datadir
-e, --exit-on-error          Do not restart ProxySQL if crashes
-f, --foreground             Run in foreground
-h, -help, --help, --usage   Display usage instructions.
-M, --no-monitor             Do not start Monitor Module
-n, --no-start               Starts only the admin service
-r, --reuseport              Use SO_REUSEPORT
-S, --admin-socket ARG       Administration Unix Socket
-V, --version                Print version
--idle-threads               Create auxiliary threads to handle idle connections
--initial                    Rename/empty database file
--reload                     Merge config file into database file
--sqlite3-server             Enable SQLite3 Server
ProxySQL rev. v1.4.10-1-g5eb0f3e -- Tue Aug  7 12:31:55 2018
Copyright (C) 2013-2018 ProxySQL LLC
This program is free and without warranty

有 -c –config 的option,可以把参数全部导入到参数文件,易于管理。

配置proxysql.cnf

# cp /etc/proxysql.cnf /etc/proxysql.cnf.bak
# vi /etc/proxysql.cnf

配置文件只在第一次启动的时候读取进行初始化,后面只读取db文件。
所以还是先启动,然后再修改参数。

启动 proxysql

# service proxysql start
Starting ProxySQL: 2018-08-13 11:08:25 [INFO] Using config file /etc/proxysql.cnf
DONE!# ps -ef|grep -i proxysql
root      7859     1  0 11:08 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql
root      7860  7859  0 11:08 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql# netstat -antp|grep -i 7859
# netstat -antp|grep -i 7860
tcp        0      0 0.0.0.0:6032            0.0.0.0:*               LISTEN      7860/proxysql
tcp        0      0 0.0.0.0:6033            0.0.0.0:*               LISTEN      7860/proxysql 

根据 /etc/proxysql.cnf 文件内容,6032 是管理端口,6033 是 mysql 连接端口。

连接 proxysql 6032 管理端口

# mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin> '
mysql: [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.5.30 (ProxySQL Admin Module)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.Admin>

proxysql 的安装先说的这里,下一篇blog说下配置。

参考:
http://www.proxysql.com/
http://www.proxysql.com/compare

https://www.percona.com/downloads/proxysql/

https://github.com/sysown/proxysql/releases
https://github.com/sysown/ProxySQL
https://github.com/sysown/proxysql/wiki

cat /etc/proxysql.cnf

#file proxysql.cfg########################################################################################
# This config file is parsed using libconfig , and its grammar is described in:
# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
# Grammar is also copied at the end of this file
################################################################################################################################################################################
# IMPORTANT INFORMATION REGARDING THIS CONFIGURATION FILE:
########################################################################################
# On startup, ProxySQL reads its config file (if present) to determine its datadir.
# What happens next depends on if the database file (disk) is present in the defined
# datadir (i.e. "/var/lib/proxysql/proxysql.db").
#
# If the database file is found, ProxySQL initializes its in-memory configuration from
# the persisted on-disk database. So, disk configuration gets loaded into memory and
# then propagated towards the runtime configuration.
#
# If the database file is not found and a config file exists, the config file is parsed
# and its content is loaded into the in-memory database, to then be both saved on-disk
# database and loaded at runtime.
#
# IMPORTANT: If a database file is found, the config file is NOT parsed. In this case
#            ProxySQL initializes its in-memory configuration from the persisted on-disk
#            database ONLY. In other words, the configuration found in the proxysql.cnf
#            file is only used to initial the on-disk database read on the first startup.
#
# In order to FORCE a re-initialise of the on-disk database from the configuration file
# the ProxySQL service should be started with "service proxysql initial".
#
########################################################################################datadir="/var/lib/proxysql"admin_variables=
{admin_credentials="admin:admin"
#   mysql_ifaces="127.0.0.1:6032;/tmp/proxysql_admin.sock"mysql_ifaces="0.0.0.0:6032"
#   refresh_interval=2000
#   debug=true
}mysql_variables=
{threads=4max_connections=2048default_query_delay=0default_query_timeout=36000000have_compress=truepoll_timeout=2000
#   interfaces="0.0.0.0:6033;/tmp/proxysql.sock"interfaces="0.0.0.0:6033"default_schema="information_schema"stacksize=1048576server_version="5.5.30"connect_timeout_server=3000
# make sure to configure monitor username and password
# https://github.com/sysown/proxysql/wiki/Global-variables#mysql-monitor_username-mysql-monitor_passwordmonitor_username="monitor"monitor_password="monitor"monitor_history=600000monitor_connect_interval=60000monitor_ping_interval=10000monitor_read_only_interval=1500monitor_read_only_timeout=500ping_interval_server_msec=120000ping_timeout_server=500commands_stats=truesessions_sort=trueconnect_retries_on_failure=10
}# defines all the MySQL servers
mysql_servers =
(
#   {#       address = "127.0.0.1" # no default, required . If port is 0 , address is interpred as a Unix Socket Domain
#       port = 3306           # no default, required . If port is 0 , address is interpred as a Unix Socket Domain
#       hostgroup = 0           # no default, required
#       status = "ONLINE"     # default: ONLINE
#       weight = 1            # default: 1
#       compression = 0       # default: 0
#   max_replication_lag = 10  # default 0 . If greater than 0 and replication lag passes such threshold, the server is shunned
#   },
#   {#       address = "/var/lib/mysql/mysql.sock"
#       port = 0
#       hostgroup = 0
#   },
#   {#       address="127.0.0.1"
#       port=21891
#       hostgroup=0
#       max_connections=200
#   },
#   { address="127.0.0.2" , port=3306 , hostgroup=0, max_connections=5 },
#   { address="127.0.0.1" , port=21892 , hostgroup=1 },
#   { address="127.0.0.1" , port=21893 , hostgroup=1 }
#   { address="127.0.0.2" , port=3306 , hostgroup=1 },
#   { address="127.0.0.3" , port=3306 , hostgroup=1 },
#   { address="127.0.0.4" , port=3306 , hostgroup=1 },
#   { address="/var/lib/mysql/mysql.sock" , port=0 , hostgroup=1 }
)# defines all the MySQL users
mysql_users:
(
#   {#       username = "username" # no default , required
#       password = "password" # default: ''
#       default_hostgroup = 0 # default: 0
#       active = 1            # default: 1
#   },
#   {#       username = "root"
#       password = ""
#       default_hostgroup = 0
#       max_connections=1000
#       default_schema="test"
#       active = 1
#   },
#   { username = "user1" , password = "password" , default_hostgroup = 0 , active = 0 }
)#defines MySQL Query Rules
mysql_query_rules:
(
#   {#       rule_id=1
#       active=1
#       match_pattern="^SELECT .* FOR UPDATE$"
#       destination_hostgroup=0
#       apply=1
#   },
#   {#       rule_id=2
#       active=1
#       match_pattern="^SELECT"
#       destination_hostgroup=1
#       apply=1
#   }
)scheduler=
(
#  {#    id=1
#    active=0
#    interval_ms=10000
#    filename="/var/lib/proxysql/proxysql_galera_checker.sh"
#    arg1="0"
#    arg2="0"
#    arg3="0"
#    arg4="1"
#    arg5="/var/lib/proxysql/proxysql_galera_checker.log"
#  }
)mysql_replication_hostgroups=
(
#        {#                writer_hostgroup=30
#                reader_hostgroup=40
#                comment="test repl 1"
#       },
#       {#                writer_hostgroup=50
#                reader_hostgroup=60
#                comment="test repl 2"
#        }
)# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
#
# Below is the BNF grammar for configuration files. Comments and include directives are not part of the grammar, so they are not included here.
#
# configuration = setting-list | empty
#
# setting-list = setting | setting-list setting
#
# setting = name (":" | "=") value (";" | "," | empty)
#
# value = scalar-value | array | list | group
#
# value-list = value | value-list "," value
#
# scalar-value = boolean | integer | integer64 | hex | hex64 | float
#                | string
#
# scalar-value-list = scalar-value | scalar-value-list "," scalar-value
#
# array = "[" (scalar-value-list | empty) "]"
#
# list = "(" (value-list | empty) ")"
#
# group = "{" (setting-list | empty) "}"
#
# empty =

转载于:https://www.cnblogs.com/ctypyb2002/p/9792906.html

mysql 高可用架构 proxysql 之一 yum安装相关推荐

  1. mysql proxy yum_mysql 高可用架构 proxysql 之一 yum安装

    os:centos 7.4 mysql: 5.7 proxysql: 1.4.10 ip 规划如下: 192.168.56.101 node1 (proxysql) 192.168.56.102 no ...

  2. 搭建MySQL高可用架构MHA

    搭建MySQL高可用架构MHA v1.0 MHA简介 MHA的主要目的是自动化master故障转移和slave自动提升为master,在较短时间(一般为10-30秒)的停机时间,可以避免复制和一致性问 ...

  3. Heartbeat+DRBD+MySQL高可用架构方案与实施过程细节 【转】

    文章出处:Heartbeat+DRBD+MySQL高可用架构方案与实施过程细节 [转]             mysql数据库高可用高扩展性架构方案实施[原] Heartbeat+DRBD+MySQ ...

  4. 探索MySQL高可用架构之MHA(6)

    探索MySQL高可用架构之MHA(6) -----构建mysql高可用系列(共9篇) 上一篇文章介绍了本次架构的Atlas读写分离! 本篇文章主要介绍本次架构中的keepalive部分! 什么是Kee ...

  5. 从mysql高可用架构看高可用架构设计

    高可用HA(High Availability)是分布式系统架构设计中必须考虑的因素之一,它通常是指,通过设计减少系统不能提供服务的时间. 假设系统一直能够提供服务,我们说系统的可用性是100%.如果 ...

  6. MySQL 高可用架构在业务层面的应用分析

    MySQL 高可用架构在业务层面的应用分析 http://mp.weixin.qq.com/s?__biz=MzAxNjAzMTQyMA==&mid=208312443&idx=1&a ...

  7. 第5章 MySQL高可用架构设计

    第5章 MySQL高可用架构设计 数据库复制 复制解决了什么问题????? 非共享架构 二进制日志 binlog工具 查看日志格式 show variables like "binlog_f ...

  8. 【DB宝42】MySQL高可用架构MHA+ProxySQL实现读写分离和负载均衡

    文章目录 一.MHA+ProxySQL架构 二.快速搭建MHA环境 2.1 下载MHA镜像 2.2 编辑yml文件,创建MHA相关容器 2.3 安装docker-compose软件(若已安装,可忽略) ...

  9. Mysql进阶(4)——基于MHA的MySQL高可用架构

    前言 MySQL高可用性大杀器之MHA MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职 ...

最新文章

  1. Vue实现左右菜单联动实现
  2. 学习笔记Spark(四)—— Spark编程基础(创建RDD、RDD算子、文件读取与存储)
  3. 【转】浅谈MS-SQL锁机制
  4. 从零入门 Serverless | SAE 场景下,应用流量的负载均衡及路由策略配置实践
  5. 【Servlet】请求转发、重定向、Cookie使用之三天自动登陆
  6. 计算机科学计算方面分为,计算机方面的专业分为哪些类?【资讯与计算科学】和【电脑科学与技术专业】有什么不同?...
  7. 截取字符串_妙用字符串的替换和截取让Shell脚本精准得到你心中的那个“她”...
  8. mac safari 下载pdf
  9. Mac上好用的音乐软件是哪个?MacOS专业音乐制作软件推荐
  10. 建筑物后期调色ps动作
  11. Tumblr 架构设计
  12. 全自动与半自动手表的区别_全自动和半自动机械表的区别?
  13. [独立游戏][纳税]个人独立游戏缴税纳税相关问题
  14. 肖臻公开课(八)——比特币中的挖矿
  15. 网易2017春招笔试——集合
  16. Android-掷骰子
  17. 打包后图片不显示问题
  18. ThinkPad 嘀嘀响 报警
  19. swif访问控制修饰符
  20. 高速工业相机与一般工业相机相比有哪些优势?

热门文章

  1. puppet 认证错误:Could not request certificate: unknown message digest algorithm
  2. 1.MAC中MySql的环境配置
  3. (Mirage系列之四)Mirage经典案例之集中桌面管理
  4. tcpip数据包编码解析(chunk and gzip)_space of Jialy_百度空间
  5. chroot--实现系统普通用户在限定目录下活动
  6. IBM交付第25000个高端磁盘存储方案
  7. 复杂多目录的Makefile模板及示例-转
  8. [Python] L1-038. 新世界 团体程序设计天梯赛GPLT
  9. PAT 乙级 1009. 说反话 (20) Java版
  10. 【软件项目管理】软件项目的主要成本是人的劳动的消耗