简体   繁体   中英

How to make faster queries on remote mysql server

I have 2 servers on OVH, they are on different datacenter in the Europe (SBG1 and GRA1). My controlled ping is 10ms. My websites run many insert and read queries.

When I try my local mysql server it is very fast but when I use the remote mysql server the queries run is delayed.

My Remote Mysql Configuration

# Percona Server template configuration

[mysqld]
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

pid-file=/var/run/mysqld/mysqld.pid
skip-name-resolve
bind-address = 5.196.77.XXX
# skip-networking
sql-mode = 'NO_AUTO_CREATE_USER'
explicit_defaults_for_timestamp = 1
# MyISAM #
key_buffer_size                 = 2G
# SAFETY #
max_allowed_packet              = 10G
# CACHES AND LIMITS #
tmp_table_size                 = 32M
max_heap_table_size            = 32M
query_cache_type               = 1
query_cache_size               = 2M
query_cache_limit              = 1M
join_buffer_size               = 6M
max_connections                = 600
thread_cache_size              = 100
open_files_limit               = 65535
table_definition_cache         = 4096
table_open_cache               = 4096

# INNODB #
innodb_flush_method            = O_DIRECT
innodb_log_files_in_group      = 2
innodb_log_file_size           = 512M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_size        = 20G
innodb_data_file_path          =ibdata1:20M:autoextend

# LOGGING #
log_error                      = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow_query_log                 = 1
long_query_time                = 3
slow_query_log_file            = /var/log/mysql/mysql-slow.log

I don't know how can i connect local connection each servers.

Do i have to use vRack? (I have but i don't know have can i use it) OR Do i have to move my servers to same location?

What should i do

Replication enables data from one MySQL database server (the master) to be copied to one or more MySQL database servers (the slaves). Replication is asynchronous by default; slaves do not need to be connected permanently to receive updates from the master.

If I understood you have a server SA width database DA and a server B with a database DB and a local Server S-Local with database D-Local.

You can replicate the DA and DB databaseson your local Server S-Local. So your query will be faster.

I'm not sure if there is communication between SA and SB, but you can even replicate database DA on Server SB and database DB on Server SA.

My team has to query a distant server. It is very slow. With replication, our query are connected to a local replicated server and it is very useful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM