XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Host time and XOA time are not consistent with each other

    Scheduled Pinned Locked Moved Unsolved Xen Orchestra
    6 Posts 4 Posters 190 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      Octopuss
      last edited by

      What can I do about this? This happens after every server reboot. I couldn't find any time settings for VMs, and I assumed time was sychronized automatically. Well apparently it doesn't....

      tjkreidlT poddingueP 2 Replies Last reply
      Reply Quote 0
      • tjkreidlT
        tjkreidl Ambassador @Octopuss
        last edited by

        @Octopuss My understanding is that VMs do NOT automatically synchronize with the XCP-ng hosts. XCP-ng uses chrony (chronyd) to synchronize time over NTP. It switched from ntpd to chrony starting in XCP-ng 8.1 and should be set up on both the servers and any VMs independently. There is documentation on the XCP-ng Website about how to implement this.

        1 Reply Last reply
        Reply Quote 1
        • poddingueP poddingue marked this topic as a question
        • poddingueP
          poddingue Vates 🪐 @Octopuss
          last edited by

          @tjkreidl has it right, I think: the host and the XO VM each keep their own clock, so both of them need a working NTP source. The page he means is probably this one: https://docs.xcp-ng.org/management/hosts-pools#time-synchronization-ntp.
          There are two older threads with this warning, and in both it seems to have come down to one side not reaching any NTP server, once because NTP was never set on the host (https://xcp-ng.org/forum/post/86396) and once because DNS broke after an update (https://xcp-ng.org/forum/post/97429).

          Could you run chronyc sources on the host and timedatectl on the XO VM right after a reboot, and tell us whether you're on XOA or XO built from sources? Olivier mentioned in one of those threads that XOA comes with an NTP client while a from-sources install leaves that part to you, but I'm not sure that alone explains why it shows up after every reboot.

          O 1 Reply Last reply
          Reply Quote 0
          • O
            Octopuss @poddingue
            last edited by

            Sorry this forum is weird, it says I need reputation to post links. I cannot put the screenshots here 😞

            D 1 Reply Last reply
            Reply Quote 1
            • D
              DustinB @Octopuss
              last edited by

              @Octopuss said:

              Sorry this forum is weird, it says I need reputation to post links. I cannot put the screenshots here 😞

              Not at all a problem, the answer here is you need to set up your guests and hosts to use the same time source, normally that might be a NTP or AD server that is on-premise (whatever else the rest of your network uses) rather than a public one like pool.ntp.org.

              This way, everything within the network has the same time source as your "source of truth" for your entire private network. That NTP server would then be the only time source that would point to something like pool.ntp.org but you have to set up each VM and system individually.

              Ansible might be a good use case here...

              1 Reply Last reply
              Reply Quote 0
              • D
                DustinB
                last edited by

                These two playbooks do what ya need, but change your ntp servers to match.

                cat /inventory/group_vars/all.yml 
                ---
                ntp_servers:
                  - 10.100.20.248 # <replace-with-your-ntp-sources>
                  - 10.100.20.249 # <replace-with-your-ntp-sources>
                
                cat playbooks/configure-ntp.yml 
                ---
                - name: Configure NTP via chrony on Linux targets
                  hosts: rocky
                  gather_facts: true
                
                  tasks:
                    - name: Install chrony package
                      ansible.builtin.dnf:
                        name: chrony
                        state: present
                
                    - name: Configure chrony NTP servers
                      ansible.builtin.copy:
                        dest: /etc/chrony.conf
                        owner: root
                        group: root
                        mode: "0644"
                        content: |
                          {% for server in ntp_servers %}
                          server {{ server }} iburst
                          {% endfor %}
                          driftfile /var/lib/chrony/drift
                          makestep 1.0 3
                          rtcsync
                      notify: Restart chronyd
                
                    - name: Ensure chronyd service is started and enabled
                      ansible.builtin.systemd:
                        name: chronyd
                        state: started
                        enabled: true
                
                  handlers:
                    - name: Restart chronyd
                      ansible.builtin.systemd:
                        name: chronyd
                        state: restarted
                
                - name: Configure NTP via w32time on Windows targets
                  hosts: windows
                  gather_facts: false
                
                  tasks:
                    - name: Ensure Windows Time service is running and automatic
                      ansible.windows.win_service:
                        name: w32time
                        state: started
                        start_mode: auto
                
                    - name: Configure w32time manual NTP peers
                      ansible.windows.win_shell: |
                        $peers = "{{ ntp_servers | join(' ') }}"
                        w32tm /config /manualpeerlist:"$peers" /syncfromflags:MANUAL /reliable:yes /update
                        Restart-Service w32time
                        w32tm /resync /rediscover
                      changed_when: true
                1 Reply Last reply
                Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post