Skip to content

Instantly share code, notes, and snippets.

@ianchen06
Created June 26, 2017 10:29
Show Gist options
  • Save ianchen06/73acc392c72d6680099b7efac1351f56 to your computer and use it in GitHub Desktop.
Save ianchen06/73acc392c72d6680099b7efac1351f56 to your computer and use it in GitHub Desktop.
delete proxmox cluster
# source: https://forum.proxmox.com/threads/removing-deleting-a-created-cluster.18887/
#/bin/sh
# stop service
systemctl stop pvestatd.service
systemctl stop pvedaemon.service
systemctl stop pve-cluster.service
systemctl stop corosync
systemctl stop pve-cluster
# edit through sqlite, check, delete, verify
$ sqlite3 /var/lib/pve-cluster/config.db
sqlite> select * from tree where name = 'corosync.conf';
254327|0|254329|0|1480944811|8|corosync.conf|totem {
version: 2
[...]
sqlite> delete from tree where name = 'corosync.conf';
sqlite> select * from tree where name = 'corosync.conf';
sqlite> .quit
#
#Remove directories
pmxcfs -l
rm /etc/pve/corosync.conf
rm /etc/corosync/*
rm /var/lib/corosync/*
rm -rf /etc/pve/nodes/*
@chaddyc
Copy link

chaddyc commented Jun 22, 2019

rm -r /etc/corosync/*
rm -r /var/lib/corosync/*

//remove line 26 (Do not delete virtual machines) " rm -rf /etc/pve/nodes/*

@datacorder
Copy link

Please add:

rm -f /var/lib/pve-cluster/.pmxcfs.lockfile

@bforpc
Copy link

bforpc commented Oct 14, 2019

beutifying the script above:

`
if [ "$1" ]; then

    echo -e "stopping Services:\npvestatd"
    systemctl stop pvestatd.service
    echo "pvedaemon"
    systemctl stop pvedaemon.service
    echo "pve-cluster.service"
    systemctl stop pve-cluster.service
    echo "pve-corosync"
    systemctl stop corosync
    echo "pve-cluster"
    systemctl stop pve-cluster
    echo "deleting data from db..."
    #echo "select * from tree where name = 'corosync.conf';"| sqlite3 /var/lib/pve-cluster/config.db
    echo "delete from tree where name = 'corosync.conf';"| sqlite3 /var/lib/pve-cluster/config.db
    echo "select * from tree where name = 'corosync.conf';"| sqlite3 /var/lib/pve-cluster/config.db
    #Remove directories
    pmxcfs -l
    rm -f /var/lib/pve-cluster/.pmxcfs.lockfile
    rm -f /etc/pve/corosync.conf
    rm -f /etc/corosync/*
    rm -f /var/lib/corosync/*
    rm -rf /etc/pve/nodes/$1/*
    echo "Staring services ..."
    echo "pvestatd"
    systemctl start pvestatd.service
    echo "pvedaemon"
    systemctl start pvedaemon.service
    echo "pve-cluster.service"
    systemctl start pve-cluster.service
    echo "pve-corosync"
    systemctl start corosync
    echo "pve-cluster"
    systemctl restart pve-cluster
else
    echo "Deleting node name missing or not existing. EXIT!"
    exit
fi

`
Bfo

@amcsng
Copy link

amcsng commented Sep 13, 2020

Thank you so much.

@jmcabandara
Copy link

jmcabandara commented Oct 30, 2020

@bforpc @ianchen06

Thank you so much

@rauhmaru
Copy link

rauhmaru commented Mar 8, 2021

Thanks! Helped a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment