OVH安装ESXi或者Proxmox后,使用Failover IP来创建VM

OVH的failover 使用在虚拟化的VM中比较多,比如说ESXi的VM或者Proxmox的VM

按照OVH的官方文档,在VM上配置failover IP时,可以使用如下的信息:

IP: 你想要使用的failover IP

netmask: 255.255.255.0

Gateway: 你的服务器的主IP的前三位,第四位是254

举个例子,如果你的服务器的主IP是91.34.67.123, 那么gateway 的IP就是91.34.67.254

这个写法是OVH官方推荐的,没有任何问题, 但是前提是VM已经创建好了可以这么配置. 

但是在实际使用的时候,就会出现了大问题. 这个问题主要是指,在安装centos或者debian, ubuntu的时候,我们一般都是用netinstall 的ISO来进行最小化安装.在安装的过程中,都是需要配置IP来访问网络下载组件的.

Linux系统,默认的情况下是不允许IP和gateway的IP不在一个网段的,这个规则的大部分情况下没有任何问题. 但是在OVH或者scaleway上,就会有问题. 因为你的OVH的服务器的主IP和你分配得到的failover 的IP往往不是一个网段的. 如果下下面的情况很常见:

比如说OVH服务器的主IP是54.23.66.78, 分配的failover IP是91.56.33.78。按照上面的例子,我们应该这样配置VM的IP:

IP: 91.56.33.78

netmask: 255.255.255.0

gateway IP: 54.23.66.254

但是在用netinstall ISO 进行系统安装的时候,系统会告诉你无法访问网络,因为IP 和gateway IP不在一个网段. 那么有没有解决办法呢?很简单,我们可以设置netmask为255.255.255.255, gateway的IP就是failover IP本身,这样也是可以访问网络的. 按照上面的例子,我们需要这样配置:

IP:91.56.33.78

netmask: 255.255.255.255

gateway ip: 91.56.33.78

这种办法是可以访问网络,但是请不要长期使用,因为OVH会封掉这种流量。因此建议在系统完成后,编辑IP配置,还是按照OVH的官方文档来.

 

OVH服务器的坑解析

无意中找到了一个OVH的老帐号,购买了一台服务器,订单很快就通过了.

OVH的服务器,其实价格并不便宜,而且还有不菲的初装费. 但是IP的价格便宜,每个IP只收3美金的初装费,每个月就不需要再另外付费了. 一台服务器最多可以添加255个IP.

OVH的网站上写着服务器都支持IPMI,我以为最起码都是supermicro的服务器呢。。后来才发现我想多了。。。

OVH的IPMI文档:

https://support.us.ovhcloud.com/hc/en-us/articles/360000108630-How-to-Install-an-OS-with-IPMI

其实这个文档里面已经透露出来OVH使用的是什么服务器了.

我买的是advance-2型号的服务器,打开IPMI我就傻眼了,并不是熟悉的Supermicro IPMI界面。。。而是ASRACK的主板

OVH的服务器主要使用两种主板,一个ASRACK的廉价主板,一个是supermicro的主板

购买之前一定要问好了是哪种服务器,supermicro要比asrock的好很多

但是实际使用过程中,我发现asrack 的IPMI要比supermicro 的稳定很多

OVH 使用的NVME SSD 都是WD的CL SN720,非常不错,算是企业级的SSD了

OVH的各站点的区别

从服务器的数量上来说,OVH应该是世界第一大IDC,一共有30个数据中心外加34个PoP

OVH的站点众多,很多人上来就会迷糊了。。。其实主要有以下区别:

  1. OVH的world主站,应该是OVH Canada在运营
  2. OVH US是一个单独的brand,由OVH US单独运营,和OVH world的账户不通用. OVH US 经常会有很好的sale和 best value 出现,因此注册一个OVH US 的账号还是很有必要的. OVH US的账号可以买OVH全球的服务器,除了亚洲dd(新加坡和悉尼)
  3. OVH.ie, 国人最喜欢的欧洲站点,好搞免税
  4. OVH.com/fr, OVH的大本营,经常会有很好的sale出现,但是是法语

 

Hostloc上很多人喜欢去注册ovh.ie然后搞免税. 如果没有任何sale的话,全球任何一个站点,不论是美元计费还是欧元计费,基本价格都是一样的. 所以正常购买的话,直接买world站的服务器就好了,还不需要搞免税. 但是可能会需要验证身份, 这个对于正规做网站的公司和个人来说没有什么影响.

OVH的欧洲账户直接购买就可以了,不需要验证账户。但是默认都有VAT的存在,需要提交身份认证搞免税. 其实我个人觉得不如在world主站买就好了.

Quadranet 服务器benchmark

看到hostloc, quadranet的官方发布了一个sale,最近正好缺多IP的服务器,于是就订了一台跑一些服务。下面先做一些基本的benchmark,然后就要安装ESXi了

使用的程序:

wget -qO- bench.sh | bash

下面是结果:

----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz
Number of cores : 8
CPU frequency : 799.890 MHz
Total size of Disk : 278.0 GB (1.7 GB Used)
Total amount of Mem : 15834 MB (232 MB Used)
Total amount of Swap : 2047 MB (0 MB Used)
System uptime : 0 days, 6 hour 45 min
Load average : 0.04, 0.04, 0.05
OS : CentOS 7.7.1908
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-1062.12.1.el7.x86_64
----------------------------------------------------------------------
I/O speed(1st run) : 316 MB/s
I/O speed(2nd run) : 317 MB/s
I/O speed(3rd run) : 318 MB/s
Average I/O speed : 317.0 MB/s

—————

用的是老款的intel s3500, 速度勉强可以吧,基本保持在321MB/s左右

检查一下硬盘信息:

[root@lax ~]# smartctl -a /dev/sda
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.12.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Intel 730 and DC S35x0/3610/3700 Series SSDs
Device Model: INTEL SSDSC2BB300G4
Serial Number: BTWL40210787300PGN
LU WWN Device Id: 5 5cd2e4 04b56befb
Firmware Version: D2010370
User Capacity: 300,069,052,416 bytes [300 GB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2 T13/2015-D revision 3
SATA Version is: SATA 2.6, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon Feb 24 19:41:04 2020 PST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x79) SMART execute Offline immediate.
No Auto Offline data collection support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 2) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0032 100 100 000 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 34840
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 37
170 Available_Reservd_Space 0x0033 100 100 010 Pre-fail Always - 0
171 Program_Fail_Count 0x0032 100 100 000 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 000 Old_age Always - 0
174 Unsafe_Shutdown_Count 0x0032 100 100 000 Old_age Always - 35
175 Power_Loss_Cap_Test 0x0033 100 100 010 Pre-fail Always - 637 (204 414)
183 SATA_Downshift_Count 0x0032 100 100 000 Old_age Always - 2
184 End-to-End_Error 0x0033 100 100 090 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Temperature_Case 0x0022 081 081 000 Old_age Always - 19 (Min/Max 17/20)
192 Unsafe_Shutdown_Count 0x0032 100 100 000 Old_age Always - 35
194 Temperature_Internal 0x0022 100 100 000 Old_age Always - 28
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
199 CRC_Error_Count 0x003e 100 100 000 Old_age Always - 4
225 Host_Writes_32MiB 0x0032 100 100 000 Old_age Always - 61519
226 Workld_Media_Wear_Indic 0x0032 100 100 000 Old_age Always - 911
227 Workld_Host_Reads_Perc 0x0032 100 100 000 Old_age Always - 84
228 Workload_Minutes 0x0032 100 100 000 Old_age Always - 2090316
232 Available_Reservd_Space 0x0033 100 100 010 Pre-fail Always - 0
233 Media_Wearout_Indicator 0x0032 100 100 000 Old_age Always - 0
234 Thermal_Throttle 0x0032 100 100 000 Old_age Always - 0/0
241 Host_Writes_32MiB 0x0032 100 100 000 Old_age Always - 61519
242 Host_Reads_32MiB 0x0032 100 100 000 Old_age Always - 341415

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

再看看sdb:

[root@lax ~]# smartctl -a /dev/sdb
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.12.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Intel 730 and DC S35x0/3610/3700 Series SSDs
Device Model: INTEL SSDSC2BB300G4
Serial Number: BTWL347206YW300PGN
LU WWN Device Id: 5 5cd2e4 04b53fc0e
Firmware Version: D2010370
User Capacity: 300,069,052,416 bytes [300 GB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2 T13/2015-D revision 3
SATA Version is: SATA 2.6, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon Feb 24 19:43:51 2020 PST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x79) SMART execute Offline immediate.
No Auto Offline data collection support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 2) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0032 100 100 000 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 39582
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 59
170 Available_Reservd_Space 0x0033 100 100 010 Pre-fail Always - 0
171 Program_Fail_Count 0x0032 100 100 000 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 000 Old_age Always - 0
174 Unsafe_Shutdown_Count 0x0032 100 100 000 Old_age Always - 57
175 Power_Loss_Cap_Test 0x0033 100 100 010 Pre-fail Always - 629 (226 417)
183 SATA_Downshift_Count 0x0032 100 100 000 Old_age Always - 0
184 End-to-End_Error 0x0033 100 100 090 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Temperature_Case 0x0022 083 083 000 Old_age Always - 17 (Min/Max 16/17)
192 Unsafe_Shutdown_Count 0x0032 100 100 000 Old_age Always - 57
194 Temperature_Internal 0x0022 100 100 000 Old_age Always - 26
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
199 CRC_Error_Count 0x003e 100 100 000 Old_age Always - 0
225 Host_Writes_32MiB 0x0032 100 100 000 Old_age Always - 4055029
226 Workld_Media_Wear_Indic 0x0032 100 100 000 Old_age Always - 16179
227 Workld_Host_Reads_Perc 0x0032 100 100 000 Old_age Always - 21
228 Workload_Minutes 0x0032 100 100 000 Old_age Always - 2374838
232 Available_Reservd_Space 0x0033 100 100 010 Pre-fail Always - 0
233 Media_Wearout_Indicator 0x0032 085 085 000 Old_age Always - 0
234 Thermal_Throttle 0x0032 100 100 000 Old_age Always - 0/0
241 Host_Writes_32MiB 0x0032 100 100 000 Old_age Always - 4055029
242 Host_Reads_32MiB 0x0032 100 100 000 Old_age Always - 1091089

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

/dev/sdb的media_wearout_indicator 是85,而非100,表明这个 ssd 硬盘已经开始downgraded

给quadranet 发了ticket 要求更换,等等看吧

经过好几天的communication,QN最后终于换了一个新的SSD给我,并且升级到了1TB SSD.

[root@lax ~]# smartctl -a /dev/sda
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.12.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Crucial/Micron BX/MX1/2/3/500, M5/600, 1100 SSDs
Device Model: CT1000MX500SSD1
Serial Number: 1949E22DBD7F
LU WWN Device Id: 5 00a075 1e22dbd7f
Firmware Version: M3CR023
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-3 T13/2161-D revision 5
SATA Version is: SATA 3.3, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Thu Feb 27 17:48:28 2020 PST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x80) Offline data collection activity
was never started.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 30) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x0031) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 100 100 000 Pre-fail Always - 0
5 Reallocate_NAND_Blk_Cnt 0x0032 100 100 010 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 8
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 3
171 Program_Fail_Count 0x0032 100 100 000 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 000 Old_age Always - 0
173 Ave_Block-Erase_Count 0x0032 100 100 000 Old_age Always - 0
174 Unexpect_Power_Loss_Ct 0x0032 100 100 000 Old_age Always - 1
180 Unused_Reserve_NAND_Blk 0x0033 000 000 000 Pre-fail Always - 47
183 SATA_Interfac_Downshift 0x0032 100 100 000 Old_age Always - 0
184 Error_Correction_Count 0x0032 100 100 000 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
194 Temperature_Celsius 0x0022 067 066 000 Old_age Always - 33 (Min/Max 0/34)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 100 100 000 Old_age Always - 0
202 Percent_Lifetime_Remain 0x0030 100 100 001 Old_age Offline - 0
206 Write_Error_Rate 0x000e 100 100 000 Old_age Always - 0
210 Success_RAIN_Recov_Cnt 0x0032 100 100 000 Old_age Always - 0
246 Total_Host_Sector_Write 0x0032 100 100 000 Old_age Always - 7136328
247 Host_Program_Page_Count 0x0032 100 100 000 Old_age Always - 128446
248 FTL_Program_Page_Count 0x0032 100 100 000 Old_age Always - 626

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Completed [00% left] (0-65535)
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

 

但是分区记录表很奇怪,我这里记录一下:

[root@lax ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: CC49A639-0ABB-4FC8-9CE4-9CB5D28B7ED7


# Start End Size Type Name
1 2048 4095 1M BIOS boot
2 4096 2101247 1G Microsoft basic
3 2101248 6295551 2G Microsoft basic
4 6295552 10489855 2G Linux swap
5 10489856 1953523711 926.5G Microsoft basic

Nginx Websocket 配置

Nginx 支持websocket,可以用下面的example:

location / { 
       proxy_redirect off;
       proxy_pass http://127.0.0.1:26534; 
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header Host $http_host;
}

26534表示任意端口

Krypt iON Benchmark

从hostloc 坛友那里收的, 20.19刀那一款,双向CN2 GIA,还是很不错的,做一个benchmark记录一下.

使用的程序:

wget -qO- bench.sh | bash

下面是结果:

----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
Number of cores : 1
CPU frequency : 2499.996 MHz
Total size of Disk : 39.0 GB (4.7 GB Used)
Total amount of Mem : 1837 MB (365 MB Used)
Total amount of Swap : 1023 MB (1 MB Used)
System uptime : 43 days, 20 hour 23 min
Load average : 0.30, 0.08, 0.07
OS : CentOS 7.7.1908
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-1062.9.1.el7.x86_64
----------------------------------------------------------------------
I/O speed(1st run) : 632 MB/s
I/O speed(2nd run) : 669 MB/s
I/O speed(3rd run) : 553 MB/s
Average I/O speed : 618.0 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 66.1MB/s
Linode, Tokyo2, JP 139.162.65.37 21.6MB/s
Linode, Singapore, SG 139.162.23.4 13.3MB/s
Linode, London, UK 176.58.107.39 16.9MB/s
Linode, Frankfurt, DE 139.162.130.8 15.8MB/s
Linode, Fremont, CA 50.116.14.9 90.9MB/s
Softlayer, Dallas, TX 173.192.68.18 61.6MB/s
Softlayer, Seattle, WA 67.228.112.250 60.3MB/s
Softlayer, Frankfurt, DE 159.122.69.4 11.3MB/s
Softlayer, Singapore, SG 119.81.28.170 10.1MB/s
Softlayer, HongKong, CN 119.81.130.170 12.3MB/s
----------------------------------------------------------------------

 

阿里云ECS的坑 – 系统硬件时间

用了这么久 的阿里云ecs,也是今天无意间才发现的,更准确的说应该是centos 7的坑,在centos 6上那样直接修改时区的办法不行了

1)拿到了阿里云的ecs,第一件事就是应该修改系统的hwclock,这是因为阿里云的ecs默认使用的是hwclock 是cst,也就是中国时区。这个可以是可以,但是国际上通用的办法是使用UTC时间,这更能避免很多问题:

timedatectl set-local-rtc 0

2) 第二个坑就是因为有了第一个问题以后,在centos 6上我经常使用下面的办法修改时区(个人习惯,所有的服务器都是UTC或者EST时区):

cp /usr/share/zoneinfo/America/New_York /etc/localtime

在centos 7上我也继续这么使用,在国外的服务器上没有一点问题,但是在阿里云ecs上就会出现下面的情况:

[root@sz ~]# timedatectl
Local time: Wed 2020-01-29 07:57:08 EST
Universal time: Wed 2020-01-29 12:57:08 UTC
RTC time: Wed 2020-01-29 20:57:07
Time zone: Asia/Shanghai (EST, -0500)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: no
Last DST change: DST ended at
Sun 2019-11-03 01:59:59 EDT
Sun 2019-11-03 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2020-03-08 01:59:59 EST
Sun 2020-03-08 03:00:00 EDT

Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.

重点是timezone 那一行, Asia/Shanghai 变成了EST了,明显不对, 我们需要用下面的命令修改一下:

timedatectl set-timezone "America/New_York"

重启以后,系统的各种时间才会恢复正常.

为什么要这么做?因为如果你不这么做,系统的时间和mysql 的时间会发生冲突,当你需要重启mysql服务的时候,就会出现:

InnoDB: Waiting for page_cleaner to finish flushing of buffer pool

让你需要最起码5分钟以上才能完全重启mysql服务或者重启服务器。。。

下午遇到了问题,一台新装的ecs服务器需要最少5分钟才能重启。。。刚开始以为是smokeping 重启过慢,仔细debug了开机启动,发现是关机速度太慢。。。然后看log 发现是mysql shutdown 时间太长,InnoDB需要清空buffer。。。再继续debug才发现这是系统时间的问题。。。

浪费了整整一下午。。。

Ubuntu Server安装图形桌面并且开启远程RDP访问

近期有项目需要使用图形桌面来完成,windows server肯定是最好的选择,但是昂贵的授权费用以及不低的硬件配置,让我想到了Ubuntu. Linux 系主要使用centos,debian系虽然也在用,但是确实不熟悉,因此debug确实耗费了不少时间.

主要步骤:

  1. 安装ubuntu 18.04 x64,这个没有什么,直接在你的云服务商上选择就可以了
  2. 安装updates
      apt update
      apt upgrade

3. 安装图形桌面

       apt install ubuntu-desktop

这里不建议使用tasksel来安装,过于复杂,安装时间太长,而且安装了很多没有必要的东西,对于配置低的cloud来说浪费资源,而且tasksel默认安装了很多和xrdp冲突的组件, 我对ubuntu不熟悉,实在没有办法修改

4. 安装xrdp

需要注意的是,ubuntu repo里面的xrdp 的版本有问题,参见这里:

http://c-nergy.be/blog/?p=13390

所以正确步骤是:

apt install xserver-xorg-core
apt install xserver-xorg-input-all
apt install xorgxrdp
apt install xrdp

5. 创建用户远程登录, 这点是和centos不一样的地方,centos 的root 可以干很多事情,debian系的root虽然权限最大,但是很多功能都被锁定了,debian 系推荐的办法是创建一个新的用户,在需要root权限的时候,用sudo提权。假如我们要创建的用户名是ccc,那么步骤是:

adduser ccc(中间会提示你设置密码)
usermod -aG sudo ccc (将ccc加入sudo group, 这样ccc就可以用sudo提权)

 

然后我们就可以用windows的RDP远程登录这台ubuntu服务器了

默认的情况下,这个GUI只有最基本的程序,大部分经常使用的app需要安装,最好是通过command line来安装,比如说安装firefox

apt install firefox

 

 

 

国行三星S8+ 打开wifi calling

刚把我的美国电话号码port到google fi了,本来把fi 的sim 卡插到了iPhone 上,但是没有想到Google Fi 不支持在iPhone上使用wifi calling。

对Google Fi 的wifi calling 支持最好的是他们自家卖的手机, designed for google fi系列,基本都是pixel,水果机支持google fi,但是不支持wifi calling. 三星的机器支持google fi, 也支持wifi calling,想起来了我还有个国行三星s8 plus,但是按照国内手机的尿性,不知道会不会阉割wifi calling。

今天早上和google fi 的客服聊了一个小时,确认国行三星s8 plus, model number 是SM-G9550, 支持google fi 的wifi calling,但是一般来说国行会缺少某些组件. 几个关键点:

  1. 你的登录google fi 的google play账号必须是美国,任何其他国家的都不行,就是这个原因,debug了整整一个早上
  2. Google Fi 的wifi calling 只支持安卓,在安卓手机上必须安装Google Fi应用,并且在里面打开wifi calling. Wifi Calling 在”Phone Setting”里面.
  3. 你的手机里必须安装有google fi,carrier service, google play services, google connectivity services,hangouts, 并且全部权限都打开, “Background data” 和”Unrestricted data usage” 也必须打开. 国行的手机可能没有carrier service,必须得从google play上下载,如果这样的话,google connectivity services就不需要安装了
  4. 安卓手机必须打开wifi calling选项,路径为”Open the Phone app > tap More (three dots icon) > Settings > Calls > Wi-Fi calling”

Linux 的 stdin, stdout 以及stderr

今天终于有时间来仔细看下stdin,stdout和stderr了

标准输入重定向(STDIN,文件描述符为 0):默认从键盘输入,也可从其他文件或命令中输入。
标准输出重定向(STDOUT,文件描述符为 1):默认输出到屏幕。
错误输出重定向(STDERR,文件描述符为 2):默认输出到屏幕。

“stdout”按理来说应该表示为”1>”, 我们可以默认的写成”>”, 重定向stderr可以用”2>”来表示

./error.sh 2> capture.txt

表示把错误信息重定向到capture.txt

./error.sh 1> capture.txt 2> error.txt

表示把标准输出定向到capture.txt, 把错误定向到error.txt

./error.sh > capture.txt 2&>1

capture.txt 表示标准输出重定向到capture.txt,  2>&1, 表示“redirect stream 2, stderr, to the same destination that stream 1, stdout, is being redirected to”

总结一下:

输入重定向:
命令 < 文件 将文件作为命令的标准输入
命令 << 分隔符 从标准输入中读入,直到遇见分隔符才停止
命令 < A1 > A2 将文件A1作为命令的标准输入并将标准输出到文件A2

 

命令 > 文件 将标准输出重定向到一个文件中(清空原有文件的数据)
命令 2> 文件 将错误输出重定向到一个文件中(清空原有文件的数据)
命令 >> 文件 将标准输出重定向到一个文件中(追加到原有内容的后面)
命令 2>> 文件 将错误输出重定向到一个文件中(追加到原有内容的后面)
命令 >> 文件 2>&1 或 命令 &>> 文件 将标准输出与错误输出共同写入到文件中(追加到原有内容的后面)

askubuntu.com上面有个老外写了一个解释,非常的好记:

List:
command > output.txt
The standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.

command >> output.txt
The standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

command 2> output.txt
The standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.

command 2>> output.txt
The standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

command &> output.txt
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, it gets overwritten.

command &>> output.txt
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, the new data will get appended to the end of the file..

command | tee output.txt
The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, it gets overwritten.

command | tee -a output.txt
The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

(*)
Bash has no shorthand syntax that allows piping only StdErr to a second command, which would be needed here in combination with tee again to complete the table. If you really need something like that, please look at "How to pipe stderr, and not stdout?" on Stack Overflow for some ways how this can be done e.g. by swapping streams or using process substitution.

command |& tee output.txt
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, it gets overwritten.

command |& tee -a output.txt
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, the new data will get appended to the end of the file.