首页 > 数据库 >proxysql安装与配置

proxysql安装与配置

时间:2024-04-17 14:23:44浏览次数:32  
标签:10 配置 proxysql hostgroup servers mysql 安装 id SELECT

insert into mysql_servers (hostgroup_id, hostname, port) values(10,'172.34.88.155',3306);
insert into mysql_servers (hostgroup_id, hostname, port) values(10,'172.34.88.165',3306);
insert into mysql_servers (hostgroup_id, hostname, port) values(10,'172.34.88.222',3306);

load mysql servers to runtime;
save mysql servers to disk;

select * from mysql_servers;

=====================mysql
set global validate_password.policy=0;
set global validate_password.length=4;

create user 'monitor'@'%' identified by 'Monitor@2020';
create user 'proxysql'@'%' identified by 'Proxysql@2020';
create user 'yjtxz'@'%' identified by 'Yjtxz@2022';
create user 'sjz'@'%' IDENTIFIED BY 'RT1jTqi7_Xeh';

grant all privileges on . to 'monitor'@'%';
grant all privileges on . to 'proxysql'@'%';
GRANT ALL PRIVILEGES ON 'yjtxz'.* TO 'yjtxz'@'%';

flush privileges;

use sys;
CREATE FUNCTION my_id() RETURNS TEXT(36) DETERMINISTIC NO SQL RETURN (SELECT @@global.server_uuid as my_id);

CREATE FUNCTION gr_member_in_primary_partition()
RETURNS VARCHAR(3)
DETERMINISTIC
BEGIN
RETURN (SELECT IF( MEMBER_STATE='ONLINE' AND ((SELECT COUNT() FROM
performance_schema.replication_group_members WHERE MEMBER_STATE NOT IN ('ONLINE', 'RECOVERING')) >=
((SELECT COUNT(
) FROM performance_schema.replication_group_members)/2) = 0),
'YES', 'NO' ) FROM performance_schema.replication_group_members JOIN
performance_schema.replication_group_member_stats USING(member_id) where member_id=my_id());
END

CREATE VIEW gr_member_routing_candidate_status AS SELECT
sys.gr_member_in_primary_partition() as viable_candidate,
IF( (SELECT (SELECT GROUP_CONCAT(variable_value) FROM
performance_schema.global_variables WHERE variable_name IN ('read_only',
'super_read_only')) != 'OFF,OFF'), 'YES', 'NO') as read_only,
Count_Transactions_Remote_In_Applier_Queue as transactions_behind, Count_Transactions_in_queue as 'transactions_to_cert'
from performance_schema.replication_group_member_stats where member_id=my_id();

=====================proxysql
set mysql-monitor_username='monitor';
set mysql-monitor_password='Monitor@2020';
INSERT INTO mysql_users(username, password, default_hostgroup) VALUES ('proxysql', 'Proxysql@2020', 10);
INSERT INTO mysql_users(username, password, default_hostgroup) VALUES ('zx_db', '&j=3NA^/c', 10);
INSERT INTO mysql_users(username, password, default_hostgroup) VALUES ('sjz', 'RT1jTqi7_Xeh', 10);

insert into mysql_group_replication_hostgroups(writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,offline_hostgroup,active) values(10,20,30,40,1);

load mysql servers to runtime;
save mysql servers to disk;
load mysql users to runtime;
save mysql users to disk;
load mysql variables to runtime;
save mysql variables to disk;

select hostgroup_id,hostname,port,status from runtime_mysql_servers;
select hostname,port,viable_candidate,read_only,transactions_behind,error from mysql_server_group_replication_log order by time_start_us desc;

读写分离规则

insert into mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply) values (1,1,'^SELECT .* FOR UPDATE$',10,1),(2,1,'^SELECT',30,1);

load mysql query rules to runtime;
save mysql query rules to disk;

查看路由日志

select hostgroup,digest_text from stats_mysql_query_digest order by digest_text limit 5;

标签:10,配置,proxysql,hostgroup,servers,mysql,安装,id,SELECT
From: https://www.cnblogs.com/wszzn/p/18140620

相关文章

  • Percona XtraDB Cluster 集群安装(PXC)
    PerconaXtraDBCluster集群安装安装环境:CentOSLinuxrelease7.6.1810(Core)16核64G在线安装离线安装配置文件在线安装添加仓库内容(在线安装)yuminstallhttps://repo.percona.com/yum/percona-release-latest.noarch.rpm-y安装:yuminstallPercona-XtraDB-Clu......
  • yum安装指定版本mysql
    参考链接:https://blog.csdn.net/Sunny_Future/article/details/105345493参考链接:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html安装好依赖环境yuminstall-yyum-utilswget下载仓库包wgethttps://dev.mysql.com/get/mysql80-community-rel......
  • ubuntu安装mysql
    ubuntu安装mysql方法一、使用apt仓库更新软件列表aptupdate查看可用的MySQL版本aptlist|grepmysql-server或者aptsearchmysql-server安装指定版本的MySQL服务器aptinstallmysql-server-<version>例如安装8.0aptinstallmysql-server-8.0使用......
  • 安装postgres
    安装postgresqlyum安装官网参考:https://www.postgresql.org/download/linux/redhat/#InstalltherepositoryRPM:sudoyuminstall-yhttps://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm#InstallPostgreSQL:s......
  • Nginx部署安装
     #部署前准备工作#配置阿里云的yum源yum-yinstallwgetcd/etc/yum.repos.d/wgethttp://mirrors.aliyun.com/repo/Centos-7.repomvCentOS-Base.repoCentOS-Base.repo.bakmvCentos-7.repoCentOS-Base.repoyumcleanallyummakecacheyumupdate yum-y......
  • mysql5.7配置文件
    datadir=/data/mysqlsocket=/var/lib/mysql/mysql.sockDisablingsymbolic-linksisrecommendedtopreventassortedsecurityriskssymbolic-links=0log-error=/data/mysql/mysqld.logpid-file=/data/mysql/mysqld/mysqld.piddefault-time-zone='+8:00'......
  • 【笔记】RedmiBookPro15锐龙板(7840hs)安装ubuntu2204注意事项
    /** 2024-04-17 12:53:52*/1、不要安装ubuntu2004,驱动问题很烦入,尤其是AMD的显卡驱动,不论哪个版本都不要打AMD的官方驱动,经常花屏,卡的完全不能操作,自带的开源驱动就行了,偶尔出现一两道花屏的,不影响使用,而且一会就消失了。如果经常出现在bios里调大显存试试,默认512估计不够,我......
  • step by step系列之:openGauss1.0.1单机安装指南v1.2
    StepbyStep之:openGauss1.0.1单机安装指南v1.2在CentOS7.6上安装openGauss单机版配置操作系统满足安装要求硬件环境:虚拟机的内存8GB,4核心CPU,900G磁盘(非必须)软件环境:CentOS7.6关闭防火墙停止firewallsystemctlstopfirewalld.service禁止firewall开机启动......
  • C:\Windows\System32\setup 目录中,这个目录包含了一些与系统安装和配置相关的文件
    C:\Windows\System32\setup目录中,这个目录包含了一些与系统安装和配置相关的文件。作用:cmmigr.dll:这是一个动态链接库文件,可能与移动设备中心相关。它可能包含了用于迁移和处理移动设备中心配置的函数和资源。comsetup.dll:这是ComponentServicesSetup工具的......
  • 2.JAVA入门 了解JAVA 配置环境
    Java入门Java特性和优势简单性:Java语言设计简洁,易于学习和使用。它摒弃了许多复杂的特性和语法,使得编程变得更加直观和容易上手。面向对象:Java是一种纯粹的面向对象编程语言,所有的代码都以类和对象的形式组织。这种面向对象的特性使得代码更加模块化、可重用性更高,并且更容易......