偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

WiredTiger 如何修復(fù) MongoDB 7.0.14 集合 WT 文件

原創(chuàng) 精選
數(shù)據(jù)庫(kù) MongoDB
WiredTiger 是一個(gè)高性能的鍵值存儲(chǔ)和數(shù)據(jù)引擎,最初由 WiredTiger Inc. 開(kāi)發(fā),后來(lái)被 MongoDB 收購(gòu)并集成到 MongoDB 中。

作者 | 吳守陽(yáng)

審校 | 重樓

目錄

1. 概述

2. 主要特性

3. 安裝依賴(lài)

4.安裝WiredTiger

5. WiredTiger編譯支持的參數(shù)

6. 找到故障WT文件

7. 恢復(fù)

8. 總結(jié)

概述

WiredTiger 是一個(gè)高性能的鍵值存儲(chǔ)和數(shù)據(jù)引擎,最初由 WiredTiger Inc. 開(kāi)發(fā),后來(lái)被 MongoDB 收購(gòu)并集成到 MongoDB 中。WiredTiger 提供了高效的數(shù)據(jù)存儲(chǔ)和檢索能力,支持多種數(shù)據(jù)結(jié)構(gòu)和壓縮算法,適用于高并發(fā)和大規(guī)模數(shù)據(jù)處理場(chǎng)景。

主要特性

  • 高性能:WiredTiger 通過(guò)高效的內(nèi)存管理和并發(fā)控制機(jī)制,提供了卓越的讀寫(xiě)性能。
  • 多種數(shù)據(jù)結(jié)構(gòu):支持 B-Tree、LSM 樹(shù)等多種數(shù)據(jù)結(jié)構(gòu),適用于不同的應(yīng)用場(chǎng)景。
  • 壓縮算法:支持多種壓縮算法(如 Snappy、LZ4、Zlib、Zstd),可以顯著減少存儲(chǔ)空間占用。
  • 事務(wù)支持:提供 ACID 事務(wù)支持,確保數(shù)據(jù)的一致性和可靠性。
  • 可擴(kuò)展性:設(shè)計(jì)為高度可擴(kuò)展,適用于從小型嵌入式設(shè)備到大型分布式系統(tǒng)的各種環(huán)境。
  • 靈活的配置:可以通過(guò)豐富的配置選項(xiàng)來(lái)優(yōu)化性能和資源使用。
  • 數(shù)據(jù)恢復(fù):提供數(shù)據(jù)恢復(fù)功能,確保在數(shù)據(jù)損壞或系統(tǒng)故障后能夠恢復(fù)數(shù)據(jù)。

數(shù)據(jù)庫(kù)節(jié)點(diǎn)出現(xiàn)無(wú)法啟動(dòng)的問(wèn)題,顯示某個(gè)集合文件損壞,使用 --repair修復(fù)后,還是不能啟動(dòng)。接下來(lái)使用WT修復(fù),此次修復(fù)的數(shù)據(jù)庫(kù)版本的是7.0.14

安裝依賴(lài)

---安裝依賴(lài)(盡量保證這些依賴(lài)都安裝完)
yum install -y swig python3-devel openssl-devel epel-release libtool automake cmake-filesystem snappy snappy-devel lz4 lz4-devel zstd zstd-devel libzstd-devel zlib zlib-devel git make vim-common
Package swig-3.0.12-19.module_el8.3.0+557+3d058e38.x86_64 is already installed.
Package python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 is already installed.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package snappy-1.1.8-3.el8.x86_64 is already installed.
Package snappy-devel-1.1.8-3.el8.x86_64 is already installed.
No match for argument: zstd-devel
Package zlib-1.2.11-17.el8.i686 is already installed.
Package zlib-1.2.11-17.el8.x86_64 is already installed.
Package zlib-devel-1.2.11-17.el8.x86_64 is already installed.
Package git-2.27.0-1.el8.x86_64 is already installed.
Package make-1:4.2.1-10.el8.x86_64 is already installed.
Package vim-common-2:8.0.1763-15.el8.x86_64 is already installed.
Error: Unable to find a match: zstd-devel

--安裝snappy-devel
https://rpmfind.net/linux/rpm2html/search.php?query=snappy-devel
wget https://rpmfind.net/linux/almalinux/8.10/PowerTools/x86_64/os/Packages/snappy-devel-1.1.8-3.el8.x86_64.rpm
yum install snappy-devel-1.1.8-3.el8.x86_64.rpm

---安裝cmake
wget https://github.com/Kitware/CMake/releases/download/v3.30.3/cmake-3.30.3-linux-x86_64.tar.gz
tar -zxvf cmake-3.30.3-linux-x86_64.tar.gz
cd cmake-3.30.3
./bootstrap
make && make install
[root@easyliao012 bin]# pwd
/opt/cmake-3.30.3-linux-x86_64/bin

安裝WiredTiger

---開(kāi)始編譯
wget https://github.com/wiredtiger/wiredtiger/archive/refs/tags/11.2.0.tar.gz
tar xvf 11.2.0.tar.gz
cd wiredtiger
mkdir build
cd build
 /opt/cmake-3.30.3-linux-x86_64/bin/cmake -DENABLE_SNAPPY=1 ../.
make && make install

---配置環(huán)境變量
export LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
[root@easyliao012 lib64]# ll -h /usr/local/lib64/
-rwxr-xr-x  1 root root 121K Sep 29 14:36 libwiredtiger_snappy.so
lrwxrwxrwx  1 root root   23 Sep 27 18:23 libwiredtiger.so -> libwiredtiger.so.11.2.0
-rwxr-xr-x  1 root root  29M Sep 29 14:36 libwiredtiger.so.11.2.0
-rwxr-xr-x  1 root root 152K Sep 29 14:36 libwiredtiger_zlib.so
-rwxr-xr-x  1 root root 139K Sep 29 14:36 libwiredtiger_zstd.so

---編譯完成
root@easyliao012 data]# cd /opt/wiredtiger/wiredtiger-11.2.0/build
[root@easyliao012 build]# ls
bench           CMakeFiles           config               examples  gdb_scripts  install_manifest.txt  libwiredtiger.so         libwiredtiger.so.11.2.0-gdb.py  src   wiredtiger.pc
CMakeCache.txt  cmake_install.cmake  CTestTestfile.cmake  ext       include      lang                  libwiredtiger.so.11.2.0  Makefile                        test  wt

WiredTiger編譯支持的參數(shù)

WiredTiger 軟件支持一些額外的配置選項(xiàng):

-DHAVE_ATTACH=1

功能:配置 WiredTiger 在發(fā)生故障時(shí)休眠并等待調(diào)試器附加。

用途:主要用于開(kāi)發(fā)和調(diào)試,不建議在生產(chǎn)環(huán)境中使用。

-DHAVE_DIAGNOSTIC=1

功能:配置 WiredTiger 在運(yùn)行時(shí)執(zhí)行各種診斷測(cè)試。

默認(rèn)值:默認(rèn)情況下,非發(fā)布(Release)構(gòu)建類(lèi)型會(huì)啟用此選項(xiàng)。

用途:主要用于開(kāi)發(fā)和調(diào)試,不建議在生產(chǎn)環(huán)境中使用。

-DNON_BARRIER_DIAGNOSTIC_YIELDS=1

功能:配置 WiredTiger 在線程讓步時(shí)不要使用內(nèi)存屏障,用于診斷目的。

前提條件:必須同時(shí)啟用 HAVE_DIAGNOSTIC 選項(xiàng)。

用途:主要用于開(kāi)發(fā)和調(diào)試,不建議在生產(chǎn)環(huán)境中使用。

-DENABLE_LZ4=1

功能:配置 WiredTiger 使用 LZ4 壓縮。

默認(rèn)值:如果系統(tǒng)中存在 LZ4 庫(kù),默認(rèn)情況下會(huì)啟用此選項(xiàng)。

用途:提高數(shù)據(jù)壓縮效率。

-DENABLE_PYTHON=1

功能:構(gòu)建 WiredTiger 的 Python API。

前提條件:需要 SWIG 工具。

默認(rèn)值:如果系統(tǒng)中存在 Python,默認(rèn)情況下會(huì)啟用此選項(xiàng)。

用途:允許使用 Python 訪問(wèn) WiredTiger 功能。

-DENABLE_SNAPPY=1

功能:配置 WiredTiger 使用 snappy 壓縮。

默認(rèn)值:如果系統(tǒng)中存在 snappy 庫(kù),默認(rèn)情況下會(huì)啟用此選項(xiàng)。

用途:提高數(shù)據(jù)壓縮效率。

-DENABLE_ZLIB=1

功能:配置 WiredTiger 使用 zlib 壓縮。

默認(rèn)值:如果系統(tǒng)中存在 zlib 庫(kù),默認(rèn)情況下會(huì)啟用此選項(xiàng)。

用途:提高數(shù)據(jù)壓縮效率。

-DENABLE_ZSTD=1

功能:配置 WiredTiger 使用 Zstd 壓縮。

默認(rèn)值:如果系統(tǒng)中存在 Zstd 庫(kù),默認(rèn)情況下會(huì)啟用此選項(xiàng)。

用途:提高數(shù)據(jù)壓縮效率。

-DWT_STANDALONE_BUILD=0

功能:配置 WiredTiger 禁用獨(dú)立構(gòu)建。獨(dú)立構(gòu)建默認(rèn)是啟用的。

用途:如果你希望 WiredTiger 作為某個(gè)更大項(xiàng)目的一部分構(gòu)建,可以禁用獨(dú)立構(gòu)建。

-DHAVE_BUILTIN_EXTENSION_LZ4=1, -DHAVE_BUILTIN_EXTENSION_SNAPPY=1, -DHAVE_BUILTIN_EXTENSION_ZLIB=1, -DHAVE_BUILTIN_EXTENSION_ZSTD=1

功能:配置 WiredTiger 在主庫(kù)中包含對(duì)擴(kuò)展的支持。這避免了需要額外的庫(kù)來(lái)支持這些擴(kuò)展。目前支持的內(nèi)置擴(kuò)展選項(xiàng)包括 lz4, snappy, zlib 和 zstd。

用途:簡(jiǎn)化依賴(lài)管理,減少外部庫(kù)的依賴(lài)。

-DSPINLOCK_TYPE[=pthread, pthread_adaptive, gcc]

功能:配置 WiredTiger 使用特定的互斥鎖類(lèi)型進(jìn)行序列化。

選項(xiàng):

pthread(默認(rèn)):使用 POSIX 1003.1c 線程互斥鎖。

pthread_adaptive:使用配置為自適應(yīng)的 POSIX 1003.1c 線程互斥鎖(如果該功能可用)。

gcc:使用基于 GCC 的自旋鎖。

用途:優(yōu)化多線程環(huán)境中的性能

找到故障WT文件

找到故障集合對(duì)應(yīng)的wt文件

mongosh mongodb://mon1:30000 -u "admin" --authenticationDatabase "admin" -p sdhjfREWccacFWEF23e
mongos>use db2
db2> db.user1.stats()
    shard1: {
      ns: 'db2.user1',
      size: 9800,
      count: 214,
      avgObjSize: 45,
      numOrphanDocs: 0,
      storageSize: 40960,
      freeStorageSize: 16384,
      capped: false,
      wiredTiger: {
        metadata: { formatVersion: 1 },
        creationString: 'access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),write_timestamp_usage=none',
        type: 'file',
        uri: 'statistics:table:collection-0-7625617652108868965',

###在shard1中找到user1集合對(duì)應(yīng)的collection-0--8815599204543663053.wt
[root@shard1 data]# ll -h collection-0--8815599204543663053.wt
-rw------- 1 root root 24K Sep 29 14:46 collection-0--8815599204543663053.wt

恢復(fù)

---前提條件,數(shù)據(jù)庫(kù)應(yīng)當(dāng)停止
/opt/mongodb/bin/mongod --config /monogocluster/shard2/config/mongo-conf  --shutdown
---修復(fù)前備份數(shù)據(jù)文件

---修復(fù)操作需要在mongo數(shù)據(jù)目錄中執(zhí)行
/usr/local/bin/wt -v -C "extensions=[/usr/local/lib64/libwiredtiger_snappy.so]"  salvage file:collection-0--8815599204543663053.wt
---啟動(dòng)數(shù)據(jù)庫(kù)
/opt/mongodb/bin/mongod --config /monogocluster/shard2/config/mongo-conf

數(shù)據(jù)庫(kù)恢復(fù)成功

--有時(shí)會(huì)出現(xiàn)這種報(bào)錯(cuò)
{"t":{"$date":"2024-09-29T15:38:40.833+08:00"}, F  STORAGE  [initandlisten] Please read the documentation for starting MongoDB with --repair here: http://dochub.mongodb.org/core/repair
{"t":{"$date":"2024-09-29T15:38:40.833+08:00"}, F  -        [initandlisten] Fatal Assertion 50944 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 922
{"t":{"$date":"2024-09-29T15:38:40.833+08:00"}, F  -        [initandlisten] \n\n***aborting after fassert() failure\n\n

執(zhí)行以下操作修復(fù)

[root@ data]# /opt/mongodb/bin/mongod --dbpath /monogocluster/shard1/data --repair


再次啟動(dòng)數(shù)據(jù)庫(kù)

查詢數(shù)據(jù)庫(kù)

[direct: mongos] test> use db2
switched to db db2
[direct: mongos] db2> db.user1.find()
[
  { _id: ObjectId("66f52c1a5e111baf0aa33a76"), id: 1, name: 'ty1' },
  { _id: ObjectId("66f52c1a5e111baf0aa33a7a"), id: 5, name: 'ty5' },
  { _id: ObjectId("66f52c1a5e111baf0aa33a7c"), id: 7, name: 'ty7' },
  { _id: ObjectId("66f52c1a5e111baf0aa33a7e"), id: 9, name: 'ty9' },
  { _id: ObjectId("66f52c1a5e111baf0aa33a7f"), id: 10, name: 'ty10' },
  { _id: ObjectId("66f52c1a5e111baf0aa33a82"), id: 13, name: 'ty13' }]

總結(jié)

WiredTiger 11.2.0 是一個(gè)強(qiáng)大且靈活的數(shù)據(jù)引擎,不僅提供了高效的數(shù)據(jù)存儲(chǔ)和檢索能力,還具備強(qiáng)大的數(shù)據(jù)恢復(fù)功能。通過(guò)合理的配置和優(yōu)化,WiredTiger 可以確保數(shù)據(jù)的完整性和可靠性,適用于多種高性能存儲(chǔ)和檢索場(chǎng)景。在使用過(guò)程中,合理配置和優(yōu)化是確保性能和數(shù)據(jù)安全的關(guān)鍵。通過(guò)注意配置優(yōu)化、數(shù)據(jù)一致性、性能監(jiān)控、安全性和升級(jí)維護(hù),可以充分發(fā)揮 WiredTiger 的優(yōu)勢(shì),滿足不同應(yīng)用場(chǎng)景的需求。

作者介紹

吳守陽(yáng),51CTO社區(qū)編輯,擁有8年DBA工作經(jīng)驗(yàn),熟練管理MySQL、Redis、MongoDB等開(kāi)源數(shù)據(jù)庫(kù)。精通性能優(yōu)化、備份恢復(fù)和高可用性架構(gòu)設(shè)計(jì)。善于故障排除和自動(dòng)化運(yùn)維,保障系統(tǒng)穩(wěn)定可靠。具備良好的團(tuán)隊(duì)合作和溝通能力,致力于為企業(yè)提供高效可靠的數(shù)據(jù)庫(kù)解決方案。

責(zé)任編輯:華軒 來(lái)源: 51CTO
相關(guān)推薦

2014-12-17 10:54:14

MongoDB

2017-09-07 15:43:24

數(shù)據(jù)庫(kù)MongoDBMySQL

2020-02-05 09:53:03

Windows 10系統(tǒng)文件Windows

2022-05-12 11:12:46

MongoDB索引元數(shù)據(jù)

2019-03-04 11:30:07

修復(fù)Windows 10系統(tǒng)文件

2021-07-09 18:26:41

PythonMySQL MongoDB

2010-06-17 17:26:21

如何修復(fù)Grub

2018-12-18 10:15:53

修復(fù)Windows 10DLL文件

2019-03-04 14:40:46

Linux文件系統(tǒng)修復(fù)

2018-08-16 10:15:41

修復(fù)Windows 10bootres.dll

2013-05-30 08:49:37

網(wǎng)絡(luò)路由路由修復(fù)路由

2010-06-17 12:57:27

如何修復(fù)Grub

2015-08-24 09:44:16

VMware快照VMDK

2018-06-04 15:35:39

修復(fù)Windows 10Windows

2018-05-30 14:29:14

WindowsWindows 10系統(tǒng)文件

2018-07-26 11:35:20

WindowsWindows 10修復(fù)

2018-03-06 09:30:58

2020-02-13 09:51:13

修復(fù)Windows 10配置文件

2016-01-05 10:06:09

軟件移植受損代碼代碼復(fù)制

2022-11-23 10:16:42

DebianUbuntu修復(fù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)