Neo4j 系统服务
本页面涵盖了 Neo4j 系统服务的配置与操作。假设您的系统使用 systemd(大多数 Linux 发行版均如此)。
|
位于 /etc/rc.d/init.d/ 或 /etc/init.d 中的 System V (SysV) 初始化脚本包含在 Neo4j 软件包安装中。但是,从 2026.01 开始,它们已被弃用,并将在未来的版本中移除。 所有当前支持的 Linux 发行版默认均使用 |
|
设置打开文件数限制。
有关如何设置用户可同时打开的文件数量的说明,请参阅 设置打开文件数。 |
服务控制
系统服务通过 systemctl 命令进行控制。它接受多个命令。
systemctl {start|stop|restart} neo4j
服务自定义项可以放置在服务覆盖文件(override file)中。要编辑您的特定选项,请执行以下命令,这将打开相应文件的编辑器:
systemctl edit neo4j
然后将任何自定义设置放置在 [Service] 部分下。以下示例列出了某些用户可能希望修改的默认值:
[Service]
# The user and group which the service runs as.
User=neo4j
Group=neo4j
# If it takes longer than this then the shutdown is considered to have failed.
# This may need to be increased if the system serves long-running transactions.
TimeoutSec=120
您可以使用以下命令打印有效的服务配置,包括可能存在的覆盖项:
systemctl cat neo4j
如果您更改了任何设置,请记得重启 neo4j。
systemctl restart neo4j
日志
Neo4j 的日志写入到 journald 中,可以使用 journalctl 命令查看:
journalctl -e -u neo4j
journald 会在一定时间后自动轮转日志,默认情况下,它通常不会在重启后保留。详细信息请参阅 man journald.conf。
卸载 Neo4j
请按照以下步骤卸载 Neo4j
-
(可选) 创建 备份 以避免数据丢失。
-
卸载 Neo4j
sudo apt remove neo4j