在Neo4j Desktop中启用Java Flight Recorder的使用

时间:2019-05-08 19:57:52

标签: java neo4j cypher jfr

在尝试使用Neo4j Desktop运行Cypher查询时,我试图启用Java Flight Recorder的功能,以便每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

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

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

1 个答案:

答案 0 :(得分: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之前的版本以来不再需要此标志)