opengauss更改數(shù)據(jù)目錄位置
歡迎來(lái)到藍(lán)隊(duì)云技術(shù)小課堂,每天分享一個(gè)技術(shù)小知識(shí)。
一、概述
有時(shí)我們部署完數(shù)據(jù)庫(kù),發(fā)現(xiàn)隨著數(shù)據(jù)量的不斷增加,數(shù)據(jù)目錄所在的磁盤(pán)大小不能夠滿足我們的需求,需要更大的磁盤(pán)空間,這時(shí)選擇重新部署數(shù)據(jù)庫(kù)會(huì)很麻煩,之前所使用的數(shù)據(jù)庫(kù)還需要重新導(dǎo)入,這里介紹將數(shù)據(jù)庫(kù)目錄更改到別的位置的方法,不建議生產(chǎn)環(huán)境使用,建議測(cè)試環(huán)境使用。
二、更改過(guò)程
1、查看數(shù)據(jù)目錄位置
gsql -d postgres -p26000 -r
show data_directory ;
data_directory
-------------------------------
/opt/huawei/install/data/dn01
(1 row)
2、更改數(shù)據(jù)庫(kù)位置
postgres=# alter system set data_directory='/opt/data'; ==>更改數(shù)據(jù)目錄位置
NOTICE: please restart the database for the POSTMASTER level parameter to take effect.
ALTER SYSTEM SET
postgres=# show data_directory ; ==>這個(gè)參數(shù)需要重啟數(shù)據(jù)庫(kù)生效
data_directory
-----------------
/opt/mogdb/data
(1 row)
3、停止數(shù)據(jù)庫(kù)更改目錄
gs_ctl stop -D /opt/huawei/install/data/dn01/
#本機(jī)采取二進(jìn)制方式部署,采用標(biāo)準(zhǔn)安裝可的使用gs_om -t stop 停止
mkdir -p /opt/data ==>創(chuàng)建新的數(shù)據(jù)目錄
cd /opt/data/
cp -r /opt/huawei/install/data/dn01/* /opt/data/ ==>將原來(lái)數(shù)據(jù)目錄的數(shù)據(jù)拷貝到新的數(shù)據(jù)目錄下
chmod 0700 /opt/data ==>將新的數(shù)據(jù)目錄賦予0700的權(quán)限,否則重啟數(shù)據(jù)庫(kù)會(huì)報(bào)錯(cuò)
4、啟動(dòng)數(shù)據(jù)庫(kù)
gs_ctl start -D /opt/data
gsql -d postgres -p26000 -r
postgres=# show data_directory ; ==>更改成功
data_directory
----------------
/opt/data
(1 row)
藍(lán)隊(duì)云官網(wǎng)上擁有完善的技術(shù)支持庫(kù)可供參考,大家可自行查閱,更多技術(shù)問(wèn)題,可以直接咨詢(xún)。同時(shí),藍(lán)隊(duì)云整理了運(yùn)維必備的工具包免費(fèi)分享給大家使用,需要的朋友可以直接咨詢(xún)。
更多技術(shù)知識(shí),藍(lán)隊(duì)云期待與你一起探索。