在有人贬值之前将此问题标记为重复,我已经检查了下面的问题,但没有一个适用于我的情况;
MSSQL VIA FreeTDS, ODBC, and Cpanel Unknown host machine name (severity 2)
php dblib, Error: SQLSTATE[HY000] Unknown host machine name (severity 2)
我有时会在之前工作正常时收到此错误。
我目前要做的是通过sudo service php7.0-fpm restart
重新启动PHP服务。但这会在几天后回来。有什么想法吗?
我正在使用以下PHP版本的Laravel 5.3;
PHP 7.0.28-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.28-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
以下是/etc/freetds/freetds.conf
;
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
#; tds version = 4.2
tds version = 8.0
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
dump file = /var/log/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 5242880
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[egServer70]
host = ntmachine.domain.com
port = 1433
tds version = 7.0
以下是/var/log/freetds.log
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Preparing Packet Application Data(23) with length: 338 and min pad: 0
net.c:1259:GNUTLS: level 9:
ENC[0xbd2738ac20]: cipher: AES-256-CBC, MAC: SHA384, Epoch: 1
net.c:1259:GNUTLS: level 11:
WRITE: enqueued 421 bytes for 0xbd27345690. Total 421 bytes.
net.c:1259:GNUTLS: level 11:
WRITE FLUSH: 421 bytes in buffer.
net.c:1242:in tds_push_func
net.c:1259:GNUTLS: level 11:
WRITE: wrote 421 bytes, 0 bytes left.
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Sent Packet[649] Application Data(23) in epoch 1 and length: 421
dblib.c:4639:dbsqlok(0xbd271fa580)
dblib.c:4669:dbsqlok() not done, calling tds_process_tokens()
token.c:540:tds_process_tokens(0xbd27345690, 0x7ffd4b1c45a0, 0x7ffd4b1c45a4, 0x6914)
util.c:156:Changed query state from PENDING to READING
net.c:1201:in tds_pull_func
net.c:1259:GNUTLS: level 10:
READ: Got 5 bytes from 0xbd27345690
net.c:1259:GNUTLS: level 10:
READ: read 5 bytes from 0xbd27345690
net.c:1259:GNUTLS: level 10:
RB: Have 0 bytes into buffer. Adding 5 bytes.
net.c:1259:GNUTLS: level 10:
RB: Requested 5 bytes
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: SSL 3.3 Application Data packet received. Epoch 0, length: 96
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Expected Packet Application Data(23)
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Received Packet Application Data(23) with length: 96
net.c:1201:in tds_pull_func
net.c:1259:GNUTLS: level 10:
READ: Got 96 bytes from 0xbd27345690
net.c:1259:GNUTLS: level 10:
READ: read 96 bytes from 0xbd27345690
net.c:1259:GNUTLS: level 10:
RB: Have 5 bytes into buffer. Adding 96 bytes.
net.c:1259:GNUTLS: level 10:
RB: Requested 101 bytes
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Decrypted Packet[3886] Application Data(23) with length: 17
net.c:557:Received header
0000 04 01 00 11 00 73 01 00- |.....s..|
net.c:611:Received packet
0000 04 01 00 11 00 73 01 00-fd 10 00 c5 00 01 00 00 |.....s.. ........|
0010 00 - |.|
token.c:555:processing result tokens. marker is fd(DONE)
token.c:2339:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2355:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2370: rows_affected = 1
util.c:104:logic error: cannot change query state from IDLE to PENDING
dblib.c:4707:dbsqlok() end status is SUCCEED
dblib.c:4718:dbsqlok() end status was success
dblib.c:1668:dbresults(0xbd271fa580)
dblib.c:1674:dbresults: dbresults_state is 5 (_DB_RES_SUCCEED)
dblib.c:1657:dbresults returning 1 (SUCCEED)
dblib.c:2761:dbcount(0xbd271fa580)
dblib.c:1813:dbnumcols(0xbd271fa580)
dblib.c:2761:dbcount(0xbd271fa580)
dblib.c:1813:dbnumcols(0xbd271fa580)
dblib.c:1443:dbclose(0xbd271fa580)
dblib.c:258:dblib_del_connection(0x7f878af82780, 0xbd27345690)
mem.c:615:tds_free_all_results()
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Start of epoch cleanup
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: End of epoch cleanup
net.c:1259:GNUTLS: level 5:
REC[0xbd2738ac20]: Epoch #1 freed
util.c:156:Changed query state from IDLE to DEAD
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5882:dbfreebuf(0xbd271fa580)
dblib.c:739:dbloginfree(0xbd273db3f0)
dblib.c:1512:dbexit(void)
dblib.c:305:dblib_release_tds_ctx(1)
编辑:我发现在短时间内插入了如此多的记录时会发生这种情况。但仍然不知道是什么原因。