Why Choose Valkey and RamNode?
Valkey Benefits:
- • Lightning-fast performance and Redis compatibility
- • Truly open-source under BSD license
- • Perfect for caching and session storage
- • Real-time analytics and message queuing
RamNode Advantages:
- • High-performance SSD VPS instances
- • Excellent network connectivity
- • Competitive pricing for databases
- • Reliable infrastructure for production workloads
Prerequisites
Before starting, ensure you have:
Server Requirements
- • RamNode VPS (Ubuntu 22.04 LTS recommended)
- • SSH access to your server
- • Sudo privileges on your VPS
- • At least 1GB RAM (2GB+ recommended)
Knowledge Requirements
- • Basic familiarity with Linux command line
- • Understanding of key-value databases
- • SSH connection skills
Initial Server Setup
Connect to your RamNode VPS and prepare the system:
ssh root@your-server-ipapt update && apt upgrade -yapt install curl wget gnupg lsb-release software-properties-common -y💡 Tip: Replace "your-server-ip" with your actual RamNode VPS IP address.
Install Valkey
Install Valkey using the official installation method:
curl -fsSL https://download.valkey.io/valkey-official.gpg | sudo gpg --dearmor -o /usr/share/keyrings/valkey-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/valkey-archive-keyring.gpg] https://download.valkey.io/deb stable main" | sudo tee /etc/apt/sources.list.d/valkey.listapt update apt install valkey -yuseradd --system --home /var/lib/valkey --shell /bin/false valkey
mkdir -p /var/lib/valkey /var/log/valkey /etc/valkey
chown valkey:valkey /var/lib/valkey /var/log/valkey
chmod 750 /var/lib/valkey /var/log/valkey✅ Valkey is now installed with proper user and directory setup.
Configure Valkey
Create and configure the Valkey configuration file:
nano /etc/valkey/valkey.confAdd the following basic configuration:
# Network Configuration
bind 127.0.0.1 ::1
port 6379
timeout 300
# General Configuration
daemonize yes
pidfile /var/run/valkey/valkey-server.pid
loglevel notice
logfile /var/log/valkey/valkey-server.log
# Data Persistence
dir /var/lib/valkey
dbfilename dump.rdb
save 900 1
save 300 10
save 60 10000
# Memory Management
maxmemory 512mb
maxmemory-policy allkeys-lru
# Security
protected-mode yes
# requirepass yourpasswordhere
# Performance
tcp-keepalive 300
tcp-backlog 511⚠️ Important: Uncomment and set the "requirepass" directive with a strong password for production use.
Security Configuration
Secure your Valkey installation:
# Generate a strong password
openssl rand -base64 32
# Add to configuration file
echo "requirepass YOUR_STRONG_PASSWORD_HERE" >> /etc/valkey/valkey.confcat >> /etc/valkey/valkey.conf << EOF
# Rename dangerous commands
rename-command FLUSHALL FLUSHALL_RENAME_TO_SOMETHING_HARD_TO_GUESS
rename-command FLUSHDB FLUSHDB_RENAME_TO_SOMETHING_HARD_TO_GUESS
rename-command CONFIG CONFIG_RENAME_TO_SOMETHING_HARD_TO_GUESS
rename-command DEBUG DEBUG_RENAME_TO_SOMETHING_HARD_TO_GUESS
rename-command EVAL ""
EOFchmod 640 /etc/valkey/valkey.conf
chown root:valkey /etc/valkey/valkey.confConfigure Firewall
Configure UFW firewall for Valkey (if accessing remotely):
# No firewall changes needed for local-only access systemctl status ufw# Only if you need remote access
ufw allow from trusted_ip_address to any port 6379
ufw reload🔒 Security: Valkey should generally only accept local connections. Only allow remote access from trusted IP addresses.
Create Systemd Service
Create and configure the systemd service:
nano /etc/systemd/system/valkey.service[Unit]
Description=Valkey In-Memory Data Store
After=network.target
[Service]
User=valkey
Group=valkey
ExecStart=/usr/bin/valkey-server /etc/valkey/valkey.conf
ExecStop=/usr/bin/valkey-cli shutdown
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl enable valkey
systemctl start valkeysystemctl status valkeyTest Valkey Connection
Verify that Valkey is running correctly:
valkey-cli pingPONGvalkey-cli -a yourpassword pingvalkey-cli -a yourpassword
# In the Valkey CLI:
SET test_key "Hello Valkey"
GET test_key
DEL test_key
EXIT🎉 Success: Your Valkey server is now running and accepting connections!
Performance Tuning
Optimize Valkey performance for your workload:
# Increase system limits
echo "valkey soft nofile 65535" >> /etc/security/limits.conf
echo "valkey hard nofile 65535" >> /etc/security/limits.conf
# Disable Transparent Huge Pages
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local
# Optimize kernel parameters
sysctl -w vm.overcommit_memory=1
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf# Check memory usage
valkey-cli -a yourpassword info memory
# Monitor active connections
valkey-cli -a yourpassword info clients
# Check slow queries
valkey-cli -a yourpassword slowlog get 10Setup Monitoring
Set up basic monitoring for your Valkey instance:
cat > /usr/local/bin/valkey-monitor.sh << 'EOF'
#!/bin/bash
VALKEY_CLI="valkey-cli -a yourpassword"
LOG_FILE="/var/log/valkey/monitor.log"
echo "$(date): Valkey Status Check" >> $LOG_FILE
$VALKEY_CLI ping >> $LOG_FILE 2>&1
$VALKEY_CLI info server | grep uptime >> $LOG_FILE
$VALKEY_CLI info memory | grep used_memory_human >> $LOG_FILE
echo "---" >> $LOG_FILE
EOF
chmod +x /usr/local/bin/valkey-monitor.sh# Add to crontab for regular monitoring
echo "*/5 * * * * /usr/local/bin/valkey-monitor.sh" | crontab -Backup Configuration
Configure automated backups for your Valkey data:
cat > /usr/local/bin/valkey-backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/var/backups/valkey"
DATE=$(date +%Y%m%d_%H%M%S)
VALKEY_CLI="valkey-cli -a yourpassword"
mkdir -p $BACKUP_DIR
$VALKEY_CLI --rdb $BACKUP_DIR/valkey_backup_$DATE.rdb
find $BACKUP_DIR -name "*.rdb" -mtime +7 -delete
EOF
chmod +x /usr/local/bin/valkey-backup.shecho "0 2 * * * /usr/local/bin/valkey-backup.sh" | crontab -Troubleshooting
Next Steps & Integration
Application Integration
Connect your applications to Valkey using these connection parameters:
Host: 127.0.0.1
Port: 6379
Password: [your-configured-password]Popular Use Cases
- • Caching: Speed up web applications with data caching
- • Session Storage: Store user sessions for web applications
- • Message Queues: Implement pub/sub messaging systems
- • Real-time Analytics: Store and process streaming data
