8.3. 監視

8.3.1. JMX
[注記]注記

Most of the monitoring features are only available in the Advanced and Enterprise editions of Neo4j.

In order to be able to continuously get an overview of the health of a Neo4j database, there are different levels of monitoring facilities available.

8.3.1. JMX

How to connect to a Neo4j instance using JMX and JConsole

First, start your embedded database or the Neo4j Server, for instance using

$NEO4j_SERVER_HOME/bin/neo4j start

Now, start JConsole with

$JAVA_HOME/bin/jconsole

Connect to the process running your Neo4j database instance:

図8.1 Connecting JConsole to the Neo4j Java process

Connecting with JConsole

Now, beside the MBeans exposed by the JVM, you will see an org.neo4j section in the MBeans tab. Under that, you will have access to all the monitoring information exposed by Neo4j.

図8.2 Neo4j MBeans View

Neo4j MBeans view

How to connect to the JMX monitoring programmatically

In order to programmatically connect to the Neo4j JMX server, there are some convenience methods in the Neo4j Management component to help you find out the most commonly used monitoring attributes of Neo4j. For instance, the number of node IDs in use can be obtained with code like:

Neo4jManager manager = new Neo4jManager( graphDb.getManagementBean( Kernel.class ) );
long nodeIDsInUse    = manager.getPrimitivesBean.getNumberOfNodeIdsInUse();

Once you have access to this information, you can use it to for instance expose the values to SNMP or other monitoring systems.

Reference of supported JMX MBeans

表8.1 MBeans exposed by the Neo4j Kernel

NameDescription

org.neo4j:instance=kernel#0,name=Memory Mapping

The status of Neo4j memory mapping

org.neo4j:instance=kernel#0,name=Locking

Information about the Neo4j lock status

org.neo4j:instance=kernel#0,name=Transactions

Information about the Neo4j transaction manager

org.neo4j:instance=kernel#0,name=Cache

Information about the caching in Neo4j

org.neo4j:instance=kernel#0,name=Configuration

The configuration parameters used to configure Neo4j

org.neo4j:instance=kernel#0,name=Primitive count

Estimates of the numbers of different kinds of Neo4j primitives

org.neo4j:instance=kernel#0,name=XA Resources

Information about the XA transaction manager

org.neo4j:instance=kernel#0,name=Store file sizes

Information about the sizes of the different parts of the Neo4j graph store

org.neo4j:instance=kernel#0,name=Kernel

Information about the Neo4j kernel

org.neo4j:instance=kernel#0,name=High Availability

Information an High Availability cluster, if enabled.


表8.2 MBean Memory Mapping

AttributeDescription Type

MemoryPools

Get information about each pool of memory mapped regions from store files with memory mapping enabled

String


表8.3 MBean Locking

AttributeDescription Type

NumberOfAdvertedDeadlocks

The number of lock sequences that would have lead to a deadlock situation that Neo4j has detected and adverted (by throwing DeadlockDetectedException).

Integer


表8.4 MBean Transactions

AttributeDescription Type

NumberOfOpenTransactions

The number of currently open transactions

Integer

PeakNumberOfConcurrentTransactions

The highest number of transactions ever opened concurrently

Integer

NumberOfOpenedTransactions

The total number started transactions

Integer

NumberOfCommittedTransactions

The total number of committed transactionss

Integer


表8.5 MBean Cache

AttributeDescription Type

CacheType

The type of cache used by Neo4j

String

NodeCacheSize

The number of Nodes currently in cache

Integer

RelationshipCacheSize

The number of Relationships currently in cache

Integer

clear()

clear all caches

function, void


表8.6 MBean Configuration

AttributeDescription Type

store_dir

Relative path for where the Neo4j storage directory is located

String

rebuild_idgenerators_fast

Use a quick approach for rebuilding the ID generators. This give quicker recovery time, but will limit the ability to reuse the space of deleted entities.

String

logical_log

Relative path for where the Neo4j logical log is located

String

neostore.propertystore.db.index.keys.mapped_memory

The size to allocate for memory mapping the store for property key strings

String

neostore.propertystore.db.strings.mapped_memory

The size to allocate for memory mapping the string property store

String

neostore.propertystore.db.arrays.mapped_memory

The size to allocate for memory mapping the array property store

String

neo_store

Relative path for where the Neo4j storage information file is located

String

neostore.relationshipstore.db.mapped_memory

The size to allocate for memory mapping the relationship store

String

neostore.propertystore.db.index.mapped_memory

The size to allocate for memory mapping the store for property key indexes

String

create

Configuration attribute

String

enable_remote_shell

Enable a remote shell server which shell clients can log in to

String

neostore.propertystore.db.mapped_memory

The size to allocate for memory mapping the property value store

Integer

neostore.nodestore.db.mapped_memory

The size to allocate for memory mapping the node store

String

dir

Configuration attribute

String


表8.7 MBean Primitive count

AttributeDescription Type

NumberOfNodeIdsInUse

An estimation of the number of nodes used in this Neo4j instance

Integer

NumberOfRelationshipIdsInUse

An estimation of the number of relationships used in this Neo4j instance

Integer

NumberOfPropertyIdsInUse

An estimation of the number of properties used in this Neo4j instance

Integer

NumberOfRelationshipTypeIdsInUse

The number of relationship types used in this Neo4j instance

Integer


表8.8 MBean XA Resources

AttributeDescription Type

XaResources

Information about all XA resources managed by the transaction manager

String


表8.9 MBean Store file sizes

AttributeDescription Type

TotalStoreSize

The total disk space used by this Neo4j instance, in bytes.

Integer

LogicalLogSize

The amount of disk space used by the current Neo4j logical log, in bytes.

Integer

ArrayStoreSize

The amount of disk space used to store array properties, in bytes.

Integer

NodeStoreSize

The amount of disk space used to store nodes, in bytes.

Integer

PropertyStoreSize

The amount of disk space used to store properties (excluding string values and array values), in bytes.

Integer

RelationshipStoreSize

The amount of disk space used to store relationships, in bytes.

Integer

StringStoreSize

The amount of disk space used to store string properties, in bytes.

Integer


表8.10 MBean Kernel

AttributeDescription Type

ReadOnly

Whether this is a read only instance.

boolean

MBeanQuery

An ObjectName that can be used as a query for getting all management beans for this Neo4j instance.

String

KernelStartTime

The time from which this Neo4j instance was in operational mode

Date

StoreCreationDate

The time when this Neo4j graph store was created

Date

StoreId

An identifier that uniquely identifies this Neo4j graph store

String

StoreLogVersion

The current version of the Neo4j store logical log

String

KernelVersion

The version of Neo4j

String

StoreDirectory

The location where the Neo4j store is located

String


表8.11 MBean High Availability

AttributeDescription Type

MachineId

The cluster machine id of this instance

String

Master

True, if this Neo4j instance is currently Master in the cluster

boolean

ConnectedSlaves

A list of conencted slaves in this cluster

String

InstancesInCluster

Information about the other Neo4j instances in this HA cluster

String