0

我正在尝试启用 Java Flight Recorder 以在使用 Neo4j Desktop 运行 Cypher 查询时每 10 秒收集一次线程转储。但是在 Neo4j 桌面的“设置”选项卡(配置文件)中,推荐的飞行记录器选项无法识别并在启动过程中抛出错误。

我正在使用 Oracle JDK 11。

这些是我在文件中输入的命令 -

# flight recorder settings
dbms.jvm.additional=-XX:+UnlockCommercialFeatures
dbms.jvm.additional=-XX:+FlightRecorder
dbms.jvm.additional=-XX:FlightRecorderOptions=stackdepth=500
dbms.jvm.additional=-XX:+UnlockDiagnosticVMOptions
dbms.jvm.additional=-XX:+DebugNonSafepoints

当我启动数据库时,这些会引发错误 -

Active database: graph.db
Directories in use:
  home:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3
  config:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/conf
  logs:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/logs
  plugins:      /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/plugins
  import:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/import
  data:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/data
  certificates: /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/certificates
  run:          /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/run
Starting Neo4j.
Unrecognized VM option 'UnlockCommercialFeatures'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Active database: graph.db
Directories in use:
  home:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3
  config:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/conf
  logs:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/logs
  plugins:      /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/plugins
  import:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/import
  data:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/data
  certificates: /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/certificates
  run:          /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/run
Starting Neo4j.
Unrecognized VM option 'FlightRecorder'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

通过在另一个简单程序上进行测试,我已经验证了 Flight Recorder 确实可以在我的机器上运行 -

java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=120s,filename=myrecording.jfr OOMEGenerator

此命令工作正常并成功生成记录。

还有其他方法可以在配置文件中启用飞行记录器设置吗?

4

1 回答 1

0

Neo4j Desktop 包含一个来自 Azul 的 Java 虚拟机,它基于 OpenJDK,无法识别 -XX:+UnlockCommercialFeatures 标志。

由于 Flight Recorder 已开源(JDK 11),因此不再需要该标志。Oracle JDK 将忽略该标志。

最简单的就是删除 -XX:+UnlockCommercialFeatures 标志。

如果这不起作用,即它抱怨-XX:+FlightRecorder 或-XX:StartFlightRecording,可能是因为Neo4j Desktop 附带了不支持Flight Recorder 的较早版本的Azul。

如果是这种情况,您必须切换 JDK。

(您也可以删除 -XX:+FlightRecorder,因为自 Oracle JDK 8u40 之前的版本以来不需要此标志)

于 2019-05-09T03:09:26.410 回答