Tugraph Running
This document describes the operation mode of the TuGraph service, starting, stopping, and restarting operations.And TuGraph’s service configuration parameters, configuration file format, and command-line configuration parameters.
1. Prerequisites
TuGraph has the following prerequisites for its execution: a correct installation of TuGraph.
TuGraph execution requires ensuring that the library file “liblgraph.so” is located in the environment variable LD_LIBRARY_PATH.
The user running the TuGraph process does not need superuser privileges. However, they need read permissions for the configuration file (usually lgraph.json) and any files referenced within it. Additionally, they should have write permissions for data folders, log files, etc.
2.The operation mode
TuGraph can be started as a normal process in the foreground or as a daemon in the background.
When running as a normal process, TuGraph can print logs directly to the terminal, which is handy when debugging server configurations. However, because the foreground process is terminated after the terminal exits, the user must ensure that the terminal remains open while the TuGraph server is running. In daemon mode, on the other hand, the TuGraph server can continue to run even if the terminal that started it exits. If TuGraph needs to run for a long time, it is recommended to start the TuGraph server in daemon mode.
2.1.Running a normal process
The lgraph_server -d run
command runs TuGraph as a normal process. Normal processes depend on the command line terminal, so when the terminal ends, the TuGraph process is automatically terminated. Normal process mode with --log_dir ""
can output the process log directly to the terminal, so it is easier to debug.Note: When not using the -d run
command, the default behavior is to run as a normal process.
The default path for lgraph_server is: /usr/local/bin/lgraph_server.
The default path for lgraph.json is: /usr/local/etc/lgraph.json.
Start the command:
$ ./lgraph_server -d run -c lgraph.json --log_dir ""
or:
$ ./lgraph_server -c lgraph.json --log_dir ""
Example of running output in normal mode:
**********************************************************************
* TuGraph Graph Database v4.3.2 *
* *
* Copyright(C) 2018-2023 Ant Group. All rights reserved. *
* *
**********************************************************************
Server is configured with the following parameters:
Backup log enable: 0
DB directory: /var/lib/lgraph/data
HA enable: 0
HTTP port: 7070
HTTP web dir: /usr/local/share/lgraph/browser-resource
RPC enable: 1
RPC port: 9090
SSL enable: 0
Whether the token is unlimited: 0
audit log enable: 0
bind host: 0.0.0.0
bolt port: 7687
disable auth: 0
durable: 0
log dir: ""
log verbose: 1
number of bolt io threads: 1
optimistic transaction: 0
reset admin password if you forget: 0
subprocess idle limit: 600
thread limit: 0
[20240730 15:34:27.848783 0x00007f81bb3889c0 INFO src/server/lgraph_server.h:78] [StateMachine] Builtin services are disabled according to ServerOptions.has_builtin_services
[20240730 15:34:27.849116 0x00007f81bb3889c0 INFO src/server/lgraph_server.cpp:268] Listening for RPC on port 9090
[20240730 15:34:27.868819 0x00007f81bb3889c0 INFO src/restful/server/rest_server.cpp:479] Listening for REST on port 7070
[20240730 15:34:27.869970 0x00006e7d435ff700 INFO src/server/bolt_server.cpp:36] bolt server run
[20240730 15:34:27.870040 0x00007f81bb3889c0 INFO src/server/lgraph_server.cpp:302] Server started.
In normal process mode, the user can prematurely terminate the TuGraph process by pressing ‘CTRL+C’.
2.2.Run process daemon mode
Start the command:
$ ./lgraph_server -d start -c lgraph.json
Example output from running in daemon mode:
Starting lgraph...
The service process is started at pid 12109.
The TuGraph server process started by this command is a daemon process that loads the relevant configuration from the file ‘lgraph.json’. After the server starts, it will start printing logs in a log file that can then be used to determine the status of the server.
3.Service operation
3.1.Start the service
TuGraph needs to be started using the ‘lgraph_server -d start’ command line. The following is an example of the command to start TuGraph:
$ ./lgraph_server -d start -c lgraph.json
Starting lgraph...
The service process is started at pid 12109.
The TuGraph server process started by this command is a daemon process that loads the relevant configuration from the file ‘lgraph.json’. After the server starts, it will start printing logs in a log file that can then be used to determine the status of the server.
3.2.Stop the service
You can stop the TuGraph daemon using the ‘kill’ command and the ‘lgraph_server -d stop’ command. Since it is possible to run multiple TuGraph server processes on the same computer, we distinguish between the different server processes using the ‘.pid ‘file, which is written to the working directory where the process was started. Therefore, you need to run the command ‘lgraph_server-d stop’ in the same working directory to stop the correct server process.
user@host:~/tugraph$ ./lgraph_server -d start -c lgraph.json
20200508122306.378: Starting lgraph...
20200508122306.379: The service process is started at pid 93.
user@host:~/tugraph$ cat ./lgraph.pid
93
user@host:~/tugraph$ ./lgraph_server -d stop -c lgraph.json
20200508122334.857: Stopping lgraph...
20200508122334.857: Process stopped.
3.3.Restart the service
Users can also restart the TuGraph service by ‘lgraph_server -d restart’ :
$ ./lgraph_server -d restart
Stopping lgraph...
Process stopped.
Starting lgraph...
The service process is started at pid 20899.
3.4.Switch between old and new front-end
To access the container and choose between the old and new versions of the frontend, modify the configuration file located at “/usr/local/etc/lgraph.json”. For the old version, change the value of the “web” parameter to “/usr/local/share/lgraph/resource”; for the new version, set it to “/usr/local/share/lgraph/browser-resource”. Once you’ve finished editing the configuration file, run the command docker restart tugraph
to apply the changes. Bear in mind that the new version is the default selection.
4.Service configuration
The TuGraph server loads configurations from the configuration file and command line options at startup, and if different values are specified for the same option in the configuration file and command line, the value specified in the command line will be used preferentially.
4.1.Configuration parameters
The parameters and their types are described as follows:
Parameter names |
Instructions |
|
---|---|---|
directory |
string |
Directory where data files are stored. If the directory does not exist, it is automatically created. The default directory is /var/lib/lgraph/data. |
durable |
boolean |
Whether to enable real-time persistence. Turning off persistence can reduce the disk IO overhead when writing, but data may be lost in extreme cases such as machine power failure. The default value is |
host |
string |
The IP address on which the REST server listens. The default address is 0.0.0.0. Note: In HA mode, the host needs to be set to the IP address of the corresponding server and cannot be set to 0.0.0.0. |
port |
int |
The Port on which the REST server listens. The default port is 7070. |
enable_rpc |
boolean |
Whether to use RPC services. The default value is false. |
rpc_port |
int |
Port used by RPC and HA services. The default port number is 9090. |
bolt_port |
int |
Port used by Bolt Client. The default port number is 7687. |
enable_ha |
boolean |
Whether to enable the HA mode. The default value is false. |
ha_log_dir |
string |
HA log directory. The HA mode needs to be enabled. The default value is null. |
verbose |
int |
Detail level of log output information. The value can be 0,1,2. The larger the value, the more detailed the output information. The default value is 1. |
log_dir |
string |
Directory where log files are stored. The default directory is /var/log/lgraph/. |
ssl_auth |
boolean |
Whether to use SSL authentication. When HTTPS is enabled, only the HTTPS service is enabled on the REST server. The default value is false. |
web |
string |
The storage location for web files (including visualization components) is set by default in the directory /usr/local/share/lgraph/browser-resource. For previous older versions, this directory was situated at /usr/local/share/lgraph/resource . |
server_cert |
string |
certificate file path used by the server when SSL authentication is enabled. The default path is/usr/local/etc/lgraph/server - cert.pem. |
server_key |
string |
The public key file used by the server when SSL authentication is enabled. The default directory is/usr/local/etc/lgraph/server - key.pem。 |
enable_audit_log |
boolean |
Whether to enable audit logs. The default value is false. |
audit_log_expire |
int |
When audit logs are enabled, the validity period (hours) of audit logs is automatically cleared upon timeout. If the value is 0, the logs are not cleared. The default value is 0. |
audit_log_dir |
string |
Specifies the directory for storing log files when audit logs are enabled. The default directory is $directory/audit_log. |
load_plugins |
boolean |
Import all stored procedures when starting the service. The default value is true. |
optimistic_txn |
boolean |
Enable optimistic multithreaded write transactions for Cypher. The default is false. |
disable_auth |
boolean |
Disable REST authentication. The default is false. |
ha_snapshot_interval_s |
int |
Snapshot interval (in seconds). The default value is 604800. -1 means not to automatically generate snapshots. |
ha_heartbeat_interval_ms |
int |
Heartbeat interval in milliseconds. The default value is 1000. |
ha_node_offline_ms |
int |
The heartbeat times out and the interval (in milliseconds) between nodes going offline. The default value is 60000. |
ha_node_remove_ms |
int |
The interval (in milliseconds) at which a node is considered completely dead and removed from the list. The default value is 120000. |
ha_first_snapshot_start_time |
string |
The time when the first snapshot is taken, the format is “HH:MM:SS”, which means the first snapshot is taken at the next HH:MM:SS time point, and then every ha_snapshot_interval_s seconds. The default value is “”, which means that the first snapshot is taken randomly at any time within 0-ha_snapshot_interval_s, and then a snapshot is taken every ha_snapshot_interval_s seconds. |
enable_ip_check |
boolean |
Allow IP address whitelists. The default value is false。 |
idle_seconds |
int |
The maximum number of seconds a child process can be idle. The default value is 600. |
enable_backup_log |
boolean |
Whether to enable backup logging. The default value is false. |
backup_log_dir |
string |
The directory where backup files are stored. The default value is null. |
snapshot_dir |
string |
Directory where snapshot files are stored. The default value is null. |
thread_limit |
int |
The maximum number of threads that can be used simultaneously. The default value is 0, which means that no restriction is imposed. The license file prevails. |
unlimited_token |
boolean |
Whether to set the link token to be infinite. The default value is false and the validity period is 24 hours. |
reset_admin_password |
boolean |
Whether to reset the password. The default value is false. When the value is true, the password will be reset to “73@TuGraph”。 |
enable_fulltext_index |
boolean |
Whether to enable the full-text index function, the default value is false. |
fulltext_analyzer |
string |
Full-text index tokenizer type. Can be set to |
fulltext_commit_interval |
int |
Full-text index data submission period, for write operations, in seconds. The default is 0, which commits immediately. |
fulltext_refresh_interval |
int |
Full-text index data refresh cycle, for read operations, in seconds. The default is 0, and the latest written data can be read immediately. |
ha_conf |
string |
Initialize the HA cluster according to host1:port1,host2:port2,host3:port3, the default value is empty. |
ha_node_join_group_s |
int |
The waiting time for a node to try to join the high availability cluster, in seconds, the default is 10. |
ha_bootstrap_role |
int |
Whether to use bootstrap to start, and the server role to start using this method, 0 means not to use bootstrap to start, 1 means to use bootstrap to start and this node is a leader, 2 means to use bootstrap to start and this node is a follower, only these 3 options. The default value is 0. |
help |
boolean |
Print the help message. The default value is false. |
browser.credential_timeout |
int |
Browser cache expiration time for usernames and passwords. |
browser.retain_connection_credentials |
boolean |
whether the browser caches usernames and passwords.. |
4.2.Server configuration file
TuGraph’s configuration file is stored in JSON format. It is recommended that most configuration be stored in configuration files and that some configuration parameters be modified only temporarily using command-line options when needed.
A typical configuration file looks like this:
{
"directory" : "/var/lib/lgraph/data",
"host" : "0.0.0.0",
"port" : 7070,
"rpc_port" : 9090,
"enable_rpc" : true,
"bolt_port": 7687,
"enable_ha" : false,
"verbose" : 1,
"log_dir" : "/var/log/lgraph_log",
"disable_auth" : false,
"ssl_auth" : false,
"server_key" : "/usr/local/etc/lgraph/server-key.pem",
"server_cert" : "/usr/local/etc/lgraph/server-cert.pem",
"web" : "/usr/local/share/lgraph/browser-resource"
}