1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Proxmox node name change

Discussion in 'Proxmox VE: Installation and configuration' started by petka, Jun 29, 2013.

  1. petka

    petka New Member

    Joined:
    Jul 31, 2012
    Messages:
    12
    Likes Received:
    0
    Hello everyone!

    As mentioned in the topic - I have only 1 proxmox node (which is not in a cluster or so) and would like to change its name.
    Is there any way I could do that without rebooting the hypervisor?

    If yes, how?

    P.
     
  2. tom

    tom Proxmox Staff Member
    Staff Member

    Joined:
    Aug 29, 2006
    Messages:
    11,908
    Likes Received:
    176
    change /etc/hostname and /etc/hosts
     
    chrone likes this.
  3. tom

    tom Proxmox Staff Member
    Staff Member

    Joined:
    Aug 29, 2006
    Messages:
    11,908
    Likes Received:
    176
  4. petka

    petka New Member

    Joined:
    Jul 31, 2012
    Messages:
    12
    Likes Received:
    0
  5. petka

    petka New Member

    Joined:
    Jul 31, 2012
    Messages:
    12
    Likes Received:
    0
    Re: [SOLVED] Proxmox node name change

    Hello,

    Actually, that hostname change caused me a lot of troubles. Indeed, when you change these files your hostname would change but:
    1) It creates a separate datacentre (called with the new name)
    2) All of your virtual machines are in the "old" datacentre
    3) You can not power on old machines in the old datacentre as you removed the old hostname
    4) When you click on the old datacentre you see "proxy loop error"

    I was also thinking of backing up all of my machines and importing it to the new datacentre, but why do I need to make such an effort because of the hostname change?

    P.
     
  6. tom

    tom Proxmox Staff Member
    Staff Member

    Joined:
    Aug 29, 2006
    Messages:
    11,908
    Likes Received:
    176
    Re: [SOLVED] Proxmox node name change

    copy all files and folders below /etc/pve/nodes/old to the /etc/pve/nodes/new,

    then remove /etc/pve/nodes/old
     
    chrone likes this.
  7. apmuthu

    apmuthu Member

    Joined:
    Feb 26, 2009
    Messages:
    739
    Likes Received:
    2
    The following was done to change the hostname on a PVE 3.0 machine:
    Code:
    nano /etc/hosts
    nano /etc/hostname
    nano /etc/postfix/main.cf
    cd /etc/pve/nodes/
    cp -r old new
    rm -r old
    cd /var/lib/rrdcached/db/pve2-node/
    cp -r old new
    rm -r old
    
    On reboot the Web GUI was inaccessible and so was PuTTY although the physical machine could be logged into.

    The following was also tried to no avail:
    Code:
    #!/bin/bash
    # 
    usage() {
       echo "usage : $0 new_host_name"
       exit 1
    }
    
    [ -z $1 ] && usage
    
    old=`hostname`
    new=$1
    
    for file in \
       /etc/exim4/update-exim4.conf.conf \
       /etc/printcap \
       /etc/hostname \
       /etc/hosts \
       /etc/ssh/ssh_host_rsa_key.pub \
       /etc/ssh/ssh_host_dsa_key.pub \
       /etc/motd \
       /etc/ssmtp/ssmtp.conf
    do
       [ -f $file ] && sed -i.old -e "s:$old:$new:g" $file
    done
     
    #7 apmuthu, Jul 10, 2013
    Last edited: Jul 10, 2013
  8. petka

    petka New Member

    Joined:
    Jul 31, 2012
    Messages:
    12
    Likes Received:
    0
    Hi guys,

    I needed some time to plan a maintenance window and so on.

    @tom - Thanks for letting me know, that worked like a charm!
    @amputhu - ta very much for the script. It gave me ideas where the hostname variable may hide elsewhere than in /etc/hostname :)

    P.
     
  9. technova

    technova New Member

    Joined:
    Oct 16, 2010
    Messages:
    6
    Likes Received:
    0
    Re: [not really SOLVED] Proxmox node name change

    Hi, this seems really simple :

    But it doesn't work for me : it says that the "standard file" already exists
    Code:
    # ls -al batman/openvz/
    total 0
    drwxr-x--- 2 root www-data 0 aout  20 01:48 .
    drwxr-x--- 2 root www-data 0 juin  20 08:29 ..
    # cp -f sd-46880/openvz/*.* batman/openvz/
    cp: impossible de creer le fichier standard á?batman/openvz/100.conf?â: Le fichier existe
    should I delete the cluster before (rm -rf /var/lib/pve-cluster/*) ?
     
  10. apmuthu

    apmuthu Member

    Joined:
    Feb 26, 2009
    Messages:
    739
    Likes Received:
    2
    Re: [not really SOLVED] Proxmox node name change

    So far, the only safe and successful way to migrate / change node name is to create a new Proxmox and move the containers to it. The down side is to either have a new hardware set or atleast another set of hard disks and backup old virtual machines to some network storage to restore from later.

    Errors such as "standard file exists" are cryptic indeed and only Proxmox subscription holders can partake of support from the horse's mouth.

    In your case see that you migrate only the numbered ###.conf files and not the non-numbered ones.
     
    #10 apmuthu, Aug 20, 2013
    Last edited: Aug 20, 2013
  11. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,270
    Likes Received:
    162
    Re: [not really SOLVED] Proxmox node name change

    The error is quite clear to me - a VM config file with the same VMID already exists - the simple solution is to use 'mv' instead of 'cp'.
     
  12. technova

    technova New Member

    Joined:
    Oct 16, 2010
    Messages:
    6
    Likes Received:
    0
    Re: [not really SOLVED] Proxmox node name change

    It still didn't work. Even with the root account.
    And after a restart of pve-cluster /etc/pve/openvz linked to the empty /etc/pve/openvz/nodes/newhostname/openvz/
    so vzctl enter NNN didn't work because the configuration file wasn't found
    I restored the old hostname (/etc/hostname etc..) and I can now enter again in the vm.
    The web interface doesn't work (there is still the old 'newhostname' node inside), but it doesn't matter.
     
  13. technova

    technova New Member

    Joined:
    Oct 16, 2010
    Messages:
    6
    Likes Received:
    0
    Re: [not really SOLVED] Proxmox node name change

    I've restarted pveproxy and then pve-cluster.
    Now everything is fine.
    I only see one node in the GUI
     
  14. David McNeill

    David McNeill New Member

    Joined:
    Jun 8, 2016
    Messages:
    2
    Likes Received:
    0
    apmuthu said:
    Errors such as "standard file exists" are cryptic indeed and only Proxmox subscription holders can partake of support from the horse's mouth.

    Dietmar said: ↑
    The error is quite clear to me - a VM config file with the same VMID already exists - the simple solution is to use 'mv' instead of 'cp'.

    This is a disingenious answer from Dietmar.

    The error occurs because /etc/pve is virtual file system managed by the cluster file system, even if you only have one node. The files actually live inside a managed database. If a 100.conf file exists on any node, including the deleted and not available node, it is deemed to exist, since the cluster manager doesn't allow two nodes to exist in the same datacenter to have the same (conflicting) node number.

    * provides strong consistency checks to avoid duplicate VM IDs

    If you follow the instructions in link above to take the cluster offline, then you can make the changes in local mode.

    service pve-cluster stop
    pmxcfs --local
    (make changes)
    service pve-cluster stop
    restart pve services (or reboot)
     
  15. breakaway9000

    breakaway9000 New Member

    Joined:
    Dec 20, 2015
    Messages:
    17
    Likes Received:
    2
    I just found this thread (First hit on google for 'proxmox change hostname').

    I am running Proxmox 4.4-2 and I have an assortment of both containers and VMs on my host (qemu). It is a single-host environment, no clustering in use. I am however using a 3-disk RAIDZ-1 for storage (as configured by the Proxmox installer).

    It turns out the steps to follow in order to change the hostnames are as follow:
    1. Powerdown all VMs and containers
    2. Edit /etc/hostname and /etc/hosts with the new hostname
    3. Reboot the host
    4. At this point you will see your old host as "disconnected" in the web interface, and a new host with your new hostname appears.
    5. SSH into the machine and navigate to /etc/pve/nodes - here you will see two folders (one with your new hostname, one with your old hostname)
    6. The config for the containers is located at /etc/pve/nodes/<currenthostname>/lxc
    7. The config for virtual machines is stored at /etc/pve/nodes/<currenthostname>/qemu-server
      etc. depending on what other technologies you are using
    8. So I just moved the contents of each folder into the folder for the new host - i.e. /etc/pve/nodes/<newhostname>/lxc etc.
      The second I did this, I saw the web interface update with the VMs and containers now showing in the correct datacenter and under the correct host.
    9. Finally, move the folder with the old server's hostname (/etc/pve/nodes/<oldhostname>) somewhere for backup.
    10. Reboot
    When the system came back up the old "disconnected" host was gone, and only the new host was shown with the correct name. All the containers & VMs start up just fine, all the host config has been retained and is working properly.
     
    Brendon and rezzo like this.
  16. psyray

    psyray New Member

    Joined:
    Jan 19, 2015
    Messages:
    2
    Likes Received:
    1
    Brendon likes this.
  17. Brendon

    Brendon New Member
    Proxmox VE Subscriber

    Joined:
    Jan 9, 2016
    Messages:
    1
    Likes Received:
    0
    Thank you @breakaway9000 for the very helpful response. I just wanted to add that the files have to be MOVED for some reason. Copying them doesn't seem to work - I got "file exists" or something just like another user here did. I just assume they are special in some way.

    Also, I simply restarted pveproxy at the end. I didn't have to reboot again.

    If anyone wants to save the old rrd data that's all under /var/lib/rrdcached/db. I didn't care about this data, so I simply deleted the entry for the old hostname.
     
  18. cosmicdan

    cosmicdan New Member

    Joined:
    Jul 8, 2017
    Messages:
    5
    Likes Received:
    0
    Apart from what was already mentioned, here are a couple more things I had to do:

    1) Change some storage and config references in /etc/pve - just do a grep -ir 'oldhostnamehere' /etc/pve/. to find that
    2) Don't forget to change the Search domain option for the node's DNS so your containers have they hostname set correctly (since PVE sets these dynamically).
     

Share This Page