사용할 구성에서 ProxySQL 읽기-쓰기 분리
Meituan-Dianping의 DBProxy 읽기-쓰기 분리 사용 지침 문서에 사용 목적이 설명되어 있습니다. 이 문서에서는 ProxySQL 사용 방법과 DBProxy와의 성능 차이를 소개합니다. 자세한 소개는 공식 홈페이지의 관련 안내를 참고하시기 바라며, 본 미들웨어 역시 퍼코나에서 추천하는 미들웨어입니다. 읽기와 쓰기를 분리하는 다른 미들웨어와 기능은 크게 다르지 않습니다. 자세한 내용은 기사에서 소개하겠습니다. 이 문서에서는 사용 중 몇 가지 지침을 간략하게 소개합니다. 공식 위키에서 도움말을 확인할 수도 있습니다.
환경:
배포자 ID: Ubuntu
설명: Ubuntu 14.04.5 LTS
릴리스: 14.04코드 이름: trusty
Download
percona 사이트:
https://www.percona.com/downloads/proxysql/
github/공식 웹사이트:
https://github.com/sysown/proxysql/releases
먼저 환경을 살펴보겠습니다.
master:172.16.16.35:3306slave:172.16.16.35:3307slave:172.16.16.34:3307
MHA 관리자는 172.16.16.34에 있고 구성 파일은 다음과 같습니다.
[root@localhost bin]# cat /etc/masterha/app1.cnf [server default] manager_log=/var/log/mha/app1/manager.log manager_workdir=/var/log/mha/app1.log master_binlog_dir=/home/mysql/db3306/log/master_ip_failover_script=/usr/local/bin/master_ip_failover master_ip_online_change_script=/usr/local/bin/master_ip_online_change password=123456ping_interval=1remote_workdir=/tmp repl_password=123456repl_user=root report_script=/usr/local/bin/send_report shutdown_script=""ssh_user=root user=root [server1] hostname=172.16.16.35port=3306[server2] candidate_master=1check_repl_delay=0hostname=172.16.16.34port=3306[server3] hostname=172.16.16.35port=3307
[root@localhost bin]# sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm[root@localhost bin]# yum install proxysql
Installed: proxysql.x86_64 0:1.3.7-1.1.el6 Complete!
[root@localhost bin]# find / -name proxysql/var/lib/proxysql/var/run/proxysql/etc/rc.d/init.d/proxysql/usr/bin/proxysql
[root@localhost bin]# cat /etc/proxysql-admin.cnf # proxysql admin interface credentials. export PROXYSQL_USERNAME="admin"export PROXYSQL_PASSWORD="admin"export PROXYSQL_HOSTNAME="localhost"export PROXYSQL_PORT="6032" # PXC admin credentials for connecting to pxc-cluster-node. export CLUSTER_USERNAME="admin"export CLUSTER_PASSWORD="admin"export CLUSTER_HOSTNAME="localhost"export CLUSTER_PORT="3306" # proxysql monitoring user. proxysql admin script will create this user in pxc to monitor pxc-nodes. export MONITOR_USERNAME="monitor"export MONITOR_PASSWORD="monit0r" # Application user to connect to pxc-node through proxysql export CLUSTER_APP_USERNAME="proxysql_user"export CLUSTER_APP_PASSWORD="passw0rd" # ProxySQL read/write hostgroup export WRITE_HOSTGROUP_ID="10"export READ_HOSTGROUP_ID="11" # ProxySQL read/write configuration mode. export MODE="singlewrite"
[root@localhost bin]# proxysql-admin --config-file=/etc/proxysql-admin.cnf --enable This script will assist with configuring ProxySQL (currently only Percona XtraDB cluster in combination with ProxySQL is supported) ProxySQL read/write configuration mode is singlewrite ProxySQL is not running; please start the proxysql service
[root@localhost bin]# service proxy proxy proxysql proxysql-admin proxysql_galera_checker proxysql_node_monitor [root@localhost bin]# service proxysql start Starting ProxySQL: DONE![root@localhost bin]# mysql -uadmin -padmin -h127.0.0.1 -P6032 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 1Server version: 5.7.14 (ProxySQL Admin Module) Copyright (c) 2000, 2016, 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>
[root@localhost bin]# find / -name proxysql.cnf/etc/proxysql.cnf
[root@localhost bin]# mysql -uadmin -padmin -h127.0.0.1 -P6032 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 2Server version: 5.7.14 (ProxySQL Admin Module) Copyright (c) 2000, 2016, 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> show databases;+-----+---------+-------------------------------+ | seq | name | file | +-----+---------+-------------------------------+ | 0 | main | | | 2 | disk | /var/lib/proxysql/proxysql.db | | 3 | stats | | | 4 | monitor | | +-----+---------+-------------------------------+4 rows in set (0.00 sec) mysql> use admin Database changed mysql> show tables;+--------------------------------------+ | tables | +--------------------------------------+ | global_variables | | mysql_collations | | mysql_query_rules | | mysql_replication_hostgroups | | mysql_servers | | mysql_users | | runtime_global_variables | | runtime_mysql_query_rules | | runtime_mysql_replication_hostgroups | | runtime_mysql_servers | | runtime_mysql_users | | runtime_scheduler | | scheduler | +--------------------------------------+13 rows in set (0.00 sec)
mysql> insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(100,'172.16.16.35',3306,1,1000,10,'test'); Query OK, 1 row affected (0.00 sec) mysql> insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(101,'172.16.16.34',3306,1,1000,10,'test'); Query OK, 1 row affected (0.00 sec) mysql> insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(101,'172.16.16.35',3307,1,1000,10,'test'); Query OK, 1 row affected (0.00 sec) mysql> select * from mysql_servers;+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+ | hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment | +--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+ | 100 | 172.16.16.35 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test | | 101 | 172.16.16.34 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test | | 101 | 172.16.16.35 | 3307 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test | +--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+3 rows in set (0.00 sec)
mysql> insert into mysql_replication_hostgroups values(100,101,'masterha') ; Query OK, 1 row affected (0.00 sec) mysql> select * from mysql_replication_hostgroups;+------------------+------------------+----------+ | writer_hostgroup | reader_hostgroup | comment | +------------------+------------------+----------+ | 100 | 101 | masterha | +------------------+------------------+----------+1 row in set (0.00 sec)
mysql> GRANT SUPER, REPLICATION CLIENT ON *.* TO 'proxysql'@'172.16.16.%' IDENTIFIED BY 'proxysql'; Query OK, 0 rows affected, 1 warning (0.09 sec) mysql> flush privileges; Query OK, 0 rows affected (0.10 sec)
mysql> set mysql-monitor_username='proxysql'; Query OK, 1 row affected (0.00 sec) mysql> set mysql-monitor_password='proxysql'; Query OK, 1 row affected (0.00 sec) mysql> load mysql variables to runtime; Query OK, 0 rows affected (0.00 sec) mysql> save mysql variables to disk; Query OK, 74 rows affected (0.02 sec)
mysql> insert into mysql_users(username,password,active,default_hostgroup,transaction_persistent) values('root','123456',1,100,1); Query OK, 1 row affected (0.00 sec) mysql> select * from mysql_users;+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+ | username | password | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections | +----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+ | root | 123456 | 1 | 0 | 100 | NULL | 0 | 1 | 0 | 1 | 1 | 10000 | +----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+1 row in set (0.00 sec)
mysql> load mysql servers to runtime; Query OK, 0 rows affected (0.01 sec) mysql> save mysql servers to disk; Query OK, 0 rows affected (0.08 sec) mysql> load mysql users to runtime; Query OK, 0 rows affected (0.00 sec) mysql> save mysql users to disk; Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO mysql_query_rules(active,match_pattern,destination_hostgroup,apply) VALUES(1,'^SELECT.*FOR UPDATE$',100,1); Query OK, 1 row affected (0.01 sec) mysql> INSERT INTO mysql_query_rules(active,match_pattern,destination_hostgroup,apply) VALUES(1,'^SELECT',101,1); Query OK, 1 row affected (0.00 sec) mysql> LOAD MYSQL QUERY RULES TO RUNTIME; Query OK, 0 rows affected (0.00 sec) mysql> SAVE MYSQL QUERY RULES TO DISK; Query OK, 0 rows affected (0.04 sec)
[root@localhost ~]# mysql -uroot -p123456 -h172.16.16.34 -P6033 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 22Server version: 5.7.14 (ProxySQL) Copyright (c) 2000, 2016, 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> select * from maxiangqian.test;+-----+------+ | id | name | +-----+------+ | 1 | qq | | 2 | qq | | 4 | aa | | 11 | a | | 111 | a | +-----+------+5 rows in set (0.04 sec)
mysql> select * from stats_mysql_query_digest;
mysql> select @@server_id;+-------------+ | @@server_id | +-------------+ | 353307 | +-------------+1 row in set (0.01 sec)
mysql> select * from maxiangqian.test for update;+-----+------+ | id | name | +-----+------+ | 1 | qq | | 2 | qq | | 4 | aa | | 11 | a | | 111 | a | +-----+------+5 rows in set (0.00 sec)
mysql> select * from stats_mysql_query_digest;
위 내용은 사용할 구성에서 ProxySQL 읽기-쓰기 분리의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

Java 9의 모듈 시스템을 사용하여 코드를 분리하고 격리하는 방법 소프트웨어 규모가 계속 확장됨에 따라 코드의 복잡성도 계속해서 증가합니다. 코드를 더 잘 구성하고 관리하기 위해 Java9에서는 모듈 시스템을 도입했습니다. 모듈 시스템의 출현으로 기존 패키지 종속성 문제가 해결되어 코드 분리 및 격리가 더욱 쉽고 유연해졌습니다. 이 기사에서는 Java 9의 모듈 시스템을 사용하여 코드 분리 및 격리를 달성하는 방법을 소개합니다. 1. 모듈 정의 Java9에서는 module 키워드를 사용하여 정의할 수 있습니다.

PHP를 사용하여 데이터 캐싱 및 읽기-쓰기 기능을 구현하는 방법 캐싱은 시스템 성능을 향상시키는 중요한 방법입니다. 캐싱을 통해 자주 사용하는 데이터를 메모리에 저장하여 데이터 읽기 속도를 높일 수 있습니다. PHP에서는 다양한 방법을 사용하여 데이터 캐싱과 읽기 및 쓰기 기능을 구현할 수 있습니다. 이 기사에서는 파일 캐싱 사용과 메모리 캐싱 사용이라는 두 가지 일반적인 방법을 소개합니다. 1. 파일 캐싱을 사용합니다. 파일 캐싱은 이후 읽기를 위해 데이터를 파일에 저장합니다. 다음은 파일 캐싱을 사용하여 데이터를 읽고 쓰는 샘플 코드입니다.

제목: Golang 프런트엔드 및 백엔드 분리 개발에서 프런트엔드 기술 선택에 대한 제안 웹 애플리케이션의 복잡성과 요구가 계속 증가함에 따라 프런트엔드 및 백엔드 분리 개발 모델이 점점 더 대중화되고 있습니다. 이 개발 모델에서 백엔드는 비즈니스 로직 처리를 담당하고 프런트엔드는 페이지 표시 및 사용자와의 상호 작용을 담당합니다. Golang을 백엔드 언어로 사용하는 개발팀의 경우 올바른 프런트엔드 기술을 선택하는 것이 중요합니다. 이 기사에서는 Golang에서 프런트엔드와 백엔드를 별도로 개발할 때 선택할 권장 프런트엔드 기술에 대해 논의하고,

FlexIOTester라고도 알려진 Concept fio는 JensAxboe가 작성한 애플리케이션입니다. Jens는 LinuxKernel에서 blockIOsubsystem의 관리자입니다. FIO는 네트워크 파일 시스템 및 디스크 성능을 테스트하는 데 사용되는 도구로, 머신 모델을 확인하고 파일 시스템 성능을 비교하는 데 자주 사용됩니다. 자동으로 클러스터 시스템 목록에 fio 명령을 보내고 작은 파일에 대한 IOPS와 큰 파일에 대한 처리량 데이터를 수집합니다. rw=[mode]rwmixwrite=30 혼합 읽기 및 쓰기 모드에서 쓰기는 30% 모드를 차지합니다.read 순차 읽기 쓰기 순차 쓰기 읽기 쓰기 순차 혼합 읽기 및 쓰기 randwrite 무작위 쓰기 r

파일 시스템 APIJava 파일 작업의 내부 원칙은 운영 체제의 파일 시스템 API와 밀접하게 관련되어 있습니다. Java에서 파일 작업은 java.NIO 패키지의 java.nio.file 모듈에 의해 제공됩니다. 이 모듈은 파일 시스템 API의 캡슐화를 제공하므로 Java 개발자는 통합 API를 사용하여 다양한 운영 체제에서 파일 작업을 수행할 수 있습니다. 파일 객체 Java 프로그램이 파일에 액세스해야 하는 경우 먼저 java.nio.file.Path 객체를 생성해야 합니다. Path 객체는 절대 경로 또는 상대 경로일 수 있는 파일 시스템의 경로를 나타냅니다. Path 객체가 생성되면 이를 사용하여 이름과 같은 파일의 다양한 속성을 가져올 수 있습니다.

Java DBF(dBaseFile)에서 DBF 파일을 처리하는 읽기 및 쓰기 방법을 해독하는 것은 일반적으로 테이블 형식 데이터를 저장하는 데 사용되는 일반적인 데이터베이스 파일 형식입니다. Java 프로그램에서 DBF 파일 읽기 및 쓰기 처리는 비교적 일반적인 요구 사항입니다. 이 기사에서는 Java를 사용하여 이 프로세스를 해독하는 방법을 소개하고 특정 코드 예제를 제공합니다. 1. DBF 파일 읽기 Java에서 DBF 파일을 읽으려면 일반적으로 dbfread 라이브러리와 같은 타사 라이브러리를 사용해야 합니다. 먼저 프로젝트를 구성해야 합니다.

PHP 개발자는 웹사이트 개발 과정에서 데이터베이스 작업에 직면하는 경우가 많습니다. 매우 널리 사용되는 데이터베이스 관리 시스템인 MySQL의 읽기-쓰기 분리는 웹사이트 성능을 향상시키는 중요한 수단 중 하나입니다. PHP 개발에서 MySQL 읽기-쓰기 분리를 구현하면 웹 사이트의 동시 액세스 기능과 사용자 경험을 크게 향상시킬 수 있습니다. 이 기사에서는 MySQL 읽기-쓰기 분리 구현 방법을 자세히 소개하고, PHP 개발자가 읽기-쓰기 분리 기능을 더 잘 이해하고 적용할 수 있도록 구체적인 PHP 코드 예제를 제공합니다. MySQL은 무엇을 읽습니까?

정적 자원 분리를 통해 Java 웹사이트의 접속 속도를 향상시키는 방법은 무엇입니까? 인터넷의 급속한 발전으로 인해 정보를 얻고 소통하기 위해 웹사이트를 이용하는 사람들이 점점 더 많아지고 있습니다. Java 웹 사이트의 경우 액세스 속도가 매우 중요하며 이는 사용자 경험과 웹 사이트의 성공에 직접적인 영향을 미칩니다. 그 중 정적 리소스의 로딩 속도는 웹 사이트 접속 속도에 영향을 미치는 중요한 요소 중 하나입니다. 이 기사에서는 정적 자원 분리를 통해 Java 웹사이트의 액세스 속도를 향상시키는 방법을 소개합니다. 정적 리소스란 무엇입니까? 먼저 정적 리소스가 무엇인지 명확히 해야 합니다.
