Thursday, 9 February 2012

Changing System Time From Container

Normally it is impossible to change the system time from a Container. Otherwise, different Containers could interfere with each other and could even break applications depending on the system time accuracy.

Normally only the Hardware Node system administrator can change the system time. However, if you want to synchronize the time via Network Time Protocol (NTP), you have to run NTP software, which will connect to external NTP servers and update the system time. It is not advisable to run application software on the Hardware Node itself, since flaws in the software can lead to compromising all Containers on the Hardware Node. Thus, if you plan to use NTP, you shall create a special Container for it and configure it to have the sys_time capability. The example below illustrates configuring such a Container:
# vzctl set 101 --capability sys_time:on --save

Unable to set capability on running Container

Saved parameters for Container 101

The output of the above command warns you that vzctl cannot apply changes in the capabilities to a running Container. The Container has to be restarted before changes take effect:

# vzctl stop 101; vzctl start 101

Stopping Container ...

Container was stopped

Container is unmounted

Starting Container ...

Container is mounted

Adding IP address(es): 192.168.1.101

Hostname for Container set: Container101

Container start in progress...

# ssh root@ct101

root@ct101's password:

Last login: Mon Feb 06 23:25:58 2012  from 10.100.10.10

[root@ct101 root]# date

Thu Feb  9 12:13:33 GMT 2012

[root@ct101 root]# date 10291300

Thu Feb  9 12:13:33 GMT 2012

[root@ct101 root]# date

Thu Feb  9 12:13:33 GMT 2012

[root@ct101 root]# logout

Connection to Container101 closed.

# date

Thu Feb  9 12:13:33 GMT 2012

The command session above shows the way to change the system time from Container 101. The changes will affect all the Containers and the Hardware Node itself. It is not advisable to have more than one Container with the sys_time capability set on.

No comments:

Post a Comment