2023.09.23
회사에서 업무를 하면서 궁금한게 생겼다. 도대체 Chrony가 무엇이길래 작업을 끝내고 확인을 하는 것일까?
이전에 IT로 직업을 전향하기 전에 공부를 했지만, Chrony에 대해서 배운적도, 들은적도 없었다.이런.. 부끄럽구만.. 이런 기본적인 것도 모르다니..!!
Chrony의 정의
간단하게 설명하자면 서버의 시간을 동기화시켜주는 서비스라고 생각하면 되겠다. 우리가 PC를 사용하면 보통 우측 하단에 보이는 날짜와 시간이 화면에 떠서 알 수 있다. 그건 이 PC의 시간동기화 서비스가 작동되서 그런것이다.
개인적으로 여기서 신기한 것은 시스템의 시간이 2가지라는 점이다. S/W 시간과 HW 시간이 있다.
시스템의 시간은 운영체제의 시간으로 보통 알고 있다. 시스템의 시간은 운영체제가 관리하는 S/W 시간과 메인보드가 관리하는 H/W시간으로 나누어 볼수 있다. 시스템을 재부팅하더라도 시간이 유지되는 것은 메인보드의 시간이 저장되어 있기 때문이다. 또한 하드웨어의 시간과 S/W의 시간은 특정 시점 동기화가 된 이후 자체적인 시간 타이머를 통해서 관리가 된다. 종종 시스템의 시간을 표준시로 설정을 하고 나면 조금씩 차이가 나는 경우가 있을수 있다. 그차이를 눈으로 확인하기는 어렵지만, 하루이상 지나면 조금씩 차이가 발생 하는 경우가 있다. 그 원인은 찾아본 사람만 알수 있는 부분이기 때문에 흔하게 경험해본 사람은 적을 것 같다.
Chrony를 이용한 시간 동기화 및 설정

환경 : VirtualBox
Local OS : Window
OS : CentOS7
보이는 것과 같이 내 PC에는 2023-09-23 07:42 로 시간이 설정되어 있지만, VirtualBox 의 서버는 2023-10-22 18:42로 시간이 설정되어 있다. 엄청난 시간차이를 보이고 있다. 실제 서비스를 운영중인 서버였다면 엄청난 사고로 이어진다.
Virtualbox 서버의 시간을 맞추기 위해 설정할 것이다.
(앞으로 Virtualbox에서 구동하고 있는 것을 서버라고 하겠다)
1. 시간확인
[user@localhost ~]$ timedatectl status
Local time: Fri 2023-09-22 18:58:49 EDT
Universal time: Fri 2023-09-22 22:58:49 UTC
RTC time: Fri 2023-09-22 22:58:49
**Time zone: America/New_York (EDT, -0400)**
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2023-03-12 01:59:59 EST
Sun 2023-03-12 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2023-11-05 01:59:59 EDT
Sun 2023-11-05 01:00:00 EST
시간설정을 보았을때 위에서 4번째 줄을 보면 서버의 타임존은 미국/뉴욕으로 되어있어서 한국과 전혀 다른 시간으로 설정된 것을알 수 있다.
2. 설정 변경
[user@localhost ~]$ timedatectl set-timezone Asia/Seoul
==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ===
Authentication is required to set the system timezone.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
아시아/서울로 설정을해서 시간을 바꿔준다
3. 변경 확인
[user@localhost ~]$ timedatectl status
Local time: Sat 2023-09-23 08:02:17 KST
Universal time: Fri 2023-09-22 23:02:17 UTC
RTC time: Fri 2023-09-22 23:02:17
Time zone: Asia/Seoul (KST, +0900)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[user@localhost ~]$ date
Sat Sep 23 08:02:21 KST 202
그리고 다시 확인해본 결과 Time Zone이 Aisa/Seoul로 변경된 것을 확인할 수 있다.
** 다른 방법 **
[user@localhost ~]$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 23
The following information has been given:
Korea (South)
Therefore TZ='Asia/Seoul' will be used.
Local time is now: Sat Sep 23 08:03:47 KST 2023.
Universal Time is now: Fri Sep 22 23:03:47 UTC 2023.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Asia/Seoul'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Seoul
혹은 다음과 같이 한단계씩 설정하는 방법도 있다.
참고
https://couplewith.tistory.com/320
(꿀팁) 리눅스 시스템 시간 동기화 하기 (Chrony,NTP )
(꿀팁) 리눅스 시스템 시간 동기화 하기 (Chrony,NTP ) #리눅스_시간동기화 NTP(Network Time Protocol) Chrony rdate -s hwclock -w 시스템의 시간은 운영체제의 시간으로 보통 알고 있다. 시스템의 시간은 운영체
couplewith.tistory.com
https://dejavuhyo.github.io/posts/chrony-time-synchronizing/
'Linux > CentOS' 카테고리의 다른 글
| [CentOS 7]netstate 명령어 (0) | 2023.09.24 |
|---|---|
| [CentOS 7]yum 및 ping 실행이 안될때 (NAT, NAT네트워크 설정) (0) | 2023.09.24 |
| [CentOS] free -g이란? (메모리 사용량 확인방법) (0) | 2023.09.24 |
| [CentOS]UPtime이란? (0) | 2023.09.24 |
| [Centos7]수동 IP 설정 (0) | 2023.09.19 |