[20191118]確定linux伺服器cpu數量.txt
[20191118]確定linux伺服器cpu數量.txt
--//連結http://www.itpub.net/thread-2121531-1-1.html上的討論.
--//當時看到dbwN很多,猜測CPU數量一定很多。
--//我記憶裡第一次見到一臺compaq伺服器N年之前,當時是開蓋狀態,開機那個噪聲讓我至今難忘。
--//想起我工作中一次難堪,20113年單位要對每臺伺服器登記存檔,因為伺服器很多,每個人負責一部分。
--//資料庫伺服器當然資料庫組負責。當時我一直以為cpu數量就是2,4,8,16,32數量。
--//當我檢查才發現,其中一臺伺服器CPU數量是24,當時的感覺自己是不是看錯了。
--//總結一下如何確定linux伺服器cpu數量的方法。
1.檢查/proc/cpuinfo:
# cat /proc/cpuinfo | grep -i processor|wc -l
24
# cat /proc/cpuinfo | grep -i cores| uniq
cpu cores : 6
# grep '^core id' /proc/cpuinfo | sort -u
core id : 0
core id : 1
core id : 2
core id : 3
core id : 4
core id : 5
--//邏輯cpu數量是24,6個core.
--//實際上2個物理CPU,每個CPU有6個core,開啟超執行緒就是24個邏輯cpu.
2.使用dmicode:
# dmidecode -t 4
# dmidecode 2.11
SMBIOS 2.8 present.
# SMBIOS implementations newer than version 2.7 are not
# fully supported by this version of dmidecode.
Handle 0x0400, DMI type 4, 42 bytes
Processor Information
Socket Designation: Proc 1
Type: Central Processor
Family: Xeon
Manufacturer: Intel
ID: E4 06 03 00 FF FB EB BF
Signature: Type 0, Family 6, Model 62, Stepping 4
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
DS (Debug store)
ACPI (ACPI supported)
MMX (MMX technology supported)
FXSR (FXSAVE and FXSTOR instructions supported)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
SS (Self-snoop)
HTT (Multi-threading)
TM (Thermal monitor supported)
PBE (Pending break enabled)
Version: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz
Voltage: 1.4 V
External Clock: 100 MHz
Max Speed: 4800 MHz
Current Speed: 2600 MHz
Status: Populated, Enabled
Upgrade: <OUT OF SPEC>
L1 Cache Handle: 0x0710
L2 Cache Handle: 0x0720
L3 Cache Handle: 0x0730
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Core Count: 6
Core Enabled: 6
Thread Count: 12
Characteristics:
64-bit capable
Handle 0x0401, DMI type 4, 42 bytes
Processor Information
Socket Designation: Proc 2
Type: Central Processor
Family: Xeon
Manufacturer: Intel
ID: E4 06 03 00 FF FB EB BF
Signature: Type 0, Family 6, Model 62, Stepping 4
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
DS (Debug store)
ACPI (ACPI supported)
MMX (MMX technology supported)
FXSR (FXSAVE and FXSTOR instructions supported)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
SS (Self-snoop)
HTT (Multi-threading)
TM (Thermal monitor supported)
PBE (Pending break enabled)
Version: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz
Voltage: 1.4 V
External Clock: 100 MHz
Max Speed: 4800 MHz
Current Speed: 2600 MHz
Status: Populated, Idle
Upgrade: <OUT OF SPEC>
L1 Cache Handle: 0x0716
L2 Cache Handle: 0x0726
L3 Cache Handle: 0x0736
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Core Count: 6
~~~~~~~~~~~~~~~
Core Enabled: 6
~~~~~~~~~~~~~~~~
Thread Count: 12
~~~~~~~~~~~~~~~~~
Characteristics:
64-bit capable
--//注意看下劃線.
# getconf _NPROCESSORS_ONLN
24
3.使用lscpu:
--//我的測試環境沒有安裝,找另外一臺機器觀察:
# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 8
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 79
Model name: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
Stepping: 1
CPU MHz: 2096.494
BogoMIPS: 4195.14
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse
sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc eagerfpu
pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand
hypervisor lahf_lm abm 3dnowprefetch arat invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm
rdseed adx smap xsaveopt
--//感覺lscpu顯示更加直觀一些.
# cat /proc/cpuinfo | grep -i processor|wc -l
8
# cat /proc/cpuinfo | grep -i cores| uniq
cpu cores : 1
--//不知道是否這臺機器沒有開啟超執行緒.
4.補充一些其它cpu相關知識:
--//taskset - retrieve or set a processes's CPU affinity
# ps -ef | grep tnslsn[r]
oracle 22995 1 0 Nov11 ? 00:00:15 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
# taskset -p 22995
pid 22995's current affinity mask: ffffff
--//f 表示二進位制 1111.就是可以在24個cpu資源.
# taskset -p ff 22995
pid 22995's current affinity mask: ffffff
pid 22995's new affinity mask: ff
--//這樣相當於使用8個cpu資源.
# taskset -p 22995
pid 22995's current affinity mask: ff
--//如果你遠端登入連線資料庫,這樣對應程式也僅僅能使用前面8個邏輯cpu資源.
SCOTT@78> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
90 1903 6964:3344 DEDICATED 29167 30 29 alter system kill session '90,1903' immediate;
# taskset -p 29167
pid 29167's current affinity mask: ff
--//還原.
# taskset -p ffffff 22995
pid 22995's current affinity mask: ff
pid 22995's new affinity mask: ffffff
5.你可以透過修改核心引數關閉一些cpu資源:
# seq 0 23 | xargs -I {} bash -c "echo -n cpu{}: ;cat /sys/devices/system/cpu/cpu{}/online"
cpu0:cat: /sys/devices/system/cpu/cpu0/online: No such file or directory
cpu1:1
cpu2:1
cpu3:1
cpu4:1
cpu5:1
cpu6:1
cpu7:1
cpu8:1
cpu9:1
cpu10:1
cpu11:1
cpu12:1
cpu13:1
cpu14:1
cpu15:1
cpu16:1
cpu17:1
cpu18:1
cpu19:1
cpu20:1
cpu21:1
cpu22:1
cpu23:1
--//cpu0沒有online.設定online=0就可以實現cpu的hotplug.
# echo 0 >| /sys/devices/system/cpu/cpu23/online
# seq 0 23 | xargs -I {} bash -c "echo -n cpu{}: ;cat /sys/devices/system/cpu/cpu{}/online"
cpu0:cat: /sys/devices/system/cpu/cpu0/online: No such file or directory
cpu1:1
cpu2:1
cpu3:1
cpu4:1
cpu5:1
cpu6:1
cpu7:1
cpu8:1
cpu9:1
cpu10:1
cpu11:1
cpu12:1
cpu13:1
cpu14:1
cpu15:1
cpu16:1
cpu17:1
cpu18:1
cpu19:1
cpu20:1
cpu21:1
cpu22:1
cpu23:0
# ps -ef | grep tnslsn[r]
oracle 22995 1 0 Nov11 ? 00:00:16 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
# taskset -p 22995
pid 22995's current affinity mask: 7fffff
--//可以發現mask變成了7fffff,也就是cpu23對應第1位.如果你使用top按1,可以發現僅僅顯示到cpu22.
SCOTT@78> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
90 1907 2376:7848 DEDICATED 31055 30 31 alter system kill session '90,1907' immediate;
--//如果你重啟資料庫看到的cpu_count是23
ORACLE instance started.
Total System Global Area 643084288 bytes
Fixed Size 2255872 bytes
Variable Size 205521920 bytes
Database Buffers 427819008 bytes
Redo Buffers 7487488 bytes
Database mounted.
Database opened.
SYS@book> show parameter cpu_count
NAME TYPE VALUE
--------- ------- -----
cpu_count integer 23
# taskset -p 31055
pid 31055's current affinity mask: 7fffff
--//還原:
# echo 1 >| /sys/devices/system/cpu/cpu23/online
# taskset -p 22995
pid 22995's current affinity mask: ffffff
6.測試cpu效能:
--//測試cpu效能方法很多,我自己的方法就是使用bc計算器.
# time echo 2^1000000 | bc > /dev/null
real 0m4.116s
user 0m4.100s
sys 0m0.008s
--//這樣即簡單又快捷,僅僅作為一個參考.記住1後面是6個0.目前我的測試基本在4秒多1點.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2664551/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 淺談如何確定伺服器的數量伺服器
- VMWare中的CPU數量與核心數量意義
- Linux檢視物理CPU個數、核數、邏輯CPU個數Linux
- Linux下區分物理CPU、邏輯CPU和CPU核數Linux
- [20191118]使用Chrome瀏覽器問題.txtChrome瀏覽器
- 檢視伺服器CPU的個數、CPU的核數、多核超執行緒數伺服器執行緒
- Linux 檢視 CPU 個數Linux
- 檢視cpu的個數 linuxLinux
- win10 cpu核心個數選擇怎麼設定_win10系統cpu核心數設定方法Win10
- 在linux中檢視cpu個數方法Linux
- 「數倉面試」如何確定主題域?面試
- AI數學基礎之:確定圖靈機和非確定圖靈機AI圖靈
- 檢視Linux系統CPU個數和核數Linux
- linux 下檢視cpu位數 核心等引數命令Linux
- [20130325]表Initrans的數量.txt
- win10系統如何設定cpu核心數Win10
- Golang-goroutine02(MPG模式+設定CPU數目)Golang模式
- 在 Linux 中查詢 CPU 的核數Linux
- ls命令統計檔案數量不準確
- [轉]解決系統CPU個數識別不正確的問題
- Linux及AIX下如何檢視物理CPU, 邏輯CPU及核數LinuxAI
- Linux檢視系統cpu個數、核心數、執行緒數Linux執行緒
- CPU選購應該注重主頻,還是核心數量? CPU主頻越高越好嗎?
- [20190630]如何確定直方圖型別.txt直方圖型別
- SAP MIGO 發貨批次確定介面批次可用數量無窮大問題之對策Go
- linux下檢視cpu個數及頻率Linux
- Linux系統下查CPU個數的方法Linux
- 工作確定
- python怎麼傳入不確定引數Python
- 15.4 由冪級數確定的函式函式
- [20181031]如何確定db_link的程式號.txt
- 根據CPU核數合理設定執行緒池大小執行緒
- 伺服器CPU比家用CPU更有哪些優勢伺服器
- 如何確定伺服器是否遭受CC攻擊?三種方法!伺服器
- 在Linux中,如何獲取CPU的總核心數?Linux
- Nginx伺服器常用引數設定Nginx伺服器
- 2.4.3 Step 2: 確定設定好了環境變數變數
- [20160921]linux下建立samba伺服器.txtLinuxSamba伺服器