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.
Start the command:
$ ./lgraph_server -c lgraph_standalone.json --log_dir ""
Example of running output in normal mode:
20200508120723.039: **********************************************************************
20200508120723.039: * TuGraph Graph Database v3.1.0 *
20200508120723.040: * *
20200508120723.041: * Copyright(C) 2018 Ant Group. All rights reserved. *
20200508120723.041: * *
20200508120723.044: * Licensed host: hostname threads:0, ha:0 *
20200508120723.044: **********************************************************************
20200508120723.044: Server is configured with the following parameters:
20200508120723.045: data directory: ./lgraph_db
20200508120723.045: license: ./fma.lic
20200508120723.046: enable ha: 0
20200508120723.046: async: 0
20200508120723.047: host: 127.0.0.1
20200508120723.047: REST port: 7071
20200508120723.048: RPC port: 9091
20200508120723.048: enable rpc: 0
20200508120723.051: optimistic txn: 0
20200508120723.059: verbose: 1
20200508120723.074: log_dir:
20200508120723.074: ssl_auth: 0
20200508120723.075: resource dir: ./resource
20200508120723.077: Loading DB state from disk
20200508120723.110: [RestServer] Listening for REST on port 7090
20200508120723.110: [LGraphService] 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_daemon.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_daemon.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_daemon.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_daemon.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_standalone.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_standalone.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.
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. |
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 0. |
rpc_port |
int |
Port used by RPC and HA services. The default port number is 9090. |
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 directory where the web files (including the visual part) are located. The default directory is/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 1. |
optimistic_txn |
boolean |
Enable optimistic multithreaded write transactions for Cypher. The default is 0. |
disable_auth |
boolean |
Disable REST authentication. The default is 0. |
ha_snapshot_interval_s |
int |
Snapshot interval (in seconds) The default value is 86400. |
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. |
enable_ip_check |
boolean |
Allow IP address whitelists. The default value is 0。 |
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 0. |
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 0 and the validity period is 24 hours. |
enable_fulltext_index |
boolean |
Whether to enable the full-text index function, the default value is 0. |
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. |
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 0. |
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",
"license": "/var/lib/lgraph/fma.lic",
"port": 7090,
"rpc_port": 9090,
"enable_ha": false,
"verbose": 1,
"log_dir": "/var/log/lgraph/",
"ssl_auth": false,
"server_key": "/usr/local/etc/lgraph/server-key.pem",
"server_cert": "/usr/local/etc/lgraph/server-cert.pem"
}