### Start Agent service with example values Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/backup-and-restore/nebula-br/2.compile-br.md Example command for starting the Agent service with specific IP addresses and a rate limit. ```bash sudo nohup ./agent --agent="192.168.8.129:8888" --meta="192.168.8.129:9559" --ratelimit=1048576 > nebula_agent.log 2>&1 & ``` -------------------------------- ### Start Listener Service Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/6.deploy-text-based-index/3.deploy-listener.md Execute this command in the installation path of the cluster to start the Listener service. Ensure the configuration file path is correct. ```bash ./bin/nebula-storaged --flagfile etc/nebula-storaged-listener.conf ``` -------------------------------- ### Install NebulaGraph Studio with RPM Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/nebula-studio/deploy-connect/st-ug-deploy.md Install Studio using the RPM package. Specify a custom installation path using the --prefix option if needed. The service starts automatically after installation. ```bash $ sudo rpm -i nebula-graph-studio-{{studio.release}}.x86_64.rpm ``` ```bash $ sudo rpm -i nebula-graph-studio-{{studio.release}}.x86_64.rpm --prefix= ``` -------------------------------- ### Create user and show users example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/7.data-security/1.authentication/2.management-user.md Demonstrates the creation of a user and then lists all users to verify the creation. This is a common workflow for initial user setup. ```ngql CREATE USER user1 WITH PASSWORD 'nebula'; SHOW USERS; ``` -------------------------------- ### Compile C++ Client Example (with default paths) Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/14.client/3.nebula-cpp-client.md Compile a C++ client file using default installation paths for libraries and include files. ```bash $LIBRARY_PATH=/usr/local/nebula/lib64:$LIBRARY_PATH g++ -std=c++11 SessionExample.cpp -I/usr/local/nebula/include -lnebula_graph_client -o session_example ``` -------------------------------- ### Example Pod Status Output Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/k8s-operator/4.cluster-administration/4.1.installation/4.1.1.cluster-install.md This is an example output showing the status of NebulaGraph cluster pods after installation. It indicates whether each pod is running. ```text NAME READY STATUS RESTARTS AGE nebula-exporter-854c76989c-mp725 1/1 Running 0 14h nebula-graphd-0 1/1 Running 0 14h nebula-graphd-1 1/1 Running 0 14h nebula-metad-0 1/1 Running 0 14h nebula-metad-1 1/1 Running 0 14h nebula-metad-2 1/1 Running 0 14h nebula-storaged-0 1/1 Running 0 14h nebula-storaged-1 1/1 Running 0 14h nebula-storaged-2 1/1 Running 0 14h ``` -------------------------------- ### Install AutoFDO Tool Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/8.service-tuning/enable_autofdo_for_nebulagraph.md Install the AutoFDO tool using apt-get. Alternatively, you can compile it from source. ```bash sudo apt-get update sudo apt-get install -y autofdo ``` -------------------------------- ### Client Configuration Example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/use-importer.md Defines client connection parameters, including NebulaGraph server address, user credentials, and SSL settings. Ensure these match your NebulaGraph cluster setup. ```yaml client: version: v3 address: "192.168.1.100:9669,192.168.1.101:9669" user: root password: nebula ssl: enable: true certPath: "/home/xxx/cert/importer.crt" keyPath: "/home/xxx/cert/importer.key" caPath: "/home/xxx/cert/root.crt" insecureSkipVerify: false concurrencyPerAddress: 10 reconnectInitialInterval: 1s retry: 3 retryInitialInterval: 1s ``` -------------------------------- ### Install NebulaGraph CPP Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/14.client/3.nebula-cpp-client.md Install the compiled NebulaGraph CPP client to the system. ```bash sudo make install ``` -------------------------------- ### Start All NebulaGraph Services Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/reuse/source_manage-service.md Run this command to start all NebulaGraph services (metad, graphd, and storaged). Ensure you have the necessary permissions. ```bash $ sudo /usr/local/nebula/scripts/nebula.service start all [INFO] Starting nebula-metad... [INFO] Done [INFO] Starting nebula-graphd... [INFO] Done [INFO] Starting nebula-storaged... [INFO] Done ``` -------------------------------- ### Example Spark Submit Command for Parquet Import Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/nebula-exchange/use-exchange/ex-ug-import-from-parquet.md An example of the spark-submit command with specific paths for the Nebula-Exchange JAR and configuration file. ```bash ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange_spark_2.4-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/parquet_application.conf ``` -------------------------------- ### Install logrotate on Debian/Ubuntu Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/5.configurations-and-logs/2.log-management/logs.md Install the logrotate package using apt-get. ```bash sudo apt-get install logrotate ``` -------------------------------- ### Start All NebulaGraph Services Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/reuse/source_manage-service.md Execute this command to start all NebulaGraph services (metad, graphd, and storaged). ```bash sudo /usr/local/nebula/scripts/nebula.service start all [INFO] Starting nebula-metad... [INFO] Done [INFO] Starting nebula-graphd... [INFO] Done [INFO] Starting nebula-storaged... [INFO] Done ``` -------------------------------- ### Install NebulaGraph Python from source Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/14.client/5.nebula-python-client.md Install the NebulaGraph Python client after cloning the source code. Ensure you are in the cloned directory. ```bash cd nebula-python pip install . ``` -------------------------------- ### Start NebulaGraph Services Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md Use this command to start NebulaGraph services. You can start individual services like metad, graphd, storaged, or all services at once. Ensure all required processes are running on each machine before starting NebulaGraph. ```bash sudo /usr/local/nebula/scripts/nebula.service start ``` -------------------------------- ### Example Output of Updated Values Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/k8s-operator/3.operator-management/3.2.update-operator.md Example output showing the user-supplied values after an update, confirming changes like enabling the AdmissionWebhook. ```yaml USER-SUPPLIED VALUES: admissionWebhook: create: true ``` -------------------------------- ### Install NebulaGraph Binaries and Libraries Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md Install the compiled NebulaGraph executables and libraries to the specified host directory '/usr/local/nebula' after a successful compilation. ```docker make install ``` -------------------------------- ### Example Spark Submit Command Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/nebula-exchange/use-exchange/ex-ug-import-from-clickhouse.md An example of the spark-submit command with specific paths for the Nebula Exchange JAR and ClickHouse configuration file. ```bash ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange_spark_2.4-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/clickhouse_application.conf ``` -------------------------------- ### Install or Update NebulaGraph Go Client Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/14.client/6.nebula-go-client.md Run this command to install or update the NebulaGraph Go client to the specified release version. ```bash $ go get -u -v github.com/vesoft-inc/nebula-go/v3@v{{go.release}} ``` -------------------------------- ### Example Nebula-Exchange Import Command Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/nebula-exchange/use-exchange/ex-ug-import-from-hive.md An example of the spark-submit command for Nebula-Exchange, specifying the JAR file and configuration file for Hive import. ```bash ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange_spark_2.4-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/hive_application.conf -h ``` -------------------------------- ### Example Connection Command Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/k8s-operator/2.get-started/2.4.connect-to-cluster.md An example of the connection command using specific IP, port, username, and password. This demonstrates how to use the parameters defined in the previous steps. ```bash kubectl run -ti --image vesoft/nebula-console:{{console.tag}} --restart=Never -- nebula-console -addr 192.168.8.160 -port 9769 -u root -p vesoft ``` -------------------------------- ### Example of decompressing NebulaGraph Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md An example of decompressing the NebulaGraph tar.gz file to a specific installation directory. Replace `{{nebula.release}}` with the actual release version. ```bash tar -xvzf nebula-graph-{{nebula.release}}.el7.x86_64.tar.gz -C /home/joe/nebula/install ``` -------------------------------- ### Example: Creating Tags, Inserting Vertex, Fetching, and Deleting Tags Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/10.tag-statements/6.delete-tag.md This comprehensive example demonstrates the lifecycle of tags on a vertex. It includes creating two tags, inserting a vertex with both tags, fetching the vertex to show its current state, deleting one tag, fetching again to show the change, deleting all remaining tags, and finally fetching to confirm the vertex has no tags. ```ngql nebula> CREATE TAG IF NOT EXISTS test1(p1 string, p2 int); nebula> CREATE TAG IF NOT EXISTS test2(p3 string, p4 int); nebula> INSERT VERTEX test1(p1, p2),test2(p3, p4) VALUES "test":("123", 1, "456", 2); nebula> FETCH PROP ON * "test" YIELD vertex AS v; +------------------------------------------------------------+ | v | +------------------------------------------------------------+ | ("test" :test1{p1: "123", p2: 1} :test2{p3: "456", p4: 2}) | +------------------------------------------------------------+ nebula> DELETE TAG test1 FROM "test"; nebula> FETCH PROP ON * "test" YIELD vertex AS v; +-----------------------------------+ | v | +-----------------------------------+ | ("test" :test2{p3: "456", p4: 2}) | +-----------------------------------+ nebula> DELETE TAG * FROM "test"; nebula> FETCH PROP ON * "test" YIELD vertex AS v; +---+ | v | +---+ +---+ ``` -------------------------------- ### Example of SKIP Clause Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/limit.md This example shows how to use the SKIP clause to set an offset and return data starting after a specified position, ordered in descending order. ```ngql nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ RETURN v2.player.name AS Name, v2.player.age AS Age \ ORDER BY Age DESC SKIP 1; +-----------------+-----+ | Name | Age | +-----------------+-----+ | "Manu Ginobili" | 41 | | "Tony Parker" | 36 | +-----------------+ ``` -------------------------------- ### Get specific configuration for the STORAGE service Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/18.operation-and-maintenance-statements/.1.configs-syntax.md Use GET CONFIGS with a service and configuration name to retrieve a specific setting. This example shows the 'wal_ttl' configuration for the STORAGE service. ```ngql nebula> GET CONFIGS STORAGE:wal_ttl; +-----------+-----------+-------+-----------+-------+ | module | name | type | mode | value | +-----------+-----------+-------+-----------+-------+ | "STORAGE" | "wal_ttl" | "int" | "MUTABLE" | 14400 | +-----------+-----------+-------+-----------+-------+ ``` -------------------------------- ### Example: Run NebulaGraph Importer in Docker Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/use-importer.md An example command to run the NebulaGraph Importer in Docker, demonstrating the usage of volume mounts for configuration and data files. ```bash docker pull vesoft/nebula-importer:v4 docker run --rm -ti \ --network=host \ -v /home/user/config.yaml:/home/user/config.yaml \ -v /home/user/data:/home/user/data \ vesoft/nebula-importer:v4 \ --config /home/user/config.yaml ``` -------------------------------- ### Start Meta Services Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-comm.md Start all Meta services after replacing binaries. Meta services require a few seconds to elect a leader. Verify their status using `SHOW HOSTS meta` and `SHOW META LEADER`. ```bash /scripts/nebula-metad.service start ``` -------------------------------- ### Example of SKIP and LIMIT Together Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/limit.md This example illustrates using both SKIP and LIMIT clauses together to retrieve a specific number of results starting from a defined offset, ordered in descending order. ```ngql nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ RETURN v2.player.name AS Name, v2.player.age AS Age \ ORDER BY Age DESC SKIP 1 LIMIT 1; +-----------------+-----+ | Name | Age | +-----------------+-----+ | "Manu Ginobili" | 41 | +-----------------+ ``` -------------------------------- ### Get configuration by name across services Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/18.operation-and-maintenance-statements/.1.configs-syntax.md Use GET CONFIGS with only a configuration name to retrieve all instances of that configuration across different services. This example fetches 'heartbeat_interval_secs' for both GRAPH and STORAGE services. ```ngql nebula> GET CONFIGS heartbeat_interval_secs; +-----------+---------------------------+-------+-----------+-------+ | module | name | type | mode | value | +-----------+---------------------------+-------+-----------+-------+ | "GRAPH" | "heartbeat_interval_secs" | "int" | "MUTABLE" | 3 | +-----------+---------------------------+-------+-----------+-------+ | "STORAGE" | "heartbeat_interval_secs" | "int" | "MUTABLE" | 3 | +-----------+---------------------------+-------+-----------+-------+ ``` -------------------------------- ### Get Start Node of a Path using startNode() Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/6.functions-and-expressions/4.schema.md The `startNode()` function extracts the source vertex information from a path. It returns the vertex ID, tags, and properties of the starting node in a path traversal. ```ngql MATCH p = (a :player {name : "Tim Duncan"})-[r:serve]-(t) RETURN startNode(p); ``` -------------------------------- ### Example Connection to NebulaGraph Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/k8s-operator/2.get-started/2.4.connect-to-cluster.md An example demonstrating how to use the kubectl run command to connect to NebulaGraph with specific node IP, port, username, and password. ```bash kubectl run -ti --image vesoft/nebula-console:{{console.tag}} --restart=Never -- nebula-console -addr 192.168.8.24 -port 32236 -u root -p vesoft If you don't see a command prompt, try pressing enter. (root@nebula) [(none)]> ``` -------------------------------- ### Start NebulaGraph Studio Service Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/nebula-studio/deploy-connect/st-ug-deploy.md Navigate to the extracted NebulaGraph Studio directory and execute the `./server` script to start the service. Studio will then be accessible via `http://:7001`. ```bash cd nebula-graph-studio ./server ``` -------------------------------- ### Get NebulaGraph Version (DEB) Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/4.uninstall-nebula-graph.md Retrieve the installed NebulaGraph version using dpkg command for uninstallation. ```bash $ dpkg -l | grep "nebula" ``` -------------------------------- ### Example: Downloading SST File from HDFS Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/nebula-exchange/use-exchange/ex-ug-import-from-sst.md An example of the `SUBMIT JOB DOWNLOAD` command, specifying the HDFS path where the SST files are located. ```ngql nebula> SUBMIT JOB DOWNLOAD HDFS "hdfs://*.*.*.*:9000/sst"; ``` -------------------------------- ### Get NebulaGraph Version (RPM) Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/4.uninstall-nebula-graph.md Retrieve the installed NebulaGraph version using rpm command for uninstallation. ```bash $ rpm -qa | grep "nebula" ``` -------------------------------- ### Prefix and Suffix Matching with STARTS WITH and ENDS WITH Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/5.operators/7.string.md STARTS WITH checks if a string begins with a specified prefix, while ENDS WITH checks if it ends with a specified suffix. These operations are case-sensitive. The examples demonstrate basic usage and case sensitivity. ```ngql nebula> RETURN 'apple' STARTS WITH 'app', 'apple' STARTS WITH 'a', 'apple' STARTS WITH toUpper('a'); +-----------------------------+---------------------------+------------------------------------+ | ("apple" STARTS WITH "app") | ("apple" STARTS WITH "a") | ("apple" STARTS WITH toUpper("a")) | +-----------------------------+---------------------------+------------------------------------+ | true | true | false | +-----------------------------+---------------------------+------------------------------------+ ``` ```ngql nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app'; +---------------------------+---------------------------------+ | ("apple" STARTS WITH "b") | ("apple" NOT STARTS WITH "app") | +---------------------------+---------------------------------+ | false | false | +---------------------------+---------------------------------+ ``` -------------------------------- ### Using INNER JOIN with LOOKUP, GO, and FIND PATH Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/joins.md This example demonstrates a multi-step data retrieval process using LOOKUP, GO, FIND ALL PATH, and FIND SHORTEST PATH, followed by an INNER JOIN to combine the results. It showcases how to join path data based on common nodes. ```ngql nebula> $a = LOOKUP ON player WHERE player.name == 'Tony Parker' YIELD id(vertex) as src, vertex AS v; $b = GO 2 TO 5 STEPS FROM $a.src OVER follow WHERE $$.player.age > 30 YIELD id($$) AS dst; $c = (FIND ALL PATH FROM $a.src TO $b.dst OVER follow YIELD path AS p | YIELD $-.p AS forward, id(endNode($-.p)) AS dst); $d = (FIND SHORTEST PATH FROM $c.dst TO $a.src OVER follow YIELD path AS p | YIELD $-.p AS p, id(startNode($-.p)) AS src); YIELD $c.forward AS forwardPath, $c.dst AS end, $d.p AS backwordPath FROM $c INNER JOIN $d ON $c.dst == $d.src; ``` -------------------------------- ### GET SUBGRAPH Exploration Query Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md Extract a portion of the graph within a specified number of steps from a starting vertex using the GET SUBGRAPH statement. The YIELD clause is mandatory for specifying the returned vertices and edges. ```ngql GET SUBGRAPH 5 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; ``` -------------------------------- ### Get Subgraph with 0-1 Steps and Incoming 'follow' Edges Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/7.get-subgraph.md This query retrieves a subgraph starting from 'player101', traversing 0 to 1 steps, considering only incoming 'follow' edges. It returns only the starting vertex as 'player101' has no incoming 'follow' edges. ```ngql nebula> GET SUBGRAPH 1 STEPS FROM "player101" IN follow YIELD VERTICES AS nodes, EDGES AS relationships; ``` -------------------------------- ### Compile C++ Client Example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/14.client/3.nebula-cpp-client.md Compile a C++ client file into an executable. Ensure LIBRARY_PATH and include paths are correctly set. ```bash $LIBRARY_PATH=:$LIBRARY_PATH g++ -std=c++11 SessionExample.cpp -I -lnebula_graph_client -o session_example ``` -------------------------------- ### Serve Edge Data Example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/nebula-exchange/use-exchange/ex-ug-import-from-json.md Sample JSON data for serve edges, connecting players to teams with start and end years. ```json {"src":"player100","dst":"team204","start_year":"1997","end_year":"2016"} {"src":"player101","dst":"team204","start_year":"1999","end_year":"2018"} ... ``` -------------------------------- ### Using SAMPLE with GO 3 STEPS Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/sample.md This example demonstrates how to use the SAMPLE clause with a GO statement that traverses exactly 3 steps. The sample list [1,2,3] specifies the number of edges to select at each step. ```ngql nebula> GO 3 STEPS FROM "player100" \ OVER * \ YIELD properties($$).name AS NAME, properties($$).age AS Age \ SAMPLE [1,2,3]; +-----------------+----------+ | NAME | Age | +-----------------+----------+ | "Tony Parker" | 36 | | "Manu Ginobili" | 41 | | "Spurs" | __NULL__ | +-----------------+ ``` -------------------------------- ### range() function example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/6.functions-and-expressions/6.list.md Generates a list of numbers within a specified range and step. The index position in nGQL starts from 1. ```ngql nebula> RETURN range(1,9,2); +-----------------+ | range(1,9,2) | +-----------------+ | [1, 3, 5, 7, 9] | +-----------------+ ``` -------------------------------- ### Using SAMPLE with GO 1 TO 3 STEPS Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/sample.md This example shows the usage of the SAMPLE clause with a GO statement that traverses from 1 to 3 steps. The sample list [2,2,2] dictates the number of edges to sample at each of the three potential steps. ```ngql nebula> GO 1 TO 3 STEPS FROM "player100" \ OVER * \ YIELD properties($$).name AS NAME, properties($$).age AS Age \ SAMPLE [2,2,2]; +-----------------+----------+ | NAME | Age | +-----------------+ | "Manu Ginobili" | 41 | | "Spurs" | __NULL__ | | "Tim Duncan" | 42 | | "Spurs" | __NULL__ | | "Manu Ginobili" | 41 | | "Spurs" | __NULL__ | +-----------------+ ``` -------------------------------- ### Example: Collecting and Showing Graph Space Statistics Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md This example demonstrates the workflow of collecting graph space statistics using SUBMIT JOB STATS and then displaying them with SHOW STATS. Ensure the SUBMIT JOB STATS job completes successfully before running SHOW STATS. ```ngql # Choose a graph space. nebula> USE basketballplayer; # Start SUBMIT JOB STATS. nebula> SUBMIT JOB STATS; +------------+ | New Job Id | +------------+ | 98 | +------------+ # Make sure the job executes successfully. nebula> SHOW JOB 98; +----------------+---------------+------------+----------------------------+----------------------------+-------------+ | Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | Error Code | +----------------+---------------+------------+----------------------------+----------------------------+-------------+ | 98 | "STATS" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | "SUCCEEDED" | | 0 | "storaged2" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | "SUCCEEDED" | | 1 | "storaged0" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | "SUCCEEDED" | | 2 | "storaged1" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | "SUCCEEDED" | | "Total:3" | "Succeeded:3" | "Failed:0" | "In Progress:0" | "" | "" | +----------------+---------------+------------+----------------------------+----------------------------+-------------+ # Show the statistics of the graph space. nebula> SHOW STATS; +---------+------------+-------+ | Type | Name | Count | +---------+------------+-------+ | "Tag" | "player" | 51 | | "Tag" | "team" | 30 | | "Edge" | "follow" | 81 | | "Edge" | "serve" | 152 | | "Space" | "vertices" | 81 | | "Space" | "edges" | 233 | +---------+------------+-------+ ``` -------------------------------- ### Get Subgraph Statement in nGQL Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/2.quick-start/6.cheatsheet-for-ngql.md Retrieves vertices and edges within a specified subgraph. Use this to explore connected data from a starting set of vertices. ```nGQL GET SUBGRAPH 1 STEPS FROM "player100" YIELD VERTICES AS nodes, EDGES AS relationships ``` -------------------------------- ### Example: Inspecting a NebulaGraph core dump Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/20.appendix/0.FAQ.md This example demonstrates the typical output when inspecting a NebulaGraph core dump using 'file' and 'gdb'. It shows how to identify the core file details and view the backtrace. ```bash $ file core.1316027 core.1316027: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), SVR4-style, from '/home/workspace/fork/nebula-debug/bin/nebula-metad --flagfile /home/k', real uid: 1008, effective uid: 1008, real gid: 1008, effective gid: 1008, execfn: '/home/workspace/fork/nebula-debug/bin/nebula-metad', platform: 'x86_64' $ gdb /home/workspace/fork/nebula-debug/bin/nebula-metad core.1316027 $(gdb) bt #0 0x00007f9de58fecf5 in __memcpy_ssse3_back () from /lib64/libc.so.6 #1 0x0000000000eb2299 in void std::__cxx11::basic_string, std::allocator >::_M_construct(char*, char*, std::forward_iterator_tag) () #2 0x0000000000ef71a7 in nebula::meta::cpp2::QueryDesc::QueryDesc(nebula::meta::cpp2::QueryDesc const&) () ... ``` -------------------------------- ### Submit Stats Job Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/4.job-statements.md Starts a job to generate statistics for the current graph space. If data changes, this job must be run again to get the latest statistics. ```ngql nebula> SUBMIT JOB STATS; +------------+ | New Job Id | +------------+ | 9 | +------------+ ``` -------------------------------- ### Dashboard Configuration Example Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/nebula-dashboard/2.deploy-dashboard.md Configure the `config.yaml` file with details for dependent services like the HTTP gateway, stats exporter, node exporter, and Prometheus, as well as cluster information for NebulaGraph. ```yaml port: 7003 # Web 服务端口。 gateway: ip: hostIP # 部署 Dashboard 的机器 IP。 port: 8090 https: false # 是否为 HTTPS 端口。 runmode: dev # 程序运行模式,包括 dev、test、prod。一般用于区分不同运行环境。 stats-exporter: ip: hostIP # 部署 Dashboard 的机器 IP。 nebulaPort: 9200 https: false # 是否为 HTTPS 端口。 node-exporter: - ip: nebulaHostIP_1 # 部署 {{nebula.name}} 的机器 IP。 port: 9100 https: false # 是否为 HTTPS 端口。 # - ip: nebulaHostIP_2 # port: 9100 # https: false prometheus: ip: hostIP # 部署 Dashboard 的机器 IP。 prometheusPort: 9090 https: false # 是否为 HTTPS 端口。 scrape_interval: 5s # 收集监控数据的间隔时间。默认为 1 分钟。 evaluation_interval: 5s # 告警规则扫描时间间隔。默认为 1 分钟。 # 集群节点信息 nebula-cluster: name: 'default' # 集群名称 metad: - name: metad0 endpointIP: nebulaMetadIP # 部署 Meta 服务的机器 IP。 port: 9559 endpointPort: 19559 # - name: metad1 # endpointIP: nebulaMetadIP # port: 9559 # endpointPort: 19559 graphd: - name: graphd0 endpointIP: GraphdIP # 部署 Graph 服务的机器 IP。 port: 9669 endpointPort: 19669 # - name: graphd1 # endpointIP: GraphdIP # port: 9669 # endpointPort: 19669 storaged: - name: storaged0 endpointIP: StoragedIP # 部署 Storage 服务的机器 IP。 port: 9779 endpointPort: 19779 # - name: storaged1 # endpointIP: StoragedIP # port: 9779 # endpointPort: 19779 ``` -------------------------------- ### Create and Return a List Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/3.data-types/6.list.md Demonstrates how to create a list literal and return it. ```ngql nebula> RETURN list[1, 2, 3] AS a; +-----------+ | a | +-----------+ | [1, 2, 3] | +-----------+ ``` -------------------------------- ### Using `all()` with node properties in a path Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/6.functions-and-expressions/8.predicate.md Checks if all nodes in a matched path satisfy a condition using the `all()` function. This example verifies that no player name in the path starts with 'D'. ```ngql nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) RETURN nodes(p)[0].player.name AS n1, nodes(p)[1].player.name AS n2, all(n IN nodes(p) WHERE n.player.name NOT STARTS WITH "D") AS b; +----------------+-------------------+-------+ | n1 | n2 | b | +----------------+-------------------+-------+ | "LeBron James" | "Danny Green" | false | | "LeBron James" | "Dejounte Murray" | false | | "LeBron James" | "Chris Paul" | true | | "LeBron James" | "Kyrie Irving" | true | | "LeBron James" | "Carmelo Anthony" | true | | "LeBron James" | "Dwyane Wade" | false | +----------------+-------------------+-------+ ``` -------------------------------- ### Example: Create 'basketballplayer' Graph Space Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/2.quick-start/4.nebula-graph-crud.md This example demonstrates creating a graph space named 'basketballplayer' with specific configurations for partition number, replica factor, and vertex ID type. ```ngql nebula> CREATE SPACE basketballplayer(partition_num=15, replica_factor=1, vid_type=fixed_string(30)); ``` -------------------------------- ### Get Source Vertex ID using src() Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/6.functions-and-expressions/4.schema.md The `src()` function returns the ID of the source vertex of an edge. This is essential for traversing relationships from a specific starting point. ```ngql MATCH ()-[e]->(v:player{name:"Tim Duncan"}) RETURN src(e); ``` -------------------------------- ### FETCH with GO statement Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/4.fetch.md Use FETCH to retrieve properties of edges identified by a preceding GO statement. The example fetches the 'degree' property of 'follow' edges starting from 'player101'. ```ngql # 返回从点 player101 开始的 follow 边的 degree 值。src(edge) 获取边的起始点 ID,dst(edge) 获取边的目的点 ID。 nebula> GO FROM "player101" OVER follow \ YIELD src(edge) AS s, dst(edge) AS d \ | FETCH PROP ON follow $-.s -> $-.d \ YIELD properties(edge).degree; +-------------------------+ | properties(EDGE).degree | +-------------------------+ | 95 | | 90 | | 95 | +-------------------------+ ``` -------------------------------- ### Get Subgraph with Edge Properties Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/7.get-subgraph.md Retrieves a subgraph starting from a specified vertex, traversing a given number of steps and edge types, and yields vertices and edges along with their properties. ```ngql nebula> GET SUBGRAPH WITH PROP 1 STEPS FROM "player101" OUT serve YIELD VERTICES AS nodes, EDGES AS relationships; +-------------------------------------------------------+-------------------------------------------------------------------------+ | nodes | relationships | +-------------------------------------------------------+-------------------------------------------------------------------------+ | [("player101" :player{age: 36, name: "Tony Parker"})] | [[:serve "player101"->"team204" @0 {end_year: 2018, start_year: 1999}]] | | [("team204" :team{name: "Spurs"})] | [] | +-------------------------------------------------------+-------------------------------------------------------------------------+ ``` -------------------------------- ### Run NebulaGraph Importer with Binary Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/use-importer.md Execute the downloaded binary file to start the data import process. Ensure the configuration file path is correctly specified. ```bash ./ --config ``` -------------------------------- ### Nebula Graph Schema Setup Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/7.get-subgraph.md These commands set up a Nebula Graph space, tags, and edges for demonstrating the GET SUBGRAPH statement. Ensure the space is created and selected before proceeding. ```ngql nebula> CREATE SPACE IF NOT EXISTS subgraph(partition_num=15, replica_factor=1, vid_type=fixed_string(30)); ``` ```ngql nebula> USE subgraph; ``` ```ngql nebula> CREATE TAG IF NOT EXISTS player(name string, age int); ``` ```ngql nebula> CREATE TAG IF NOT EXISTS team(name string); ``` ```ngql nebula> CREATE EDGE IF NOT EXISTS follow(degree int); ``` ```ngql nebula> CREATE EDGE IF NOT EXISTS serve(start_year int, end_year int); ``` ```ngql nebula> INSERT VERTEX player(name, age) VALUES "player100":("Tim Duncan", 42); ``` ```ngql nebula> INSERT VERTEX player(name, age) VALUES "player101":("Tony Parker", 36); ``` ```ngql nebula> INSERT VERTEX player(name, age) VALUES "player102":("LaMarcus Aldridge", 33); ``` ```ngql nebula> INSERT VERTEX team(name) VALUES "team203":("Trail Blazers"), "team204":("Spurs"); ``` ```ngql nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player100":(95); ``` ```ngql nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player102":(90); ``` ```ngql nebula> INSERT EDGE follow(degree) VALUES "player102" -> "player100":(75); ``` ```ngql nebula> INSERT EDGE serve(start_year, end_year) VALUES "player101" -> "team204":(1999, 2018),"player102" -> "team203":(2006, 2015); ``` -------------------------------- ### 通过 nebula-console Pod 连接数据库 Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/k8s-operator/2.get-started/2.4.connect-to-cluster.md 如果 `spec.console` 字段已在集群配置文件中设置,可以先进入 `nebula-console` Pod,然后使用 `nebula-console` 命令连接数据库。 ```bash # 进入 nebula-console Pod。 kubectl exec -it nebula-console -- /bin/sh ``` ```bash # 连接到数据库。 nebula-console -addr nebula-graphd-svc.default.svc.cluster.local -port 9669 -u -p ``` -------------------------------- ### Get All Configuration Information Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/5.configurations-and-logs/1.configurations/1.configurations.md Use the --help flag with the NebulaGraph service binary to retrieve a list of all available configurations and their descriptions. This is the primary method for understanding the configurable parameters of each service. ```bash --help ``` ```bash # Get the help information from Meta $ /usr/local/nebula/bin/nebula-metad --help ``` ```bash # Get the help information from Graph $ /usr/local/nebula/bin/nebula-graphd --help ``` ```bash # Get the help information from Storage $ /usr/local/nebula/bin/nebula-storaged --help ``` -------------------------------- ### Get Subgraph - Specific Incoming Edge Type Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/7.general-query-statements/7.get-subgraph.md Retrieves a subgraph by traversing one step from 'player101' specifically over incoming 'follow' edges. If no such edges exist, only the starting vertex is returned. ```ngql nebula> GET SUBGRAPH 1 STEPS FROM "player101" IN follow YIELD VERTICES AS nodes, EDGES AS relationships; ``` -------------------------------- ### Run NebulaGraph Importer from Source Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/import-export/use-importer.md Start the NebulaGraph Importer service after compiling from source. Specify the path to the configuration file. ```bash ./bin/nebula-importer --config ``` -------------------------------- ### Match Edges with Property Filters Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/2.match.md Filter starting nodes based on their properties and return connected nodes. This example shows how to find players whose names are in a predefined list and return their connections. ```ngql # 匹配 name 属性值存在于 names 列表内的起点,并返回起点和终点的数据。 nebula> WITH ['Tim Duncan', 'Yao Ming'] AS names MATCH (v1:player)-->(v2:player) WHERE v1.player.name in names RETURN v1, v2; +----------------------------------------------------+----------------------------------------------------------+ | v1 | v2 | +----------------------------------------------------+----------------------------------------------------------+ | ("player133" :player{age: 38, name: "Yao Ming"}) | ("player114" :player{age: 39, name: "Tracy McGrady"}) | | ("player133" :player{age: 38, name: "Yao Ming"}) | ("player144" :player{age: 47, name: "Shaquille O'Neal"}) | | ("player100" :player{age: 42, name: "Tim Duncan"}) | ("player101" :player{age: 36, name: "Tony Parker"}) | | ("player100" :player{age: 42, name: "Tim Duncan"}) | ("player125" :player{age: 41, name: "Manu Ginobili"}) | +----------------------------------------------------+----------------------------------------------------------+ ``` -------------------------------- ### 使 Service 生效 Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/k8s-operator/2.get-started/2.4.connect-to-cluster.md 执行 `kubectl create` 命令使 Service 在集群中生效。 ```bash kubectl create -f graphd-clusterip-service.yaml ``` -------------------------------- ### Get Subgraph with 0-1 Steps and All Edge Types Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/7.get-subgraph.md This query retrieves a subgraph starting from 'player101', traversing 0 to 1 steps, considering all edge types, and returns vertices and edges with their properties. ```ngql nebula> GET SUBGRAPH 1 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; ``` -------------------------------- ### UNWIND Clause in MATCH Statement Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/unwind.md Retrieves vertices from a matched path, transforms the list of nodes into unique rows, and then collects them into a list. This example shows how to get all related vertices to a specific player. ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})--(v2) \ WITH nodes(p) AS n \ UNWIND n AS r \ WITH DISTINCT r AS r \ RETURN collect(r); ``` -------------------------------- ### Start NebulaGraph Lite from Command Line Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/4.deployment-and-installation/2.compile-and-install-nebula-graph/8.deploy-nebula-graph-with-lite.md Launch NebulaGraph Lite directly from the command line. This command starts a single-node NebulaGraph service and imports a test dataset, indicated by a success message. ```bash nebulagraph start ``` -------------------------------- ### Return Path Length using length() Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-en/3.ngql-guide/8.clauses-and-options/return.md Demonstrates how to use the length() function within the RETURN clause to get the length of paths found by a MATCH statement. The example returns both the path itself and its calculated length. ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-[*..2]->(v2) RETURN p AS Paths, length(p) AS Length; ``` -------------------------------- ### Get Subgraph with 0-1 Steps and Outgoing 'serve' Edges with Properties Source: https://github.com/vesoft-inc/nebula-docs/blob/master/docs-2.0-zh/3.ngql-guide/7.general-query-statements/7.get-subgraph.md This query retrieves a subgraph starting from 'player101', traversing 0 to 1 steps, considering only outgoing 'serve' edges, and displays the edge properties. ```ngql nebula> GET SUBGRAPH WITH PROP 1 STEPS FROM "player101" OUT serve YIELD VERTICES AS nodes, EDGES AS relationships; ```