我有一个使用tomcat托管的应用程序,它在12-18小时后停止响应,我可以访问其他应用程序,如tomcat管理器,即tomcat进程正在运行,但我部署的应用程序停止响应。 我在日志中找不到任何真正重要的东西,我可以直接得到一些理由。 我正在使用struts2 + spring + ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我继承了Windows Server(2016),并且拥有一个不是我编写的使用MySQL数据库的专有软件。 我是SQL的新手。
有客户端软件将全天随机连接到服务器。 根据我们的忙碌程度,全天10到200台不同的计算机将登录到该服务器。
我们使用带有4个虚拟内核,8GB RAM和204GB本地磁盘的VPS。
似乎每隔12-18小时我们就会遇到软件挂起的问题,然后任务管理器会显示mysqld的99-100%CPU使用率
在我强制退出软件然后重新启动mysql服务之前,它不会再次正常运行。
这是我之前跟踪的设置文件。
my.ini设置:
[client]
port=3306
[mysql]
no-beep=
default-character-set=utf8
[mysqld]
port=3306
datadir=C:/ProgramData/MySQL/MySQL Server 5.7\Data
character-set-server=utf8
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
log-output=FILE
general-log=0
general_log_file="xyz.log"
slow-query-log=1
slow_query_log_file="xyz-slow.log"
long_query_time=10
log-error="xyz.err"
server-id=1
secure-file-priv="C:/ProgramData/MySQL/MySQL Server 5.7/Uploads"
max_connections=151
table_open_cache=2000
tmp_table_size=249M
thread_cache_size=10
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=486M
key_buffer_size=8M
read_buffer_size=64K
read_rnd_buffer_size=256K
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=8M
innodb_log_file_size=48M
innodb_thread_concurrency=13
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=256K
max_allowed_packet=4M
max_connect_errors=100
open_files_limit=4161
sort_buffer_size=256K
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
这是用于Windows的MySQLTuner的图片,其结果是: mysql_tuner
只是想了解我们可以在此处做什么以缓解此问题。 看来我们需要运行OPTIMIZE来修复表的碎片。
它还显示了具有0%缓存的23M选择。
innodb数据大小/缓冲池为687M / 8M
任何帮助,将不胜感激。
[编辑]
我只是运行了在另一个线程中找到的以下命令:
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;
我的返回值为2,所以我应该设置innodb_buffer_pool_size=2G
吗?
SET GLOBAL innodb_buffer_pool_size=2*1024*1024*1024;
会没事的。 您有8GB的计算机。 我将花一些时间让MySQL动态地实现此目的。 在30分钟内使用SELECT @@innodb_buffer_pool_size;
查看它是否完成了您的动态请求。
这是SHOW CREATE TABLE的配方:
mysql> USE xyz; SHOW CREATE TABLE recipes;
Database changed
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| recipes | CREATE TABLE `recipes` (
`id` int(11) NOT NULL,
`name` varchar(64) NOT NULL,
`dname` varchar(64) NOT NULL DEFAULT '',
`descrpara` text NOT NULL,
`category` varchar(32) NOT NULL,
`costperserving` float NOT NULL DEFAULT '0',
`batchsize` int(11) NOT NULL DEFAULT '1',
`servname` varchar(32) NOT NULL DEFAULT 'Serving',
`rectype` tinyint(4) NOT NULL DEFAULT '0',
`servweight` float NOT NULL DEFAULT '0',
`servflvol` float NOT NULL DEFAULT '0',
`flags` tinyint(4) NOT NULL DEFAULT '0',
`isapproved` tinyint(4) NOT NULL DEFAULT '0',
`isapproved2` tinyint(4) NOT NULL DEFAULT '0',
`tags` varchar(128) NOT NULL DEFAULT '',
`allrestr` tinyint(4) NOT NULL DEFAULT '0',
`numsides` tinyint(4) NOT NULL DEFAULT '0',
`utensils` varchar(64) NOT NULL DEFAULT '',
`active` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
再次,我是超级新手,但是my.ini文件中是否可能显示utf8的默认字符集,但是在此显示了latin1?
我会在24小时后再次更新
的PasteBin链接
超过1天的正常运行时间后,MySQLTuner。 这也是在将innodb_buffer_pool_size = 8M更改为1G之后。 从那以后,mysqld的总RAM使用量约为1.25G。
MySQL Tuner 0.8.3 - Peter Chapman <peter@conglomo.co.nz>
Performing tests on localhost:3306 at Friday, 16 November 2018 6:13:41 AM
Currently running supported MySQL version 5.7.24-log
Archive Engine Installed
Berkeley DB Engine Not Installed
Federated Engine Not Installed
InnoDB Engine Installed
ISAM Engine Not Installed
NDBCLUSTER Engine Not Installed
Data in InnoDB tables: 687M (Tables: 257)
Data in MyISAM tables: 6M (Tables: 32)
Total fragmented tables: 67
All database users have passwords assigned
Up for: 1d 10h 33m 15s (49M q [397.000 qps], 38K conn, TX: 43G, RX: 3G)
Reads / Writes: 99% / 1%
Total buffers: 1.0G global + 1.1M per thread (151 max threads)
Maximum possible memory usage: 1.2G (14% of installed RAM)
Slow queries: 1% (4/49M)
Highest usage of available connections: 26% (38/151)
Key buffer size / total MyISAM indexes: 8.0M/1.0M
Key buffer hit rate: 98% (630 cached / 9 reads)
Query cache efficiency: 0% (0 cached / 47M selects)
Query cache prunes per day: 0
Sorts requiring temporary tables: 1% (2K temp sorts / 377K sorts)
Joins performed without indexes: 13254
Temporary tables created on disk: 3% (2K on disk / 79K total)
Thread cache hit rate: 99% (41 created / 38K connections)
Table cache hit rate: 26% (2K open / 7K opened)
Open file limit used: 0% (10/6K)
Table locks acquired immediately: 100% (682 immediate / 682 locks)
InnoDB data size / buffer pool: 687.0M/1.0G
Run OPTIMIZE TABLE to defragment tables for better performance
Adjust your join queries to always utilize indexes
query_cache_limit (> 1M, or use smaller result sets)
join_buffer_size (> 256.0K, or always use indexes with joins)
Scan Completed at Friday, 16 November 2018 6:13:44 AM
建议考虑立即救济
SET GLOBAL innodb_buffer_pool_size=1*1024*1024*1024
从MySQL命令提示符
将为您带来与众不同的世界,并可能在其他细节被整理出来的同时让您生存。
将您的my.ini [mysqld]部分更改为1G,以进行下一次停止/启动服务。
my.ini [mysqld]部分中的其他建议(每秒速率= RPS)
innodb_buffer_pool_size=2G # from 1G reported in SHOW GLOBAL STATUS of 11/16
innodb_lru_scan_depth=100 # from 1024 to conserve CPU cycles every SECOND
thread_cache_size=100 # from 10 to increase threads_cached for increased performance
innodb_io_capacity=1600 # from 200 to allow higher IOPS
read_rnd_buffer_size=192K # from 256K to reduce handler_read_rnd_next RPS of 63407
innodb_log_buffer_size=16M # from 1M for ~ 30 minutes in RAM before WD
open_files_limit=8192 # from 6209 to reduce opened_files RPHour of 152
table_open_cache=3000 # from 2000 to reduce opened_tables RPHour of 258
query_cache_size=0 # from 1M to conserve RAM since QC is OFF
如需其他帮助,请查看我的个人资料,网络个人资料以获取联系信息。
如果您添加评论,请以@wilsonhauck开头,以便SO自动提醒我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.