openGauss數(shù)據(jù)庫維護管理指導(dǎo)(一)

簡介

本實驗適用于 openGauss數(shù)據(jù)庫,通過該實驗可以順利完成對數(shù)據(jù)庫各項日潮幼唬基本維護管理缀台。主要內(nèi)容為操作系統(tǒng)參數(shù)檢查棠赛、openGauss健康狀態(tài)檢查、數(shù)據(jù)庫性能檢查膛腐、日志檢查和清理睛约、時間一致性檢查、應(yīng)用連接數(shù)檢查哲身、例行維護表等辩涝。

前置條件

  1. 由于本實驗主要是在openEuler操作系統(tǒng)上進行數(shù)據(jù)庫維護管理,需要掌握Linux系統(tǒng)的基本操作和系統(tǒng)命令

  2. 數(shù)據(jù)庫維護管理尤其是例行表勘天、索引的維護需要掌握openGauss數(shù)據(jù)庫的基本操作和SQL語法怔揩,openGauss數(shù)據(jù)庫支持SQL2003標(biāo)準(zhǔn)語法。

實驗環(huán)境說明

組網(wǎng)說明:本實驗環(huán)境為華為云 ECS 服務(wù)器 + openGauss數(shù)據(jù)庫脯丝。
設(shè)備介紹:為了滿足數(shù)據(jù)庫原理與實踐課程實驗需要商膊,建議每套實驗環(huán)境采用以下配置:

實驗概覽:

1.操作系統(tǒng)參數(shù)檢查

1.1 實驗介紹

1.1.1 關(guān)于本實驗

gs_checkos工具用來幫助檢查操作系統(tǒng)、控制參數(shù)宠进、磁盤配置等內(nèi)容晕拆,并對系統(tǒng)控制參數(shù)、I/O配置材蹬、網(wǎng)絡(luò)配置和THP服務(wù)等信息進行配置实幕。
本實驗主要是通過gs_checkos工具來檢查操作系統(tǒng)參數(shù)設(shè)置是否合理。先進行場景設(shè)置堤器,然后根據(jù)檢查結(jié)果進行參數(shù)調(diào)整昆庇。

1.1.2 實驗?zāi)康?/strong>

掌握gs_checkos工具的基本使用

1.2 場景設(shè)置及操作步驟

步驟 1 用root用戶登錄裝有openGauss數(shù)據(jù)庫服務(wù)的操作系統(tǒng),登錄后信息如下:

Welcome to 4.19.90-2003.4.0.0036.oe1.aarch64
System information as of time: Mon Jul 20 16:41:11 CST 2020
System load: 0.00
Processes: 113
Memory used: 7.0%
Swap used: 0.0%
Usage On: 15%
IP address: 192.168.0.96
Users online: 2
[root@ecs-e1b3 ~]#

步驟 2 在root用戶下執(zhí)行g(shù)s_checkos先對系統(tǒng)參數(shù)進行檢查吼旧。

[root@ecs-e1b3 ~]# gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Normal
A6. [ System control parameters status ] : Warning
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A10.[ IO scheduler status ] : Normal
BondMode Null
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:14. Abnormal numbers:0. Warning numbers:3.

說明事項:
Normal 為正常項凰锡,Abnormal為必須處理項未舟,Warning可以不處理圈暗。
Total numbers:14. Abnormal numbers:0. Warning numbers:3掂为。
表示:總共檢查14項,其中Abnormal必須處理項為0员串,Warning告警項為3勇哗。

步驟 3 調(diào)整系統(tǒng)參數(shù)值。
在參數(shù)配置文件(/etc/sysctl.conf)中將參數(shù) vm.min_free_kbytes(表示:內(nèi)核內(nèi)存分配保留的內(nèi)存量) 的值調(diào)整為3488寸齐。輸入“i”進入INSERT模式欲诺,進行修改。

[root@ecs-e1b3 ~]# vi /etc/sysctl.conf
net.ipv4.conf.default.accept_redirects=0
net.ipv4.conf.all.secure_redirects=0
net.ipv4.conf.default.secure_redirects=0
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_ignore_bogus_error_responses=1
………......
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 3488
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535

參數(shù)值修改好后渺鹦,按” ESC”鍵退出編輯模式扰法,然后輸入 :wq 后回車進行保存。接著通過執(zhí)行sysctl -p 命令使剛才修改的參數(shù)生效毅厚,具體如下:

[root@ecs-e1b3 ~]# sysctl -p
kernel.sysrq = 0
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
…………..
net.core.rmem_default = 21299200
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
kernel.sem = 250 6400000 1000 25600
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 3488
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615

步驟 4 再執(zhí)行g(shù)s_checkos 對系統(tǒng)參數(shù)進行檢查塞颁。

[root@ecs-e1b3 ~]# gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Normal
A6. [ System control parameters status ] : Abnormal
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A10.[ IO scheduler status ] : Normal
BondMode Null
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:14. Abnormal numbers:1. Warning numbers:2.
Do checking operation finished. Result: Abnormal.

此時A6. [ System control parameters status ] 的狀態(tài)為Abnormal為必須處理項;
Total numbers:14. Abnormal numbers:1. Warning numbers:2吸耿。
表示:總共檢查14項祠锣,其中Abnormal必須處理項為1,Warning告警項為2咽安。

步驟 5 通過執(zhí)行g(shù)s_checkos -i A --detail 查看更詳細的信息伴网。

[root@ecs-e1b3 ~]# gs_checkos -i A --detail
Checking items:
A1. [ OS version status ] : Normal
[ecs-e1b3]
openEuler_20.03_64bit
A2. [ Kernel version status ] : Normal
The names about all kernel versions are same. The value is "4.19.90-2003.4.0.0036.oe1.aarch64".
A3. [ Unicode status ] : Normal
The values of all unicode are same. The value is "LANG=en_US.UTF-8".
A4. [ Time zone status ] : Normal
The informations about all timezones are same. The value is "+0800".
A5. [ Swap memory status ] : Normal
The value about swap memory is correct.
A6. [ System control parameters status ] : Abnormal
[ecs-e1b3]
Abnormal reason: variable 'vm.min_free_kbytes' RealValue '3488' ExpectedValue '348844'.
Warning reason: variable 'net.ipv4.tcp_retries1' RealValue '3' ExpectedValue '5'.
Warning reason: variable 'net.ipv4.tcp_syn_retries' RealValue '6' ExpectedValue '5'.
Warning reason: variable 'net.sctp.path_max_retrans' RealValue '5' ExpectedValue '10'.
Warning reason: variable 'net.sctp.max_init_retransmits' RealValue '8' ExpectedValue '10'.
Check_SysCtl_Parameter failed.
A7. [ File system configuration status ] : Normal
Both soft nofile and hard nofile are correct.
A8. [ Disk configuration status ] : Normal
The value about XFS mount parameters is correct.
A9. [ Pre-read block size status ] : Normal
The value about Logical block size is correct.
A10.[ IO scheduler status ] : Normal
The value of IO scheduler is correct.
BondMode Null
A11.[ Network card configuration status ] : Warning
[ecs-e1b3]
BondMode Null
Warning reason: Failed to obtain the network card speed value. Maybe the network card "eth0" is not working.
A12.[ Time consistency status ] : Warning
[ecs-e1b3]
The NTPD not detected on machine and local time is "2020-07-20 17:16:41".
A13.[ Firewall service status ] : Normal
The firewall service is stopped.
A14.[ THP service status ] : Normal
The THP service is stopped.
Total numbers:14. Abnormal numbers:1. Warning numbers:2.
Do checking operation finished. Result: Abnormal.

在詳細信息中,可以明確看出那些參數(shù)設(shè)置有問題妆棒,并給出了問題參數(shù)要求修改的參考值澡腾,如下:

A6. [ System control parameters status ] : Abnormal
[ecs-e1b3]
Abnormal reason: variable ‘vm.min_free_kbytes’ RealValue ‘3488’ ExpectedValue ‘348844’.
Warning reason: variable ‘net.ipv4.tcp_retries1’ RealValue ‘3’ ExpectedValue ‘5’.
Warning reason: variable ‘net.ipv4.tcp_syn_retries’ RealValue ‘6’ ExpectedValue ‘5’.
Warning reason: variable ‘net.sctp.path_max_retrans’ RealValue ‘5’ ExpectedValue ‘10’.
Warning reason: variable ‘net.sctp.max_init_retransmits’ RealValue ‘8’ ExpectedValue ‘10’.
Check_SysCtl_Parameter failed.

步驟 6 按詳細信息中的修改說明對系統(tǒng)參數(shù)進行修改。

vm.min_free_kbytes的值由3488調(diào)整為348844
net.ipv4.tcp_retries1的值由3調(diào)整為5.
net.ipv4.tcp_syn_retries的值由6調(diào)整為5.
net.sctp.path_max_retrans的值由5調(diào)整為10
net.sctp.max_init_retransmits的值由8調(diào)整為10
具體設(shè)置如下:

vm.min_free_kbytes = 348844
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10

在系統(tǒng)參數(shù)文件中進行修改(輸入“i”進入INSERT模式糕珊,進行修改蛋铆。):

[root@ecs-e1b3 ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
kernel.sysrq=0
net.ipv4.ip_forward=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0
net.ipv4.conf.all.accept_redirects=0
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
kernel.sysrq=0
net.ipv4.ip_forward=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.all.accept_source_route=0
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
kernel.sysrq=0
net.ipv4.ip_forward=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0
…………..
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
kernel.sem = 250 6400000 1000 25600
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 348844
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10

參數(shù)值修改好后,按”ESC”鍵退出編輯模式放接,然后輸入:wq 后回車進行保存刺啦。接著通過執(zhí)行sysctl -p 命令使剛才修改的參數(shù)生效,具體如下:

[root@ecs-e1b3 ~]# sysctl -p
kernel.sysrq = 0
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_syncookies = 1
kernel.dmesg_restrict = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
vm.swappiness = 0
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
…………….
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 348844
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10

步驟 7 再次通過執(zhí)行g(shù)s_checkos -i A 查看系統(tǒng)參數(shù)檢查是否能通過纠脾。

[root@ecs-e1b3 ~]# gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Normal
A6. [ System control parameters status ] : Normal
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A10.[ IO scheduler status ] : Normal
BondMode Null
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:14. Abnormal numbers:0. Warning numbers:2.

從檢查結(jié)果可以看出玛瘸,系統(tǒng)參數(shù)檢查已經(jīng)通過。其中A6. [ System control parameters status ]的狀態(tài)由原來的Abnormal變?yōu)榱薔ormal苟蹈。
操作系統(tǒng)參數(shù)檢查實驗結(jié)束糊渊。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市慧脱,隨后出現(xiàn)的幾起案子渺绒,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,386評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件宗兼,死亡現(xiàn)場離奇詭異躏鱼,居然都是意外死亡,警方通過查閱死者的電腦和手機殷绍,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,142評論 3 394
  • 文/潘曉璐 我一進店門染苛,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人主到,你說我怎么就攤上這事茶行。” “怎么了登钥?”我有些...
    開封第一講書人閱讀 164,704評論 0 353
  • 文/不壞的土叔 我叫張陵畔师,是天一觀的道長。 經(jīng)常有香客問我牧牢,道長茉唉,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,702評論 1 294
  • 正文 為了忘掉前任结执,我火速辦了婚禮度陆,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘献幔。我一直安慰自己懂傀,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,716評論 6 392
  • 文/花漫 我一把揭開白布蜡感。 她就那樣靜靜地躺著蹬蚁,像睡著了一般。 火紅的嫁衣襯著肌膚如雪郑兴。 梳的紋絲不亂的頭發(fā)上犀斋,一...
    開封第一講書人閱讀 51,573評論 1 305
  • 那天,我揣著相機與錄音情连,去河邊找鬼叽粹。 笑死,一個胖子當(dāng)著我的面吹牛却舀,可吹牛的內(nèi)容都是我干的虫几。 我是一名探鬼主播,決...
    沈念sama閱讀 40,314評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼挽拔,長吁一口氣:“原來是場噩夢啊……” “哼辆脸!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起螃诅,我...
    開封第一講書人閱讀 39,230評論 0 276
  • 序言:老撾萬榮一對情侶失蹤啡氢,失蹤者是張志新(化名)和其女友劉穎状囱,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體倘是,經(jīng)...
    沈念sama閱讀 45,680評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡亭枷,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,873評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了辨绊。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,991評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡匹表,死狀恐怖门坷,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情袍镀,我是刑警寧澤默蚌,帶...
    沈念sama閱讀 35,706評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站苇羡,受9級特大地震影響绸吸,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜设江,卻給世界環(huán)境...
    茶點故事閱讀 41,329評論 3 330
  • 文/蒙蒙 一锦茁、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧叉存,春花似錦码俩、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,910評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至瞳秽,卻和暖如春瓣履,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背练俐。 一陣腳步聲響...
    開封第一講書人閱讀 33,038評論 1 270
  • 我被黑心中介騙來泰國打工袖迎, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人腺晾。 一個月前我還...
    沈念sama閱讀 48,158評論 3 370
  • 正文 我出身青樓瓢棒,卻偏偏與公主長得像,于是被迫代替她去往敵國和親丘喻。 傳聞我的和親對象是個殘疾皇子脯宿,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,941評論 2 355

推薦閱讀更多精彩內(nèi)容