教你Open Suse Linux服務器配置方法
學習Open Suse Linux時,經常會遇到Open Suse Linux問題,這里將介紹Open Suse Linux問題的解決方法。現在很多的IT企業部門都想應用Open Suse Linux。本文介紹Open Suse Linux服務器配置方法,如下:
操作系統版本:
- suse10:/ # cat /etc/SuSE-release
- openSUSE 10.2 (i586)
- VERSION = 10.2
- suse10:/ # uname -a
- Linux suse10 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 athlon i386 GNU/Linux
1、檢查系統是否安裝quota包
suse10:/ # rpm -qa | grep quota
suse10:/ #
查詢無任何輸出,表示系統未安裝。
2、安裝quota包
- suse10:/tmp # ls -l quota*
- -rwxr-xr-x 1 root root 270080 Aug 17 14:33 quota-3.13-17.i586.rpm
- suse10:/tmp # rpm -ivh quota-3.13-17.i586.rpm
- Preparing... ########################################### [100%]
- 1:quota ########################################### [100%]
3、再次檢查系統是否成功安裝quota包
suse10:/tmp # rpm -qa | grep quota
quota-3.13-17
有“quota-3.13-17”輸出,表示quota包安裝成功。
4、設置需要做用戶/組磁盤限額的文件系統
編輯/etc/fstab文件,對用戶進行限制,添加usrquota,對組進行限制,添加grpquota。如下紅色部分:
- suse10:/ # cat /etc/fstab
- /dev/system_vg/root_lv / ext3 acl,user_xattr 1 1
- /dev/hda1 /boot ext3 acl,user_xattr 1 2
- /dev/system_vg/home_lv /home ext3 acl,user_xattr,usrquota,grpquota 1 2
- /dev/system_vg/tmp_lv /tmp ext3 acl,user_xattr 1 2
- /dev/system_vg/usr_lv /usr ext3 acl,user_xattr 1 2
- /dev/system_vg/swap_lv swap swap defaults 0 0
- proc /proc proc defaults 0 0
- sysfs /sys sysfs noauto 0 0
- debugfs /sys/kernel/debug debugfs noauto 0 0
- usbfs /proc/bus/usb usbfs noauto 0 0
- devpts /dev/pts devpts mode=0620,gid=5 0 0
- /dev/data_vg/informix_lv /informix ext3 acl,user_xattr 1 2
- /dev/data_vg/oracle_lv /oracle ext3 acl,user_xattr 1 2
5、重新mount文件系統
對啟用磁盤限額的文件系統重新加載:
suse10:/ # mount -o remount /home
回車后如無任何信息,表示重新加載成功。
6、為啟用磁盤限額的文件系統創建限額文件
- suse10:/ # quotacheck -gumv /home
- quotacheck: Scanning /dev/mapper/system_vg-home_lv [/home] done
- quotacheck: Cannot stat old user quota file: No such file or directory
- quotacheck: Cannot stat old group quota file: No such file or directory
- quotacheck: Cannot stat old user quota file: No such file or directory
- quotacheck: Cannot stat old group quota file: No such file or directory
- quotacheck: Checked 3210 directories and 8310 files
- quotacheck: Old file not found.
- quotacheck: Old file not found.
-g參數:掃描磁盤空間時,計算每個組標識符(GID)所占用的目錄和文件數目;
-u參數:掃描磁盤空間時,計算每個用戶標識符(UID)所占用的目錄和文件數目;
-v參數:標識命令執行過程。
-m參數:強制執行命令。
此時會在/home文件系統根目錄下自動生成兩個文件:aquota.user和aquota.group
- suse10:/ # ls -l /home/aquota.*
- -rw------- 1 root root 8192 Aug 17 22:18 /home/aquota.group
- -rw------- 1 root root 8192 Aug 17 22:18 /home/aquota.user
7、開啟磁盤限額
suse10:/ # quotaon -augv
/dev/mapper/system_vg-home_lv [/home]: group quotas turned on
/dev/mapper/system_vg-home_lv [/home]: user quotas turned on
-a參數:開啟在/ect/fstab文件里,有加入quota設置的分區的空間限制;
-g參數:開啟群組的磁盤空間限制;
-u參數:開啟用戶的磁盤空間限制;
-v參數:顯示指令指令執行過程。
8、編輯用戶/組的磁盤限額大小(本文以oracle1用戶為例,組配置過程類似,本文不列出)
suse10:/ #edquota -u oracle1
回車后會調用vi編輯,如下:
Disk quotas for user oracle1 (uid 2002):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/system_vg-home_lv 1886624 0 0 3880 0 0
說明:
Filessystem:表示當前啟用磁盤限額的文件系統名稱;
blocks:表示當前用戶已使用塊數量大小;
soft:表示軟限制(非強制性限制)磁盤空間大小,單位為KBytes;
hard:表示硬限制(強制性限制)磁盤空間大小,單位為KBytes;
inodes:表示當前用戶已使用文件個數;
soft:表示軟限制(非強制性限制)文件個數;
hard:表示硬限制(強制性限制)文件個數。
“0”表示沒有不限制,把想要設置的數值填入對應項保存退出。
9、查看某個用戶的磁盤限額情況
suse10:/ # quota -u oracle1
Disk quotas for user oracle1 (uid 2002):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/system_vg-home_lv 1886624 4194304 4200000 3880 10000 11000
說明:查看某個組的磁盤限額情況使用-g參數。
10、查看某個文件系統的磁盤限額(包括用戶和組限額)
- suse10:/ # repquota -ugv /home
- *** Report for user quotas on device /dev/mapper/system_vg-home_lv
- Block grace time: 7days; Inode grace time: 7days
- Block limits File limits
- User used soft hard grace used soft hard grace
- ----------------------------------------------------------------------
- root -- 1027760 0 0 2444 0 0
- metal -- 3068 0 0 656 0 0
- informix -- 599128 0 0 2076 0 0
- oracle -- 701152 0 0 2437 0 0
- oinstall -- 116 0 0 25 0 0
- oracle1 -- 1886624 4194304 4200000 3880 10000 11000
- Statistics:
- Total blocks: 8
- Data blocks: 1
- Entries: 6
- Used average: 6.000000
- *** Report for group quotas on device /dev/mapper/system_vg-home_lv
- Block grace time: 7days; Inode grace time: 7days
- Block limits File limits
- Group used soft hard grace used soft hard grace
- ----------------------------------------------------------------------
- root -- 1003900 0 0 2449 0 0
- users -- 3068 0 0 656 0 0
- informix -- 623104 0 0 2096 0 0
- oinstall -- 2587776 0 0 6317 0 0
- Statistics:
- Total blocks: 8
- Data blocks: 1
- Entries: 4
- Used average: 4.000000
11、編輯寬限時間
- suse10:/ #edquota -t
- Grace period before enforcing soft limits for users:
- Time units may be: days, hours, minutes, or seconds
- Filesystem ock grace period Inode grace period
- /dev/mapper/system_vg-home_lv 7days 7days
系統缺省是7天,可改成你實際需要的值保存后退出即可。
特別要說明的是,當實際使用的空間未超過軟(soft)限制,寬限(grace)時間是不會出現在quota -u username輸出中的。
看完本文你肯定有不少收獲,希望本文能教會你更多東西。也許看完本文你就能了解服務器配置了。
【編輯推薦】