linux服務(wù)器磁盤空間擴(kuò)充方法
前言
今天發(fā)現(xiàn)es日志未記錄,檢查了filebeat、elasticsearch、logstash之后發(fā)現(xiàn)es的索引都變成了只讀狀態(tài),手動修改索引模式之后,過幾分鐘又變成了只讀狀態(tài)。
進(jìn)一步翻閱資料,才知道原因是一旦在存儲超過95%的磁盤中的節(jié)點上分配了一個或多個分片的任何索引,該索引將被強(qiáng)制進(jìn)入只讀模式。所以只能擴(kuò)充磁盤空間了。下面簡單描述下磁盤擴(kuò)充的步驟。
步驟
磁盤原來已經(jīng)有兩個分區(qū)了,但是分配的空間都不大。
增加磁盤,通過管理端掛載新的磁盤sdc;
使用fdisk /dev/sdc,創(chuàng)建新分區(qū);
[root@localhost indices]# fdisk /dev/sdc Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x5799aeba. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: The size of this disk is 2.2 TB (2199023255552 bytes). DOS partition table format can not be used on drives for volumes larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT). WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n #new 新分區(qū) Command action e extended p primary partition (1-4) p #選擇主扇區(qū) Partition number (1-4): 1 #起始扇區(qū) First cylinder (1-267349, default 1): #這里直接回車表示取默認(rèn)值1 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349): #這里由于es需要的存儲空間比較大,所以2個T的空間我都加上了,正??梢园凑招枨笮薷纳葏^(qū)大小 Using default value 267349 Command (m for help): w #保存退出 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
然后創(chuàng)建物理卷,使用pvcreate /dev/sdc1命令;注意:這里很多文章里要求重啟系統(tǒng),這里其實可以不用重啟,可直接操作,不影響服務(wù)器的正常運行;
[root@localhost indices]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created
使用vgscan查看 物理卷組 名稱;
[root@localhost indices]# vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup" using metadata type lvm2 #這里物理卷組名稱為VolGroup
將剛才增加的物理扇區(qū)加載到卷組中,這里使用 vgextend VolGroup /dev/sdc1;
[root@localhost indices]# vgextend VolGroup /dev/sdc1 Volume group "VolGroup" successfully extended
增加卷組的大小,這里使用lvextend -L +2048G /dev/mapper/VolGroup-lv_root;
[root@localhost indices]# lvextend -L +2048G /dev/mapper/VolGroup-lv_root Size of logical volume VolGroup/lv_root changed from 135.47 GiB (34681 extents) to 2.13 TiB (558848 extents). Logical volume lv_root successfully resized.
使用df -h查看空間擴(kuò)充情況,發(fā)現(xiàn)空間并未擴(kuò)充,這是因為文件系統(tǒng)還未同步;
[root@localhost indices]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 134G 119G 8.4G 94% / tmpfs 32G 72K 32G 1% /dev/shm /dev/sda1 477M 41M 411M 10% /boot
同步文件系統(tǒng),使用xfs_growfs或者resize2fs同步文件系統(tǒng),如下操作;
[root@localhost indices]# resize2fs -f /dev/mapper/VolGroup-lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required old desc_blocks = 9, new_desc_blocks = 137 Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 572260352 (4k) blocks. The filesystem on /dev/mapper/VolGroup-lv_root is now 572260352 blocks long.
再使用df -h 查看空間擴(kuò)容情況
[root@localhost indices]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 2.1T 125G 1.9T 7% / tmpfs 32G 72K 32G 1% /dev/shm /dev/sda1 477M 41M 411M 10% /boot
由于CentOS6和CentOS7在默認(rèn)根文件系統(tǒng)的文件系統(tǒng)格式存在差異,需要判斷是否為xfs,如果是xfs則應(yīng)該使用xfs_growfs而不是一味的使用resize2fs。
到此這篇關(guān)于linux服務(wù)器磁盤空間擴(kuò)充方法的文章就介紹到這了,更多相關(guān)linux磁盤空間擴(kuò)充內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解如何在 CentOS 7 中添加新磁盤而不用重啟系統(tǒng)
本篇文章主要介紹了詳解如何在 CentOS 7 中添加新磁盤而不用重啟系統(tǒng),具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-03-03Linux 通過Rsync+Inotify實現(xiàn)本、異地遠(yuǎn)程數(shù)據(jù)實時同步功能
這篇文章主要介紹了Linux 通過Rsync+Inotify實現(xiàn)本、異地遠(yuǎn)程數(shù)據(jù)實時同步功能,需要的朋友可以參考下2020-04-04linux采用scp命令拷貝文件到本地,拷貝本地文件到遠(yuǎn)程服務(wù)器的方法
今天小編就為大家分享一篇linux采用scp命令拷貝文件到本地,拷貝本地文件到遠(yuǎn)程服務(wù)器的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-07-07Apache多虛擬主機(jī)多站點配置的兩種實現(xiàn)方案
本文介紹了在Apache服務(wù)器上配置多虛擬主機(jī)的兩種方案:基于IP地址的虛擬主機(jī)配置和基于域名的虛擬主機(jī)配置,詳細(xì)說明了每個方案的配置步驟,以實現(xiàn)在同一臺服務(wù)器上托管多個網(wǎng)站的目的,感興趣的可以了解一下2024-09-09動態(tài)在線擴(kuò)容root根分區(qū)大小的方法詳解
這篇文章主要給大家介紹了關(guān)于如何動態(tài)在線擴(kuò)容root根分區(qū)大小的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-05-05Linux系統(tǒng)下如何實現(xiàn)修改主機(jī)名
這篇文章主要介紹了Linux系統(tǒng)下如何實現(xiàn)修改主機(jī)名問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02