### Secure Cluster Example Source: https://rqlite.io/docs/guides/security Provides examples of starting a secure rqlite cluster with TLS enabled for both HTTP and node-to-node communication, and demonstrates how to query the cluster using user credentials. ```APIDOC ## Secure Cluster Example ### Description Demonstrates how to start a secure rqlite cluster with HTTPS and node-to-node encryption, and how to query it using authenticated requests. ### Starting a Node with HTTPS and Node-to-Node Encryption Starts a node with HTTPS enabled, node-to-node encryption, mutual TLS disabled, and a specified authentication configuration file. ```bash rqlited -auth config.json -http-cert server.crt -http-key key.pem \ -node-cert node.crt -node-key node-key.pem ~/node.1 ``` ### Joining a Second Node to the Cluster Brings up a second node on the same host, joins it to the first node, and uses user credentials for authentication. ```bash rqlited -auth config.json -http-addr localhost:4003 -http-cert server.crt \ -http-key key.pem -raft-addr :4004 -join localhost:4002 -join-as bob \ -node-cert node.crt -node-key node-key.pem ~/node.2 ``` ### Querying the Cluster as an Authenticated User Queries the cluster using `curl`, authenticating as the user 'mary' with her password. ```bash curl -G 'https://mary:secret2@localhost:4001/db/query?pretty&timings' \ --data-urlencode 'q=SELECT * FROM foo' ``` ``` -------------------------------- ### Start a Single rqlite Node Source: https://rqlite.io/docs/quick-start Launches a single rqlite node using a pre-built binary. It requires a node ID and a directory for data storage. The node will listen on HTTP port 4001. ```bash $ rqlited -node-id=1 data/ ``` -------------------------------- ### Join rqlite Cluster with User Credentials Source: https://rqlite.io/docs/guides/security Example command to start a second rqlite node and join an existing cluster. It specifies the authentication configuration, HTTPS certificates, and uses user credentials ('bob') for joining. ```bash rqlited -auth config.json -http-addr localhost:4003 -http-cert server.crt \ -http-key key.pem -raft-addr :4004 -join localhost:4002 -join-as bob -node-cert node.crt -node-key node-key.pem ~/node.2 ``` -------------------------------- ### Start rqlite Node with HTTPS and Node-to-Node Encryption Source: https://rqlite.io/docs/guides/security Example command to start a rqlite node with HTTPS enabled, node-to-node encryption, and mutual TLS disabled. It specifies paths to the authentication configuration, HTTPS certificates, and node-to-node certificates. ```bash rqlited -auth config.json -http-cert server.crt -http-key key.pem \ -node-cert node.crt -node-key node-key.pem ~/node.1 ``` -------------------------------- ### Run rqlite with Docker Source: https://rqlite.io/docs/quick-start Starts an rqlite instance using a Docker container. This command maps the default rqlite port (4001) from the container to the host machine. ```bash docker run -p 4001:4001 rqlite/rqlite ``` -------------------------------- ### Install rqlite on macOS Source: https://rqlite.io/docs/quick-start Installs the rqlite command-line tool on macOS using the Homebrew package manager. This is a convenient way to get started on macOS systems. ```bash brew install rqlite ``` -------------------------------- ### rqlite User Permissions Configuration Example Source: https://rqlite.io/docs/guides/security An example JSON configuration file for setting up user-level permissions in rqlite. This file defines usernames, passwords, and the specific permissions granted to each user or to all users using a wildcard. ```json [ { "username": "bob", "password": "secret1", "perms": ["all"] }, { "username": "mary", "password": "secret2", "perms": ["query", "backup", "join"] }, { "username": "*", "perms": ["status", "ready", "join-read-only"] } ] ``` -------------------------------- ### Interact with rqlite Shell Source: https://rqlite.io/docs/quick-start Demonstrates using the rqlite shell to connect to a running node, create a table, insert data, and query the data using standard SQLite syntax. ```sql 127.0.0.1:4001> CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT) 1 row affected (0.000668 sec) 127.0.0.1:4001> .schema +-----------------------------------------------------------------------------+ | sql | +-----------------------------------------------------------------------------+ | CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT) | +-----------------------------------------------------------------------------+ 127.0.0.1:4001> INSERT INTO foo(name) VALUES("fiona") 1 row affected 127.0.0.1:4001> SELECT * FROM foo +----+-------+ | id | name | +----+-------+ | 1 | fiona | +----+-------+ ``` -------------------------------- ### rqlite Shell Basic Usage Example Source: https://rqlite.io/docs/cli Demonstrates connecting to a local rqlite instance and listing available shell commands. This showcases the interactive nature of the shell and its built-in help functionality. ```bash $ rqlite 127.0.0.1:4001> .help .backup Write database backup to SQLite file .consistency [none|weak|strong] Show or set read consistency level .dump Dump the database in SQL text format to a file .exit Exit this program .expvar Show expvar (Go runtime) information for connected node .help Show this message .indexes Show names of all indexes .nodes Show connection status of all nodes in cluster .ready Show ready status for connected node .remove Remove a node from the cluster .restore Restore the database from a SQLite database file or dump file .schema Show CREATE statements for all tables .status Show status and diagnostic information for connected node .sysdump Dump system diagnostics to a file for offline analysis .tables List names of tables 127.0.0.1:4001> ``` -------------------------------- ### Run rqlite with SQLite DB on RAM Disk (Linux) Source: https://rqlite.io/docs/guides/performance This example shows how to combine a memory-backed filesystem with rqlite. First, a RAM disk is created, and then rqlite is launched with its SQLite database file located on this RAM disk. The Raft log is stored on a persistent disk. This configuration prioritizes I/O performance for the database while ensuring data durability for the Raft log. ```bash # Create a RAM disk, and then launch rqlite, telling it to # put the SQLite database on the RAM disk. mount -t tmpfs -o size=4096m tmpfs /mnt/ramdisk rqlited -on-disk-path /mnt/ramdisk/node1/db.sqlite /path_to_persistent_disk/data ``` -------------------------------- ### rqlite Shell Data Insertion and Retrieval Example Source: https://rqlite.io/docs/cli Illustrates how to create a table, insert data using standard SQLite syntax, and then query the data within the rqlite shell. This example highlights the SQL compatibility of rqlite. ```bash 127.0.0.1:4001> CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT) 0 row affected (0.000362 sec) 127.0.0.1:4001> INSERT INTO foo(name) VALUES("fiona") 1 row affected (0.000117 sec) 127.0.0.1:4001> SELECT * FROM foo +----+-------+ | id | name | +----+-------+ | 1 | fiona | +----+-------+ 127.0.0.1:4001> quit bye~ ``` -------------------------------- ### Form an rqlite Cluster Source: https://rqlite.io/docs/quick-start Starts additional rqlite nodes to form a cluster. Each node requires a unique node ID, HTTP address, raft address, and a join target to connect to an existing node. ```bash $ rqlited -node-id 2 -http-addr localhost:4003 -raft-addr localhost:4004 -join localhost:4002 data2/ $ rqlited -node-id 3 -http-addr localhost:4005 -raft-addr localhost:4006 -join localhost:4002 data3/ ``` -------------------------------- ### Speed Up rqlite Builds by Installing SQLite Library (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source To accelerate the build process, especially when it's slowed down by repeated SQLite source code compilation, this command installs the SQLite library once. Subsequent builds will then be significantly faster. ```bash cd $GOPATH/src/github.com/rqlite/rqlite go install github.com/rqlite/go-sqlite3 ``` -------------------------------- ### POST /boot - Booting a Standalone Node Source: https://rqlite.io/docs/guides/backup Initializes a standalone rqlite node rapidly from a SQLite database image. This method is highly efficient for disaster recovery or quick initialization of large databases, but is exclusively for single-node setups. ```APIDOC ## POST /boot ### Description Initializes a standalone rqlite node rapidly from a SQLite database image. This method is highly efficient for disaster recovery or quick initialization of large databases, but is exclusively for single-node setups. ### Method POST ### Endpoint /boot ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None. The SQLite database file is uploaded via `--upload-file`. ### Request Example ```bash curl -XPOST 'http://localhost:4001/boot' -H "Transfer-Encoding: chunked" \ --upload-file largedb.sqlite ``` ### Response #### Success Response (200) Indicates that the node was booted successfully. #### Response Example ```json { "error": "", "results": [], "status": "OK" } ``` ``` -------------------------------- ### Configuration Examples Source: https://rqlite.io/docs/guides/cdc Illustrative examples of various configurations for RQLite IO, including row IDs only, table filtering, mTLS, and exponential backoff retries. ```APIDOC ## Examples ### Row‑IDs‑only Mode Configuration ```json { "endpoint": "https://example.com/webhook", "row_ids_only": true } ``` ### Regex Filter Configuration ```json { "endpoint": "https://example.com/webhook", "table_filter": "^(users|orders)$" } ``` ### mTLS Configuration ```json { "endpoint": "https://secure.example.com/cdc", "tls": { "ca_cert_file": "/etc/certs/ca.pem", "cert_file": "/etc/certs/client.crt", "key_file": "/etc/certs/client.key", "server_name": "secure.example.com" } } ``` ### Exponential Backoff Retries Configuration ```json { "endpoint": "https://example.com/cdc", "transmit_retry_policy": "ExponentialRetryPolicy", "transmit_min_backoff": "200ms", "transmit_max_backoff": "10s", "transmit_max_retries": 12 } ``` ``` -------------------------------- ### Configure Automatic Optimization Interval in rqlite Source: https://rqlite.io/docs/guides/performance This example demonstrates configuring the automatic optimization interval for rqlite using the `-auto-optimze-int` flag. Setting it to '6h' runs 'PRAGMA optimize' every six hours, while '0h' disables automatic optimization. This helps maintain optimal query performance. ```shell rqlited -auto-optimze-int=6h ``` ```shell rqlited -auto-optimze-int=0h ``` -------------------------------- ### rqlite Example: Create Table and Insert Row using curl Source: https://rqlite.io/docs/guides/cdc Demonstrates how to start a single rqlite node printing CDC to stdout for debugging and then uses curl to execute SQL statements for creating a table and inserting a row. ```bash # Start single node printing CDC to stdout - this can be useful for debug and testing. rqlited -cdc-config=stdout ~/node # Execute statements curl -XPOST 'localhost:4001/db/execute?pretty' \ -H 'Content-Type: application/json' \ -d '[ "CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY, name TEXT)", "INSERT INTO users(id, name) VALUES(7, \"fiona\")" ]' ``` -------------------------------- ### Configure Automatic VACUUM in rqlite Source: https://rqlite.io/docs/guides/performance This example shows how to configure rqlite to automatically run the VACUUM command periodically. The `-auto-vacuum-int` flag specifies the interval, for instance, '24h' for daily execution. Be aware of the implications of VACUUM, including write blocking and disk space requirements. ```shell rqlited -auto-vacuum-int=24h ``` -------------------------------- ### rqlite Shell Remote Connection Example Source: https://rqlite.io/docs/cli Shows how to connect to a rqlite instance running on a different host using the `-H` option. This is useful for managing rqlite clusters across a network. ```bash $ rqlite -H 192.168.0.1 192.168.0.1:4001> ``` -------------------------------- ### Start rqlite Node and Join Cluster (Shell) Source: https://rqlite.io/docs/clustering/general-guidelines This command starts a new rqlite node on a specific host, assigning it a unique node ID and configuring its HTTP and Raft network addresses. It also instructs the node to join an existing cluster by connecting to a specified leader node. ```shell rqlited -node-id 3 -http-addr host3:4001 -raft-addr host3:4002 -join host1:4002 ~/node ``` -------------------------------- ### Clone a Fork of rqlite (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This snippet guides users on how to clone their own fork of the rqlite repository while maintaining the required directory structure for Go imports to work correctly. It involves setting up the GOPATH and cloning the fork into the appropriate location. ```bash export GOPATH=$HOME/rqlite mkdir -p $GOPATH/src/github.com/rqlite cd $GOPATH/src/github.com/rqlite git clone git@github.com:/rqlite ``` -------------------------------- ### RQLite Query API with Read Consistency Source: https://rqlite.io/docs/api/read-consistency This section covers the RQLite /db/query endpoint and how to specify various read consistency levels using the 'level' query parameter. It also includes examples for 'weak', 'linearizable', 'none', and 'strong' consistency. ```APIDOC ## GET /db/query ### Description Executes a query against the RQLite database. Allows specification of read consistency levels to control data freshness and consistency guarantees. ### Method GET ### Endpoint /db/query ### Query Parameters - **q** (string) - Required - The SQL query to execute. - **level** (string) - Optional - The read consistency level. Options: 'weak' (default), 'linearizable', 'none', 'strong'. - **linearizable_timeout** (string) - Optional - Timeout for linearizable reads (e.g., '1s'). - **freshness** (string) - Optional - Maximum age of data for 'none' level reads (e.g., '1s'). - **freshness_strict** (boolean) - Optional - Enforces strict freshness checks for 'none' level reads. ### Request Example ```json { "example": "curl -G 'localhost:4001/db/query?q=SELECT * FROM foo&level=weak'" } ``` ### Response #### Success Response (200) - **results** (array) - The results of the query. - **error** (string) - An error message if the query failed. #### Response Example ```json { "example": { "results": [ { " து " : "foo", "columns": ["id", "name"], "types": ["integer", "text"], "values": [[1, "Alice"], [2, "Bob"]] } ], "error": null } } ``` ``` -------------------------------- ### Create Table using curl (Plain Text) Source: https://rqlite.io/docs/api/api Example of creating a table in rqlite using a POST request to the `/db/execute` endpoint with the SQL command directly in the request body. This format is convenient for quick prototyping but less recommended for production. ```shell curl -XPOST 'localhost:4001/db/execute?pretty' -H "Content-Type: text/plain" -d \ 'CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT, age INTEGER)' ``` -------------------------------- ### Build and Run rqlite from Source (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This snippet demonstrates the basic steps to download, build, and run rqlite from its source code using Go. It requires Go 1.24.0 or later and a C compiler. The process involves setting up the GOPATH, cloning the repository, installing dependencies, and then running the rqlited binary. ```bash mkdir rqlite # Or any directory of your choice. cd rqlite/ export GOPATH=$PWD mkdir -p src/github.com/rqlite cd src/github.com/rqlite git clone https://github.com/rqlite/rqlite.git cd rqlite go install ./... $GOPATH/bin/rqlited ~/node.1 ``` -------------------------------- ### View rqlite Cluster Nodes Source: https://rqlite.io/docs/quick-start Displays information about the nodes participating in the rqlite cluster. This includes their API addresses, raft addresses, voter status, reachability, and leader status. ```text 127.0.0.1:4001> .nodes 1: api_addr: http://localhost:4001 addr: localhost:4002 voter: true reachable: true leader: true id: 1 2: api_addr: http://localhost:4003 addr: localhost:4004 voter: true reachable: true leader: false id: 2 3: api_addr: http://localhost:4005 addr: localhost:4006 voter: true reachable: true leader: false id: 3 ``` -------------------------------- ### Generate Code for Protobuf and Flags (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This snippet is for situations where changes are made to Protobuf definitions or command-line flags. It installs necessary tools like protoc-gen-go and flagforge, sets the GOBIN environment variable, updates the PATH, and then runs the go generate command to regenerate code. ```bash go install google.golang.org/protobuf/cmd/protoc-gen-go go install github.com/rqlite/flagforge/cmd/flagforge@latest export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN go generate ./... ``` -------------------------------- ### Get rqlite Node Status via Shell Source: https://rqlite.io/docs/guides/monitoring-rqlite Accesses the status information of a rqlite node directly from the rqlite command-line interface. This provides details about the build, HTTP server, node start time, and Go runtime version. ```shell $ ./rqlite Welcome to the rqlite CLI. Enter ".help" for usage hints. 127.0.0.1:4001> .status build: build_time: unknown commit: unknown version: 5 branch: unknown http: addr: 127.0.0.1:4001 auth: disabled redirect: node: start_time: 2019-12-23T22:34:46.215507011-05:00 uptime: 16.963009139s runtime: num_goroutine: 9 version: go1.13 ``` -------------------------------- ### Boot rqlite Node from SQLite File using rqlite CLI Source: https://rqlite.io/docs/guides/backup Initializes a standalone rqlite node by 'booting' from a SQLite database file using the rqlite command-line interface. This provides a convenient way to load data and immediately query it. ```shell ~ $ rqlite Welcome to the rqlite CLI. Enter ".help" for usage hints. 127.0.0.1:4001> .boot largedb.sqlite Node booted successfully 127.0.0.1:4001> SELECT * FROM foo +----+-------+ | id | name | +----+-------+ | 1 | fiona | +----+-------+ ``` -------------------------------- ### Dockerized rqlite Cluster Node Bootstrapping Source: https://rqlite.io/docs/clustering/automatic-clustering Shows how to launch rqlite nodes within a Docker environment for automatic cluster bootstrapping. All nodes can be started identically using the `docker run` command with the same `-bootstrap-expect` and `-join` parameters. This simplifies deployment by abstracting the underlying host network addresses, represented by `$HOST[1-3]`, which should correspond to the container network addresses. ```bash docker run rqlite/rqlite -bootstrap-expect 3 -join $HOST1:4002,$HOST2:4002,$HOST3:4002 ``` -------------------------------- ### Querying Data - GET /db/query Source: https://rqlite.io/docs/api/api Retrieve data by executing a SELECT statement using an HTTP GET request. The query is passed as a URL-encoded parameter 'q'. ```APIDOC ## GET /db/query ### Description Execute a SQL SELECT statement and retrieve data. The query is provided as a URL-encoded parameter 'q'. Supports optional query parameters like 'pretty' and 'timings'. ### Method GET ### Endpoint `/db/query` ### Query Parameters - **q** (string) - Required - The SQL SELECT statement to execute. - **pretty** (boolean) - Optional - Formats the JSON response for readability. - **timings** (boolean) - Optional - Includes timing information for the query execution. - **associative** (boolean) - Optional - Returns results in an associative form (array of maps). ### Request Example ```bash curl -G 'localhost:4001/db/query?pretty&timings' --data-urlencode 'q=SELECT * FROM foo' ``` ### Response #### Success Response (200) - **results** (array) - An array of query result objects. - **columns** (array) - Array of column names. - **types** (array) - Array of column declared types. - **values** (array) - Array of rows, where each row is an array of values. - **time** (number) - Query execution time in seconds. - **time** (number) - Total request time in seconds. #### Associative Response Example ```json { "results": [ { "types": {"id": "integer", "age": "integer", "name": "text"}, "rows": [ { "id": 1, "age": 20, "name": "fiona"}, { "id": 2, "age": 25, "name": "declan"} ], "time": 0.000173061 } ], "time": 0.000185964 } ``` #### Default Response Example ```json { "results": [ { "columns": [ "id", "name", "age" ], "types": [ "integer", "text", "integer" ], "values": [ [ 1, "fiona", 20 ] ], "time": 0.0150043 } ], "time": 0.0220043 } ``` ``` -------------------------------- ### Boot rqlite Node from SQLite File using cURL Source: https://rqlite.io/docs/guides/backup Initializes a standalone rqlite node by 'booting' from a SQLite database file. This method is efficient for large databases and disaster recovery but is limited to single-node setups initially. It uses the `/boot` endpoint with a POST request. ```shell curl -XPOST 'http://localhost:4001/boot' -H "Transfer-Encoding: chunked" \ --upload-file largedb.sqlite ``` -------------------------------- ### Run rqlite Unit Tests (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This command executes the unit test suite for rqlite. It's essential to run these tests before submitting a pull request to ensure code quality and stability. The output shows the status of tests for different packages within the rqlite project. ```bash $ cd $GOPATH/src/github.com/rqlite/rqlite $ go test ./... ``` -------------------------------- ### rqlite Shell Help Options Source: https://rqlite.io/docs/cli Displays the available command-line options for the rqlite shell. These options control connection parameters, security settings, and general behavior. ```bash $> rqlite -h Options: -h, --help display help information -a, --alternatives comma separated list of 'host:port' pairs to use as fallback -s, --scheme[=http] protocol scheme (http or https) -H, --host[=127.0.0.1] rqlited host address -p, --port[=4001] rqlited host port -P, --prefix[=/] rqlited HTTP URL prefix -i, --insecure[=false] do not verify rqlited HTTPS certificate -c, --ca-cert path to trusted X.509 root CA certificate -u, --user set basic auth credentials in form username:password -v, --version display CLI version ``` -------------------------------- ### Query Data via HTTP GET Source: https://rqlite.io/docs/api/api Perform an HTTP GET request to the /db/query endpoint with the SQL query as a 'q' parameter. Supports pretty printing and timings. The default response includes results, columns, types, and execution time. ```shell curl -G 'localhost:4001/db/query?pretty&timings' --data-urlencode 'q=SELECT * FROM foo' ``` -------------------------------- ### Create Memory-Backed Filesystem (Linux) Source: https://rqlite.io/docs/guides/performance This command creates a temporary filesystem in memory on Linux systems. It is useful for improving I/O performance by storing data like the Raft log and SQLite database in RAM. Be aware of the risk of data loss if power is interrupted. ```bash mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk ``` -------------------------------- ### Automatic Bootstrapping of rqlite Cluster Nodes Source: https://rqlite.io/docs/clustering/automatic-clustering Demonstrates how to bootstrap a 3-node rqlite cluster by starting all nodes simultaneously. Each node is configured with a unique ID, HTTP and Raft addresses, and uses `-bootstrap-expect` to define the required number of nodes for bootstrapping. The `-join` flag specifies the Raft addresses of all nodes in the cluster, ensuring they can discover and form a cluster. This method is idempotent, meaning it can be safely re-run. ```bash rqlited -node-id 1 -http-addr=$HOST1:4001 -raft-addr=$HOST1:4002 \ -bootstrap-expect 3 -join $HOST1:4002,$HOST2:4002,$HOST3:4002 data ``` ```bash rqlited -node-id 2 -http-addr=$HOST2:4001 -raft-addr=$HOST2:4002 \ -bootstrap-expect 3 -join $HOST1:4002,$HOST2:4002,$HOST3:4002 data ``` ```bash rqlited -node-id 3 -http-addr=$HOST3:4001 -raft-addr=$HOST3:4002 \ -bootstrap-expect 3 -join $HOST1:4002,$HOST2:4002,$HOST3:4002 data ``` -------------------------------- ### GET /debug/pprof/* - Pprof Profiling Data Source: https://rqlite.io/docs/guides/monitoring-rqlite Accesses pprof profiling information, which is available by default. Various endpoints exist for different types of profiling data. ```APIDOC ## GET /debug/pprof/* ### Description Accesses pprof profiling information, which is available by default. This can be used for performance analysis and debugging. ### Method GET ### Endpoint /debug/pprof/* #### Path Parameters - *** ** (string) - Required - The specific pprof endpoint to access (e.g., `cmdline`, `profile`, `symbol`). ### Request Example ```bash curl localhost:4001/debug/pprof/cmdline curl localhost:4001/debug/pprof/profile curl localhost:4001/debug/pprof/symbol ``` ### Response #### Success Response (200) - **(various)** - The response format depends on the specific pprof endpoint requested. It typically contains profiling data in a format understandable by the `go tool pprof` command. #### Response Example (Example response will vary based on the specific pprof endpoint and runtime data) ``` -------------------------------- ### GET /debug/vars - Expvar Metrics Source: https://rqlite.io/docs/guides/monitoring-rqlite Retrieves expvar metrics, which are counters of various rqlite activities. You can optionally filter by a specific key using the `key` query parameter. ```APIDOC ## GET /debug/vars ### Description Retrieves expvar metrics, which are counters of various rqlite activities. This data can be used to track the performance of rqlite over time. ### Method GET ### Endpoint /debug/vars #### Query Parameters - **key** (string) - Optional - If provided, filters the expvar output to only include information related to the specified key (e.g., `http`). ### Request Example ```bash curl localhost:4001/debug/vars ``` ### Response #### Success Response (200) - **(object)** - A JSON object containing various expvar metrics. #### Response Example ```json { "cmdline": [ "./rqlited", "data" ], "db": { "execute_transactions": 0, "execution_errors": 1, "executions": 1, "queries": 0, "query_transactions": 0 }, "http": { "backups": 0, "executions": 0, "queries": 0 }, "memstats": { "Mallocs": 8950, "HeapSys": 2588672, "StackInuse": 557056, "LastGC": 0 } } ``` ``` -------------------------------- ### Rebuild and Run rqlite (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This snippet shows how to rebuild and rerun rqlite after making changes to the source code. It assumes you are already in the rqlite source directory and have the necessary Go environment set up. The process involves updating dependencies and restarting the rqlite server. ```bash cd $GOPATH/src/github.com/rqlite/rqlite go install ./... $GOPATH/bin/rqlited ~/node.1 ``` -------------------------------- ### Query rqlite Node as Authenticated User Source: https://rqlite.io/docs/guides/security Example `curl` command to query a rqlite node using Basic Authentication with a username ('mary') and password. It targets the `/db/query` endpoint and pretty-prints the results. ```bash curl -G 'https://mary:secret2@localhost:4001/db/query?pretty&timings' \ --data-urlencode 'q=SELECT * FROM foo' ``` -------------------------------- ### Enable CGO for SQLite Compilation (Go) Source: https://rqlite.io/docs/install-rqlite/building-from-source This section addresses compilation errors related to SQLite functions during the rqlite build process. It emphasizes the need for a correctly configured C compilation environment and setting the CGO_ENABLED environment variable to 1. It also suggests explicitly setting the C compiler using the CC environment variable. ```bash export CGO_ENABLED=1 export CC=gcc # Or your preferred C compiler ``` -------------------------------- ### Set Query Timeouts in rqlite Source: https://rqlite.io/docs/api/api Explains how to set a timeout for SQL queries in rqlite using the `db_timeout` URL parameter. This prevents long-running queries from blocking indefinitely, with the example setting a 2-second timeout. ```bash curl -XPOST 'localhost:4001/db/execute?db_timeout=2s' -H "Content-Type: application/json" -d ' ["INSERT INTO foo(name, age) VALUES(?, ?)", "fiona", 20] ]' ``` -------------------------------- ### Configure S3-Compliant Provider Backups for rqlite (MinIO) Source: https://rqlite.io/docs/guides/backup Set up automatic backups to S3-compliant providers like MinIO, especially when using path-style requests. This configuration requires the `endpoint`, `region`, `bucket`, and credentials, along with `force_path_style: true` for MinIO's default setup. ```json { "version": 1, "type": "s3", "interval": "5m", "vacuum": false, "sub": { "access_key_id": "$ACCESS_KEY_ID", "secret_access_key": "$SECRET_ACCESS_KEY_ID", "endpoint": "https://s3.minio.example.com", "region": "us-east-1", "bucket": "rqlite-kq7z9xg", "path": "backups/db.sqlite3.gz", "force_path_style": true } } ``` -------------------------------- ### Handle rqlite Database-Level Errors Source: https://rqlite.io/docs/api/api Shows how rqlite indicates database-level errors, even with an HTTP 200 status code, by including an 'error' key in the JSON response. This example triggers a syntax error. ```bash curl -XPOST 'localhost:4001/db/execute?pretty&timings' -H "Content-Type: application/json" -d "[ \"INSERT INTO nonsense\" ]" ```