Step-by-Step Loki Binary Deployment on Linux (CentOS/Ubuntu)
This guide walks through preparing a Linux host, downloading Loki v3.6.10, configuring its YAML file, setting up a systemd service, deploying Promtail for log collection, and integrating Grafana for visualization, all using a unified /app/soft directory structure.
Prerequisites
Target OS: CentOS 7.x / 8.x (Ubuntu similar). Required components: Loki v3.6.10 (latest stable, GLIBC‑compatible), Promtail for log collection, Grafana for visualization.
Note: On CentOS 7 the default GLIBC is lower than 2.32; deploying v3.6.10 may fail with GLIBC_2.32/2.34 not found. Upgrade GLIBC or use an older Loki version.
1. Environment Preparation
Disable the firewall or open ports 3100, 9090, 3000.
2. Deploy Loki Server (binary)
2.1 Create directories
mkdir -p /app/soft/{bin,conf,data}
cd /app/soft/bin2.2 Download and install Loki
wget https://github.com/grafana/loki/releases/download/v3.6.10/loki-linux-amd64.zip
unzip loki-linux-amd64.zip
chmod +x loki-linux-amd64
mv loki-linux-amd64 loki2.3 Create Loki configuration
Save the following as /app/soft/conf/loki-config.yaml (paths adapted to /app/soft).
server:
http_listen_port: 3100 # Loki service port
grpc_listen_port: 9096 # gRPC port
log_level: info
common:
instance_addr: 127.0.0.1
path_prefix: /app/soft/data
storage:
filesystem:
chunks_directory: /app/soft/data/chunks
rules_directory: /app/soft/data/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
schema_config:
configs:
- from: 2025-04-08
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
compactor:
working_directory: /app/soft/data/compactor
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
delete_request_store: filesystem
limits_config:
retention_period: 72h
ruler:
alertmanager_url: http://localhost:9093
frontend:
encoding: protobuf2.4 Create systemd service for Loki
vim /etc/systemd/system/loki.serviceService file content:
[Unit]
Description=Loki Log Aggregation System
After=network.target
[Service]
User=root
Group=root
ExecStart=/app/soft/bin/loki -config.file=/app/soft/conf/loki-config.yaml
Restart=always
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetReload systemd, start and enable the service, then verify:
systemctl daemon-reload
systemctl start loki
systemctl enable loki
systemctl status loki
curl localhost:3100/ready # should return "ready"3. Deploy Promtail (log collector)
3.1 Download and install Promtail
cd /app/soft/bin
wget https://github.com/grafana/loki/releases/download/v3.6.10/promtail-linux-amd64.zip
unzip promtail-linux-amd64.zip
chmod +x promtail-linux-amd64
mv promtail-linux-amd64 promtail3.2 Create Promtail configuration
Save as /app/soft/conf/promtail-config.yaml:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /app/soft/data/positions.yaml
clients:
- url: http://127.0.0.1:3100/loki/api/v1/push
scrape_configs:
# System logs
- job_name: system
static_configs:
- targets: [localhost]
labels:
job: system_log
env: test
node: localhost
file_sd_configs:
- files: [/app/soft/conf/system-logs.yaml]
# Loki own logs
- job_name: loki
static_configs:
- targets: [localhost]
labels:
job: loki_log
env: test
node: localhost
file_sd_configs:
- files: [/app/soft/conf/loki-logs.yaml]3.3 Define log path files
System log paths ( /app/soft/conf/system-logs.yaml):
- targets:
- localhost
labels:
__path__: /var/log/*.log
__path__: /var/log/messages
__path__: /var/log/secureLoki log path ( /app/soft/conf/loki-logs.yaml):
- targets:
- localhost
labels:
__path__: /var/log/loki.log3.4 Create systemd service for Promtail
vim /etc/systemd/system/promtail.serviceService file content:
[Unit]
Description=Promtail Log Collector
After=network.target loki.service
[Service]
User=root
Group=root
ExecStart=/app/soft/bin/promtail -config.file=/app/soft/conf/promtail-config.yaml
Restart=always
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetReload systemd, start and enable Promtail, then verify its status.
systemctl daemon-reload
systemctl start promtail
systemctl enable promtail
systemctl status promtail4. Deploy Grafana and Add Loki Datasource
Install Grafana (method omitted) and configure it to use Loki as a data source. The article includes screenshots of the Grafana UI for adding the datasource.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Linux Cloud-Native Ops Stack
Focused on practical internet operations, sharing server monitoring, troubleshooting, automated deployment, and cloud-native tech insights. From Linux basics to advanced K8s, from ops tools to architecture optimization, helping engineers avoid pitfalls, grow quickly, and become your tech companion.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
