Neo4j 4.0 / 4.1 配置快速参考 - 单服务器模式,适用于社区版和企业版

本文档提供Neo4j 4.0/4.1在单服务器模式下的配置参考,包括系统环境要求、配置样例及性能调整建议,适用于社区版和企业版。推荐使用JDK 11、至少4核CPU和32GB RAM(分配6GB给Neo4j),并强调硬盘应为SSD。样例配置文件涉及JAVA堆内存、页面缓存、事务内存、监听地址、端口、垃圾收集器以及启用apoc和gds扩展库。

Neo4j 4.0/4.1是最新的Neo4j 图数据库平台产品,提供多数据库、跨库查询、细粒度数据访问控制等丰富特性。相比3.5,4.0在配置方面也有不少改变。为了方便大家快速上手,这里提供一个配置样例。

1、系统环境

- Windows 10,Linux同样适用;

- JDK / OpenJDK 11

- CPU: 4 cores

- RAM: 32GB,分配给Neo4j一共6GB。

- 硬盘:强烈建议用SSD,如果没有就通过USB3 外接一个。

- 适用的数据库大小:<1亿节点、5亿关系,约50GB在数据库目录下。

2、样例配置neo4j.conf 

#*****************************************************************
# Neo4j configuration
#
# For more details and a complete list of settings, please see
# https://neo4j.com/docs/operations-manual/current/reference/configuration-settings/
#*****************************************************************

# The name of the default database.
#dbms.default_database=neo4j

# Paths of directories in the installation.
#dbms.directories.data=data
#dbms.directories.plugins=plugins
#dbms.directories.logs=logs
#dbms.directories.lib=lib
#dbms.directories.run=run
#dbms.directories.metrics=metrics
#dbms.directories.transaction.logs.root=data/transactions
#dbms.directories.dumps.root=data/dumps

# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or comment it out to
# allow files to be loaded from anywhere in the filesystem; this introduces possible security problems. See the
# `LOAD CSV` section of the manual for details.
dbms.directories.import=import

# Whether requests to Neo4j are authenticated.
# To disable authentication, uncomment this line
#dbms.security.auth_enabled=false

# Enable this to be able to upgrade a store from an older version.
dbms.allow_upgrade=true

# Number of databases in Neo4j is limited.
# To change this limit please uncomment and adapt following setting:
# dbms.max_databases=100

# Enable online backups to be taken from this database.
#dbms.backup.enabled=true

# By default the backup service will only listen on localhost.
# To enable remote backups you will have to bind to an external
# network interface (e.g. 0.0.0.0 for all interfaces).
# The protocol running varies depending on deployment. In a Causal Clustering environment this is the
# same protocol that runs on causal_clustering.transaction_listen_address.
#dbms.backup.listen_address=0.0.0.0:6362

#********************************************************************
# Memory Settings
#********************************************************************
#
# Memory settings are specified kilobytes with the 'k' suffix, megabytes with
# 'm' and gigabytes with 'g'.
# If Neo4j is running on a dedicated server, then it is generally recommended
# to leave about 2-4 gigabytes for the operating system, give the JVM enough
# heap to hold all your transaction state and query context, and then leave the
# rest for the page cache.

# Java Heap Size: by default the Java heap size is dynamically calculated based
# on available system resources. Uncomment these lines to set specific initial
# and maximum heap size.
dbms.memory.heap.initial_size=512m
dbms.memory.heap.max_size=2g

# The amount of memory to use for mapping the store files.
# The default page cache memory assumes the machine is dedicated to running
# Neo4j, and is heuristically set to 50% of RAM minus the Java heap size.
dbms.memory.pagecache.size=4g

# Limit the amount of memory that all of the running transaction can consume.
# By default there is no limit.
dbms.memory.transaction.global_max_size=2g

# Limit the amount of memory that a single transaction can consume.
# By default there is no limit.
dbms.memory.transaction.max_size=256m

# Transaction state location. It is recommended to use ON_HEAP.
dbms.tx_state.memory_allocation=ON_HEAP

#*****************************************************************
# Network connector configuration
#*****************************************************************

# With default configuration Neo4j only accepts local connections.
# To accept non-local connections, uncomment this line:
dbms.default_listen_address=0.0.0.0

# You can also choose a specific network interface, and configure a non-default
# port for each connector, by setting their individual listen_address.

# The address at which this server can be reached by its clients. This may be the server's IP address or DNS name, or
# it may be the address of a reverse proxy which sits in front of the server. This setting may be overridden for
# individual connectors below.
dbms.default_advertised_address=192.168.0.209

# You can also choose a specific advertised hostname or IP address, and
# configure an advertised port for each connector, by setting their
# individual advertised_address.

# By default, encryption is turned off.
# To turn on encryption, an ssl policy for the connector needs to be configured
# Read more in SSL policy section in this file for how to define a SSL policy.

# Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=DISABLED
#dbms.connector.bolt.listen_address=:7687


# To add: bolt connection pool
#dbms.connector.bolt.thread_pool_min_size=5
#dbms.connector.bolt.thread_pool_max_size=400
#dbms.connector.bolt.thread_pool_keep_alive=5m


# HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
#dbms.connector.http.listen_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=false
#dbms.connector.https.listen_address=:7473

# Cluster Routing Connector. Enables the opening of an additional port to allow
# for internal communication using the same security configuration as CLUSTER
#dbms.routing.enabled=false

# Customize the listen address used for the routing connector port.
#dbms.routing.listen_address=0.0.0.0:7688

# Number of Neo4j worker threads.
#dbms.threads.worker_count=

#*****************************************************************
# SSL policy configuration
#*****************************************************************

# Each policy is configured under a separate namespace, e.g.
#    dbms.ssl.policy.<scope>.*
#    <scope> can be any of 'bolt', 'https', 'cluster' or 'backup'
#
# The scope is the name of the component where the policy will be used
# Each component where the use of an ssl policy is desired needs to declare at least one setting of the policy.
# Allowable values are 'bolt', 'https', 'cluster' or 'backup'.

# E.g if bolt and https connectors should use the same policy, the following could be declared
#   dbms.ssl.policy.bolt.base_directory=certificates/default
#   dbms.ssl.policy.https.base_directory=certificates/default
# However, it's strongly encouraged to not use the same key pair for multiple scopes.
#
# N.B: Note that a connector must be configured to support/require
#      SSL/TLS for the policy to actually be utilized.
#
# see: dbms.connector.*.tls_level

# SSL settings (dbms.ssl.policy.<scope>.*)
#  .base_directory       Base directory for SSL policies paths. All relative paths within the
#                        SSL configuration will be resolved from the base dir.
#
#  .private_key          A path to the key file relative to the '.base_directory'.
#
#  .private_key_password The password for the private key.
#
#  .public_certificate   A path to the public certificate file relative to the '.base_directory'.
#
#  .trusted_dir          A path to a directory containing trusted certificates.
#
#  .revoked_dir          Path to the directory with Certificate Revocation Lists (CRLs).
#
#  .verify_hostname      If true, the server will verify the hostname that the client uses to connect with. In order
#                        for this to work, the server public certificate must have a valid CN and/or matching
#                        Subject Alternative Names.
#
#  .client_auth          How the client should be authorized. Possible values are: 'none', 'optional', 'require'.
#
#  .tls_versions         A comma-separated list of allowed TLS versions. By de
Neo4j 社区版支持使用 `neo4j-admin` 工具进行数据库的备份恢复操作。通过 `neo4j-admin backup` 命令,用户可以创建数据库的完整备份,确保在发生数据损坏或系统故障时能够恢复数据[^3]。该命令的基本使用方式如下: ```bash neo4j-admin backup --backup-dir=/path/to/backup --name=latest-backup --from=neo4j://localhost:7687 ``` 上述命令将数据库备份至指定目录,并标记为 `latest-backup`。备份过程中,工具会复制数据库的存储文件,包括节点、关系、属性索引等信息,确保备份的完整性。 在需要恢复数据时,可以使用 `neo4j-admin restore` 命令将数据库恢复至备份状态。恢复操作会覆盖当前数据库的内容,因此在执行前应确保已有数据已做好备份。其基本用法如下: ```bash neo4j-admin restore --backup-dir=/path/to/backup --name=latest-backup --database=neo4j --from=/path/to/backup/latest-backup ``` 执行恢复后,Neo4j 会将备份中的数据重新加载至指定数据库中。需要注意的是,恢复操作应在数据库停止状态下进行,以确保数据一致性[^3]。 此外,在执行备份恢复操作前,建议使用 `neo4j-admin check-consistency` 验证数据库的完整性,以确保备份数据的可靠性。该命令能够检测存储文件的结构是否完整,包括节点、关系、属性索引的一致性,并输出检查结果[^3]。 --- ### 数据备份与恢复的注意事项 - **备份路径权限**:执行备份恢复操作的用户需要具备对目标目录的读写权限,否则可能导致操作失败。 - **数据库状态**:为了确保数据一致性,建议在执行备份恢复操作时关闭 Neo4j 数据库服务。 - **版本兼容性**:备份恢复操作需确保 Neo4j 版本兼容性,不同版本之间可能存在存储格式差异,导致恢复失败。 --- ### 示例:完整备份与恢复流程 ```bash # 停止 Neo4j 服务 neo4j stop # 执行数据库备份 neo4j-admin backup --backup-dir=/var/backups/neo4j --name=neo4j_backup_20231001 --from=neo4j://localhost:7687 # 恢复数据库 neo4j-admin restore --backup-dir=/var/backups/neo4j --name=neo4j_backup_20231001 --database=neo4j --from=/var/backups/neo4j/neo4j_backup_20231001 # 启动 Neo4j 服务 neo4j start ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值