簡介
本實驗適用于 openGauss數(shù)據(jù)庫,通過該實驗可以順利完成對數(shù)據(jù)庫各項日潮幼唬基本維護管理缀台。主要內(nèi)容為操作系統(tǒng)參數(shù)檢查棠赛、openGauss健康狀態(tài)檢查、數(shù)據(jù)庫性能檢查膛腐、日志檢查和清理睛约、時間一致性檢查、應(yīng)用連接數(shù)檢查哲身、例行維護表等辩涝。
前置條件
由于本實驗主要是在openEuler操作系統(tǒng)上進行數(shù)據(jù)庫維護管理,需要掌握Linux系統(tǒng)的基本操作和系統(tǒng)命令
數(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é)束糊渊。