programing

원격 연결이 간헐적임

sourcejob 2022. 9. 30. 11:05
반응형

원격 연결이 간헐적임

MariaDB 서버에 문제가 있습니다.

서버 A 데비안:MariaDB + apache2

서버 B Debian: apache2 + (A) 서버에서 MariaDB로의 리모트 액세스.

문제는 서버 B가 MariaDB와의 연결이 자주 끊긴다는 것입니다.연결이 정상인 경우도 있지만 "Server has away"라는 오류가 표시될 수 있습니다.

서버 A apache는 localhost를 통해 MariaBD와 함께 작동하며 모든 것이 정상적으로 작동합니다.

iptables 문제인 줄 알았어요.

root@xxx:/home/x# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql state NEW,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --

my.cnf 파일도 다음과 같습니다.

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
external-locking
delay-key-write=OFF
query-cache-size=0
skip-name-resolve
default-storage-engine=INNODB
    character-set-server=utf8
    collation-server=utf8_bin

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 195....
#
# * Fine Tuning
#
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 10000
table_cache            = 128
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 10M
query_cache_size        = 160M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#slow_query_log      = 1
#long_query_time = 2
#log_queries_not_using_indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

이 문제를 어떻게 해결해야 할지...다른 서버에서도 MariaDB로의 접속을 테스트했지만 접속이 끊어지고 있었습니다.여기 적혀있는 것도 다 했어요.https://dev.mysql.com/doc/refman/5.7/en/gone-away.html

아무 도움도 없었다.감사합니다.

문제는 모든 요청이 데이터베이스 서버에 대한 새로운 연결을 생성하는 것입니다.정의된 양의 접속만 처리할 수 있기 때문에 더 이상 접속을 허용하지 않고 위의 오류가 발생합니다.

Apache 요청을 처리하고 데이터베이스에 대한 하나 이상의 영구 연결이 있는 Apache 서버에서 (마이크로) 서비스를 사용합니다.

Apache -> 서비스 -> _permanent_connection_ -> 데이터베이스

언급URL : https://stackoverflow.com/questions/49515112/remote-connection-is-intermittent

반응형