products:cockpit.old:1.0:installguide:installvictoriametrics

Install Victoria Metrics

Install with delivered script

  • Pro.Monitor Cockpit deliver a script to install automatically victoria metrics.
  • Victoria metrics will be installed by default in /opt/victoria.
  • Run the install.sh script in victoria-metrics
  • Alternatively, you can download the latest package from Victoria metrics repository
  • Look for package victoria-metrics-linux-amd64-vx.yy.zz.tar.gz

Prepare VM files system

  • You need to prepare two file systems:
    • One for hosting database data
    • One for hosting database backups

Install manually

mkdir /YOUR_FOLDER/victoriametrics
nano /etc/systemd/system/victoriametrics.service

Content victoriametrics.service file :

[Unit]
Description=Victoria Metrics
After=network.target

[Service]
Type=simple
StartLimitBurst=5
StartLimitInterval=0
Restart=on-failure
RestartSec=1
PIDFile=/YOUR_FOLDER/victoriametrics/victoriametrics.pid
ExecStart=/usr/local/bin/victoriametrics -storageDataPath /YOUR_FOLDER/victoriametrics-data -retentionPeriod 6 -graphiteListenAddr=:2003 -dedup.minScrapeInterval=1ms
ExecStop=/bin/kill -s SIGTERM $MAINPID

[Install]
WantedBy=multi-user.target
chmod 755 /etc/systemd/system/victoriametrics.service
mkdir /etc/systemd/system/victoriametrics.service.d
nano /etc/systemd/system/victoriametrics.service.d/ulimit.conf

Create the file ulimit.conf with following content :

[Service]
LimitNOFILE=32000
LimitNPROC=32000
wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.56.0/victoria-metrics-amd64-v1.56.0.tar.gz
tar -zxvf victoria-metrics-amd64-v1.56.0.tar.gz
cp -R victoria-metrics-prod /usr/local/bin/victoriametrics
systemctl enable victoriametrics
firewall-cmd --zone=public --add-port=2003/tcp --permanent
firewall-cmd --reload
systemctl start victoriametrics

Backups

  • To configure backups, we are going to use victoria metrics vmbackup utility.
  • Get the files:
wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.77.2/vmutils-amd64-v1.77.2.tar.gz
tar -zxvf vmutils-amd64-v1.77.2.tar.gz
  • Create a script do_vm_backup.sh:
#!/bin/sh
vmbackup-prod -storageDataPath=[VM_DATA_FOLDER] -snapshot.createURL=http://localhost:8428/snapshot/create -dst=fs://[VM_BACKUP_FOLDER]
  • Change file permissions
chmod 700 do_vm_backup.sh
  • Edit crontab
crontab -e
0 */1 * * * /[PATH_TO_SCRIPT]/do_vm_backup.sh
  • The backup will now run once per hour

Restore

  • To restore a backup, we are going to use the vmrestore utility:
systemctl stop victoriametrics
vmrestore-prod -src=fs:///[PATH_TO_BACKUPS]  -storageDataPath=[VM_DATA_FOLDER]
systemctl start victoriametrics
/home/clients/8c48b436badcd3a0bdaaba8c59a54bf1/wiki-web/data/pages/products/cockpit.old/1.0/installguide/installvictoriametrics.txt · Last modified: 2024/05/01 18:39 (external edit)