栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Couldn‘t flush user prefs: java.util.prefs.BackingStoreException: Couldn‘t get file lock

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Couldn‘t flush user prefs: java.util.prefs.BackingStoreException: Couldn‘t get file lock

最近在部署秒杀项目的时候,部署完以后,发现项目报错,如下:

文章目录
  • 问题详情
  • 解决方法
  • ulimit常用命令

问题详情
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4446
summary +   5121 in 00:00:35 =  144.6/s Avg:  5662 Min:  1019 Max:  8053 Err:  5121 (100.00%) Active: 4270 Started: 10000 Finished: 5730
Apr 26, 2022 11:36:10 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode
WARNING: Could not lock User prefs.  Unix error code 24.
Apr 26, 2022 11:36:10 AM java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
summary +   4879 in 00:00:01 = 9240.5/s Avg: 12363 Min:  1038 Max: 15500 Err:  1274 (26.11%) Active: 0 Started: 10000 Finished: 10000
summary =  10000 in 00:00:36 =  278.3/s Avg:  8931 Min:  1019 Max: 15500 Err:  6395 (63.95%)
Tidying up ...    @ Tue Apr 26 11:36:11 CST 2022 (1650944171289)

通过对报错文件的分析找到关键错误如下:

解决方法

linux中关于默认打开文件的数量是1024,通过ulimit -n命令可以查看

[root@bdc-test133 ~]# ulimit -n
1024

由于默认的打开文件数量1024无法支撑现在的并发请求,所以需要修改该参数值。

临时生效:可以使用ulimit -n 102400临时生效
永久生效:
修改/etc/security/limits.conf,增加如下信息:

  • soft nofile 65536 --软限制
  • hard nofile 65536 --硬限制
    然后退出当前会话,重新登录。 即可生效,重启配置也会保留。

注意:
nofile可以设置的最大值为 1048576(2**20),设置的值大于该数,就会进行登录不了。
soft 设置的值 一定要小于或等于 hard 的值。

ulimit常用命令
      -S	use the `soft' resource limit # 设置软限制
      -H	use the `hard' resource limit # 设置硬限制
      -a	all current limits are reported# 显示所有的配置。
      -b	the socket buffer size # 设置socket buffer 的最大值。
      -c	the maximum size of core files created # 设置core文件的最大值.
      -d	the maximum size of a process's data segment  # 设置线程数据段的最大值
      -e	the maximum scheduling priority (`nice') # 设置最大调度优先级
      -f	the maximum size of files written by the shell and its children # 创建文件的最大值。
      -i	the maximum number of pending signals # 设置最大的等待信号
      -l	the maximum size a process may lock into memory #设置在内存中锁定进程的最大值
      -m	the maximum resident set size 
      -n	the maximum number of open file descriptors # 设置最大可以的打开文件描述符。
      -p	the pipe buffer size
      -q	the maximum number of bytes in POSIX message queues
      -r	the maximum real-time scheduling priority
      -s	the maximum stack size
      -t	the maximum amount of cpu time in seconds
      -u	the maximum number of user processes  # 设置用户可以创建的最大进程数。
      -v	the size of virtual memory  # 设置虚拟内存的最大值
      -x	the maximum number of file locks

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/866044.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号