zpool performance optimal property vdev’s ashift or sector at create time

1 minute read

背景

只能在创建zpool时指定的唯一参数ashift, 用于指定zpool的扇区大小(2^ashift bytes).

比较优化的选择是大于等于底层设备的sector.

查看块设备的sector. 例如

fdisk -l /dev/sdb  

看到如下一行.

Sector size (logical/physical): 512 bytes / 512 bytes  

但是有些系统可能将4K的sector认为是512字节的, 所以如果要强制使用4K sector的话, 建议在创建zpool时指定ashift=12.

例如 :

# zpool create -o ashift=12 zp1 raidz2 sdb sdc sdd sde sdf sdg sdh sdi sdj sdk spare sdl sdm  

参考

1. man zpool

       ashift  
  
           Pool  sector  size exponent, to the power of 2 (internally referred to as "ashift"). I/O operations will be  
           aligned to the specified size boundaries. Additionally, the minimum (disk) write size will be  set  to  the  
           specified  size,  so  this  represents a space vs. performance trade-off. The typical case for setting this  
           property is when performance is important and the underlying disks use 4KiB sectors but report 512B sectors  
           to the OS (for compatibility reasons); in that case, set ashift=12 (which is 1<<12 = 4096).  
  
           For  optimal  performance,  the  pool sector size should be greater than or equal to the sector size of the  
           underlying disks. Since the property cannot be changed after pool creation, if in a given  pool,  you  ever  
           want to use drives that report 4KiB sectors, you must set ashift=12 at pool creation time.  
  
           Keep in mind is that the ashift is vdev specific and is not a pool global.  This means that when adding new  
           vdevs to an existing pool you may need to specify the ashift.  

Flag Counter

digoal’s 大量PostgreSQL文章入口