aerospike.conf.j2
Overview
This file is a Jinja2 template for generating the Aerospike database configuration file (aerospike.conf). It defines the key configuration blocks required to set up an Aerospike node, including service identity, logging, network settings, and namespace storage. The template uses placeholders and control structures (like loops and variable substitutions) to dynamically configure parameters such as ports and data files, adapting the configuration based on deployment-specific variables.
File Structure and Key Configuration Sections
1. service Block
Purpose: Defines high-level service parameters for the Aerospike instance.
Key parameter:
cluster-name: A fixed string identifying the Aerospike cluster as "acki-nacki-node".
Usage: This name is used by cluster nodes to identify themselves as part of the same cluster.
2. logging Block
Purpose: Specifies logging behavior and contexts.
Sub-block:
console: Defines console logging configuration.context any info: Enables informational level logging for any context, which helps in debugging and monitoring.
3. network Block
Defines network-related configuration for various Aerospike communication channels.
Sub-block:
serviceaddress any: Binds to all available network interfaces.port {{ AEROSPIKE_PORT }}: Uses a Jinja2 variable to set the service port dynamically.# access-address <IPADDR>: Commented out placeholder for specifying a specific access address if needed.
Sub-block:
heartbeatmode mesh: Specifies the heartbeat mode as mesh, suitable for environments without multicast support.address local: Uses the local address for heartbeat communications.port {{ AEROSPIKE_HEARTBEAT_PORT }}: Dynamic port for heartbeat messages.interval 150: Heartbeat interval in milliseconds.timeout 10: Time in milliseconds before a node is considered down after missing heartbeats.
Sub-block:
fabricHandles intra-cluster communications such as migrations and replication.
address local: Binds to the local address.port {{ AEROSPIKE_FABRIC_PORT }}: Dynamic port for fabric communication.
4. namespace node Block
Purpose: Defines a namespace called
nodewhich is a logical grouping within Aerospike for data storage.Parameters:
replication-factor 1: Data replication factor set to 1, meaning no replication.
Storage Engine:
Uses the
devicestorage engine type with the following configuration:file /opt/aerospike/data/node.dat: Specifies the primary data file.Additional data files are dynamically added using a Jinja2 loop:
{% for i in range(2, (AS_FILES_CNT | default(16) + 1)) %} file /opt/aerospike/data/node{{ i }}.dat {% endfor %}This loop creates multiple data files starting from
node2.datup tonode{AS_FILES_CNT}.dat, defaulting to 16 files ifAS_FILES_CNTis not defined.filesize {{ AS_FILE_SIZE | default('80G') }}: Sets the file size per data file, defaulting to 80 GB.Other options:
direct-files true: Enables direct I/O for data files.disable-odsync true: Disables O_DSYNC flag on file writes to improve performance.read-page-cache true: Enables the page cache for read operations.stop-writes-used-pct 100: Threshold percentage of used storage at which writes are stopped.stop-writes-avail-pct 0: Threshold percentage of available storage at which writes are stopped.
Important Implementation Details
Template Variables:
AEROSPIKE_PORT,AEROSPIKE_HEARTBEAT_PORT,AEROSPIKE_FABRIC_PORT: Ports are templated to provide flexibility for different deployment environments.AS_FILES_CNT: Controls the number of data files created for the namespace, allowing scaling of storage.AS_FILE_SIZE: Specifies the size of each data file.
Dynamic Data Files Generation:
The Jinja2 loop for generating multiple data files enables easy scaling of storage capacity by simply changing a single parameter without editing the configuration manually.
Network Heartbeat Mode:
Using
meshmode for heartbeat is crucial for environments that do not support multicast, such as certain cloud or containerized environments.
Storage Engine Optimizations:
direct-filesanddisable-odsyncoptions are used to improve storage performance by bypassing OS caches and disabling synchronous writes, respectively.The
read-page-cacheoption helps optimize read performance by enabling caching at the page level.
Interaction with Other System Components
Deployment Automation:
This template is typically rendered by a configuration management or orchestration system that provides the required variables (
AEROSPIKE_PORT,AS_FILES_CNT, etc.).
Aerospike Node Initialization:
The resulting configuration file guides the Aerospike server on startup, defining how the node communicates with others (
networkblock), logs information (loggingblock), and stores data (namespaceblock).
Cluster Coordination:
The
heartbeatandfabricsettings ensure this node can discover and communicate with peers, facilitating cluster health and data replication.
Storage Volume Management:
The data files referenced are expected to be present or created on the host's filesystem, and their paths and sizes align with the storage infrastructure provisions.
Usage Example of the Template Variables
Suppose the following variables are provided at render time:
AEROSPIKE_PORT: 3000
AEROSPIKE_HEARTBEAT_PORT: 3002
AEROSPIKE_FABRIC_PORT: 3001
AS_FILES_CNT: 4
AS_FILE_SIZE: '50G'
The generated configuration will:
Bind service port to
3000.Use heartbeat port
3002.Use fabric port
3001.Create 4 data files:
node.dat,node2.dat,node3.dat,node4.dat.Set each file size to 50 GB.
Mermaid Diagram: Configuration File Structure Flowchart
flowchart TD
A[aerospike.conf.j2 Template] --> B[service Block]
A --> C[logging Block]
A --> D[network Block]
A --> E[namespace node Block]
D --> D1[service Network]
D --> D2[heartbeat Network]
D --> D3[fabric Network]
E --> E1[replication-factor]
E --> E2[storage-engine device]
E2 --> E3[data files loop]
E2 --> E4[filesize & options]
This flowchart illustrates the hierarchical structure of the configuration defined within the file, highlighting the main blocks and their subcomponents.