Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 3 章 Huawei Cloud Service

目录

3.1. Flexus 云服务器
3.1.1. AlmaLinux 9 镜像初始化
3.1.2. Flexus 服务器 BUG
3.2. Flexus RDS
3.2.1. 迁移阿里云RDS至华为云RDS
3.3. Huawei Cloud EulerOS
3.3.1. DNS 配置
3.3.2. Python 环境
3.4. Ubuntu
3.4.1. Nvidia 驱动
3.4.2. Python 环境

3.1. Flexus 云服务器

3.1.1. AlmaLinux 9 镜像初始化

3.1.1.1. 配置域名服务器

默认域名服务器无法解析外部域名

			
[root@production ~]# ping www.netkiller.cn
ping: www.netkiller.cn: Name or service not known			
			
				

100.79.1.250 内部域名服务器

				
[root@production ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search openstacklocal
nameserver 100.79.1.250
options timeout:1 single-request-reopen				
				
				

添加域名服务器

				
[root@production ~]# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
				
[root@production ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search openstacklocal
nameserver 100.79.1.250
options timeout:1 single-request-reopen
nameserver  8.8.8.8				
				
				

测试域名解析是否正常

				
[root@production ~]# ping www.netkiller.cn
PING netkiller.github.io (185.199.111.153) 56(84) bytes of data.
^C64 bytes from 185.199.111.153: icmp_seq=4 ttl=48 time=124 ms

--- netkiller.github.io ping statistics ---
4 packets transmitted, 1 received, 75% packet loss, time 3058ms
rtt min/avg/max/mdev = 124.042/124.042/124.042/0.000 ms				
				
				

3.1.1.2. 员常用工具

管理员常用工具

			
dnf install -y bzip2 tree psmisc \
telnet wget rsync vim-enhanced \
net-tools bind-utils			
			
				

3.1.1.3. OpenJDK 17

				
[root@testing ~]# dnf install -y java-17-openjdk maven-openjdk17				
				
				

3.1.2. Flexus 服务器 BUG

故障描述,今日服务器,突然有个功能不能用了,经过艰辛排查发现是时间戳计算出错。服务器时间比本地时间快了6分钟

			
neo@Mac-mini-M4 ~/netkiller (master)> date
2024年11月13日 星期三 10时32分52秒 CST			
			
			

服务器时间快了6分钟

			
[root@testing ~]# date
Wed Nov 13 10:38:59 AM CST 2024			
			
			

检查时间同步进程 chronyd 正常

			
[root@testing ~]# systemctl status chronyd
● chronyd.service - NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-10-02 08:34:26 CST; 1 month 11 days ago
       Docs: man:chronyd(8)
             man:chrony.conf(5)
   Main PID: 690 (chronyd)
      Tasks: 1 (limit: 100479)
     Memory: 3.3M
        CPU: 543ms
     CGroup: /system.slice/chronyd.service
             └─690 /usr/sbin/chronyd -F 2			
			
			

查看配置文件,发现少了 pool 配置

			
[root@testing ~]# cat /etc/chrony.
chrony.conf  chrony.keys

[root@testing ~]# cat /etc/chrony.conf 

server ntp.myhuaweicloud.com minpoll 4 maxpoll 10 iburst

# Ignore stratum in source selection.
stratumweight 0.05

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Allow NTP client access from local network.
#allow 192.168/16

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# Serve time even if not synchronized to any NTP server.
#local stratum 10

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

logdir /var/log/chrony
#log measurements statistics tracking			
			
			

检查时间同步服务器源,返回空数据

			
[root@testing ~]# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================			

[root@testing ~]# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
			
			

检查时间同步状态,返回空数据

			
[root@testing ~]# chronyc sourcestats -v
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================			
			
			

检查NTP设置,正常

			
[root@testing ~]# timedatectl show
Timezone=Asia/Shanghai
LocalRTC=no
CanNTP=yes
NTP=yes
NTPSynchronized=no
TimeUSec=Wed 2024-11-13 10:43:38 CST
RTCTimeUSec=Wed 2024-11-13 10:37:22 CST	

[root@testing ~]# timedatectl status
               Local time: Wed 2024-11-13 10:43:56 CST
           Universal time: Wed 2024-11-13 02:43:56 UTC
                 RTC time: Wed 2024-11-13 02:37:40
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
			
			

如果 NTP=no 使用下面命令开启 NTP

			
timedatectl set-ntp yes
			
			

解决方案,添加 pool 配置到

			
[root@testing ~]# cat /etc/chrony.conf 

server ntp.myhuaweicloud.com minpoll 4 maxpoll 10 iburst

# Ignore stratum in source selection.
stratumweight 0.05

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Allow NTP client access from local network.
#allow 192.168/16

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# Serve time even if not synchronized to any NTP server.
#local stratum 10

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

logdir /var/log/chrony
#log measurements statistics tracking

pool ntp1.aliyun.com iburst
pool ntp.tencent.com iburst
pool ntp1.bce.baidu.com iburst			
			
			

重启 chronyd 服务

			
[root@testing ~]# systemctl restart  chronyd  			

[root@testing ~]# systemctl status  chronyd
● chronyd.service - NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-11-13 10:55:09 CST; 19s left
       Docs: man:chronyd(8)
             man:chrony.conf(5)
    Process: 392965 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 392968 (chronyd)
      Tasks: 1 (limit: 100479)
     Memory: 1.3M
        CPU: 58ms
     CGroup: /system.slice/chronyd.service
             └─392968 /usr/sbin/chronyd -F 2

Nov 13 10:55:09 testing chronyd[392968]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG)
Nov 13 10:55:09 testing chronyd[392968]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift
Nov 13 10:55:09 testing chronyd[392968]: Loaded seccomp filter (level 2)
Nov 13 10:55:09 testing systemd[1]: Started NTP client/server.
Nov 13 10:55:20 testing chronyd[392968]: Selected source 106.55.184.199 (ntp.tencent.com)
Nov 13 10:55:20 testing chronyd[392968]: System clock wrong by -375.557443 seconds
Nov 13 10:49:04 testing chronyd[392968]: System clock was stepped by -375.557443 seconds
Nov 13 10:49:06 testing chronyd[392968]: Selected source 120.25.115.20 (ntp1.aliyun.com)
Nov 13 10:51:18 testing chronyd[392968]: Selected source 106.55.184.199 (ntp.tencent.com)
Nov 13 10:54:31 testing chronyd[392968]: Selected source 120.25.115.20 (ntp1.aliyun.com)
			
			

再次查看 pool 服务器

			
[root@testing ~]# chronyc sources 
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? 120.25.115.20                 0   6     0     -     +0ns[   +0ns] +/-    0ns
^? 106.55.184.199                2   6     1     0  +375.6s[+375.6s] +/-   22ms

[root@testing ~]# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 120.25.115.20                 2   6   245    71   -326us[ -776us] +/- 5099us
^- 106.55.184.199                2   6   173    10  +1630us[+1630us] +/-   29ms

[root@testing ~]# chronyc sourcestats -v
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
120.25.115.20               6   6   334     -0.085     13.288  -7613ns   401us
106.55.184.199              9   4   396    +16.456     38.482  +2761us  2680us
			
			

有服务器返回,正常

			
[root@testing ~]# chronyc tracking
Reference ID    : 78197314 (120.25.115.20)
Stratum         : 3
Ref time (UTC)  : Wed Nov 13 02:54:34 2024
System time     : 0.000003450 seconds fast of NTP time
Last offset     : -0.000449605 seconds
RMS offset      : 0.011590191 seconds
Frequency       : 101.751 ppm fast
Residual freq   : -0.085 ppm
Skew            : 14.673 ppm
Root delay      : 0.008122038 seconds
Root dispersion : 0.003573609 seconds
Update interval : 3.0 seconds
Leap status     : Normal			
			
			

Leap status : Normal 状态正常

			
[root@testing ~]# timedatectl show
Timezone=Asia/Shanghai
LocalRTC=no
CanNTP=yes
NTP=yes
NTPSynchronized=yes
TimeUSec=Wed 2024-11-13 10:57:21 CST
RTCTimeUSec=Wed 2024-11-13 10:57:21 CST			
			
			

NTPSynchronized=yes 表示同步成功

现在,查看时间,同步正常,问题彻底解决。