In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the method of setting Linux instance time zone and NTP service, which is very detailed and has certain reference value. Friends who are interested must read it!
Time setting: setting Linux instance time zone and NTP service
The synchronization of time zone and time is very important for CVM (for example, when you update the database, the accuracy of time will have a great impact on your business). To avoid confusion in business logic running on instances and network request errors, you need to set one or more instances under the same time zone, such as Asia/Shanghai or America/Los Angeles. Currently, the default time zone for Ali Cloud ECS instances in all regions is CST (China Standard Time). You can set or modify the time zone for ECS instances according to your business needs and refer to this document. In addition, the NTP (Network Time Protocol) service can ensure that the ECS time of your CVM is synchronized with the standard time. You can configure the NTP service according to this article.
Modify ECS instance time zone
Here we take Centos 6.5 as an example to list how to modify the time zone by modifying the configuration file:
Note: after changing the time zone, keep in mind that you need to run hwclock-w to update the instance hardware clock.
You need to open and edit the time zone configuration file as root, so use the sudo command here.
Remotely connect to the Linux instance.
Execute the command sudo rm / etc/localtime to delete the local time link in the system.
Execute the command sudo vi / etc/sysconfig/clock to open and edit the configuration file / etc/sysconfig/clock with vim.
Enter I to add a time zone city, for example, add Zone=Asia/Shanghai, press ESC to exit editing and enter: wq to save and exit.
The command ls / usr/share/zoneinfo can be executed to query the list of time zones, and Shanghai is one of the list entries.
Execute the command sudo ln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime to update the time zone modification.
Execute the command hwclock-w to update the hardware clock (RTC).
Execute the command sudo reboot to restart the instance.
Execute the command date-R to check whether the time zone information is valid. If it is not in effect, you can repeat the steps.
Set up the NTP server
In Linux system, there are two ways to realize NTP time synchronization: ntpd and ntpdate, in which ntpd synchronization time is a step-by-step gradual adjustment time and ntpdate is a breakpoint update. Newly purchased instances can use ntpdate update service. It is recommended to use ntpd synchronization time for instances that are already running business. Standard NTP service configuration and custom NTP service configuration are provided here, which you can configure selectively as needed. For more information about NTP services, please refer to the intranet and public NTP servers.
prerequisite
The communication port for the NTP service is UDP 123.Please make sure that you have opened the UDP port 123before setting up the NTP service. You can check whether UDP port 123 is enabled in the instance via netstat-nupl. You can refer to the documentation to add security group rules to release UDP port 123.
Enable standard NTP services
Remotely connect to the Linux instance.
Execute the command sudo service ntpd start to run the NTP service.
Execute the command chkconfig ntpd on to enable the NTP service.
Execute the command ntpstat to see if the NTP service is enabled.
(optional) execute the command ntpq-p to view the list information of the peer of the NTP service, and execute the command sudo chkconfig-- list ntpd to view the running level of the NTP service.
Configure a custom NTP service
Remotely connect to the Linux instance.
Execute the command sudo vi / etc/ntp.conf to open and edit the NTP service configuration file with vim.
After finding the information about the server ntp server iburst, type I to start editing the file, adding # to the beginning of the NTP server sentence that you don't need for the time being.
Add a new line of NTP server information in the format: server the NTP server iburst you need to add. When you are finished editing, press Esc and enter: wq to save exit.
Execute the command sudo service ntpd start to enable the custom NTP service.
Execute the command chkconfig ntpd on to enable the NTP service.
Execute the command ntpstat to see if the NTP service is enabled.
If the problem is not solved, you can go to Aliyun Community for free consultation, or contact the cloud market merchant for help.
The above is all the contents of the method of setting the Linux instance time zone and NTP service. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.