rocksdb安装与使用

news/2025/3/19 15:42:50/文章来源:https://www.cnblogs.com/lightdb/p/17738820.html
首先要安装gcc 7.3以上版本,依赖于c++ 17.
参见
gcc 7安装及4.8.5和7.5并存。
需要rpm方式或源码安装gflags 2.2,否则系统可能内置了gflags 2.1,从而导致链接时一直找不到gflags库。如下:
/tmp/ccUXmr9R.o: In function `__static_initialization_and_destruction_0(int, int)':
/home/zjh/test_gflags.cpp:4: undefined reference to `google::FlagRegisterer::FlagRegisterer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: error: ld returned 1 exit status
离线库可从https://pan.baidu.com/s/1P-LAEfJQbJfhbsda1Cd0QQ?pwd=vcu5下载。
cd gflags-2.2.2
mkdir build && cd build
注意:记得先清理干净。

cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=ON -DINSTALL_STATIC_LIBS=ON ..
make -j4
make install

tar -xzvf v8.5.4.tar.gz
cd rocksdb-8.5.4/
make static_lib
make shared_lib
 make 生成rocksdb辅助工具如db_bench等,注意默认生成的是debug模式,所以需要动态库和静态库先独立生产,然后再跑make。但是除了上面的动态库和静态库,最好是一次性跑make,不要单独跑make xxx
 
make db_bench报错,如下:

[zjh@hs-10-20-30-193 rocksdb-8.5.4]$ make db_bench
$DEBUG_LEVEL is 1, $LIB_MODE is shared
Makefile:166: Warning: Compiling in debug mode. Don't use the resulting binary in production
CCLD db_bench
tools/db_bench_tool.o: In function `rocksdb::CompressData(rocksdb::Slice const&, rocksdb::CompressionInfo const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
/home/zjh/cpp_demo/rocksdb-8.5.4/./util/compression.h:1583: undefined reference to `rocksdb::SyncPoint::GetInstance()'
tools/db_bench_tool.o: In function `void rocksdb::SyncPoint::Process<35ul>(char const (&) [35ul], void*)':
/home/zjh/cpp_demo/rocksdb-8.5.4/./test_util/sync_point.h:132: undefined reference to `rocksdb::SyncPoint::Process(rocksdb::Slice const&, void*)'
tools/db_bench_tool.o: In function `rocksdb::SimCache* rocksdb::static_cast_with_check<rocksdb::SimCache, rocksdb::Cache>(rocksdb::Cache*)':
/home/zjh/cpp_demo/rocksdb-8.5.4/./util/cast_util.h:22: undefined reference to `typeinfo for rocksdb::Cache'
tools/db_bench_tool.o:(.data.rel.ro._ZTIN7rocksdb12CacheWrapperE[_ZTIN7rocksdb12CacheWrapperE]+0x10): undefined reference to `typeinfo for rocksdb::Cache'
tools/db_bench_tool.o:(.data.rel.ro._ZTIN7rocksdb22FileChecksumGenFactoryE[_ZTIN7rocksdb22FileChecksumGenFactoryE]+0x10): undefined reference to `typeinfo for rocksdb::Customizable'
tools/db_bench_tool.o:(.data.rel.ro._ZTIN7rocksdb13EventListenerE[_ZTIN7rocksdb13EventListenerE]+0x10): undefined reference to `typeinfo for rocksdb::Customizable'
tools/db_bench_tool.o:(.data.rel.ro._ZTIN7rocksdb16CompactionFilterE[_ZTIN7rocksdb16CompactionFilterE]+0x10): undefined reference to `typeinfo for rocksdb::Customizable'
test_util/testutil.o:(.data.rel.ro._ZTIN7rocksdb18MemTableRepFactoryE[_ZTIN7rocksdb18MemTableRepFactoryE]+0x10): undefined reference to `typeinfo for rocksdb::Customizable'
test_util/testutil.o:(.data.rel.ro._ZTIN7rocksdb10ComparatorE[_ZTIN7rocksdb10ComparatorE]+0x18): undefined reference to `typeinfo for rocksdb::Customizable'
test_util/testutil.o:(.data.rel.ro._ZTIN7rocksdb23CompactionFilterFactoryE[_ZTIN7rocksdb23CompactionFilterFactoryE]+0x10): more undefined references to `typeinfo for rocksdb::Customizable' follow
test_util/testutil.o:(.data.rel.ro._ZTIN7rocksdb4test22ChanglingMergeOperatorE[_ZTIN7rocksdb4test22ChanglingMergeOperatorE]+0x10): undefined reference to `typeinfo for rocksdb::MergeOperator'
test_util/testutil.o:(.data.rel.ro._ZTIN7rocksdb15MockSystemClockE[_ZTIN7rocksdb15MockSystemClockE]+0x10): undefined reference to `typeinfo for rocksdb::SystemClockWrapper'
test_util/testutil.o:(.data.rel.ro+0x28): undefined reference to `typeinfo for rocksdb::MemTableRep'
tools/simulated_hybrid_file_system.o:(.data.rel.ro._ZTIN7rocksdb25SimulatedHybridFileSystemE[_ZTIN7rocksdb25SimulatedHybridFileSystemE]+0x10): undefined reference to `typeinfo for rocksdb::FileSystemWrapper'
collect2: error: ld returned 1 exit status
make: *** [db_bench] Error 1

但是rocksdb so已经存在了LD_LIBRARY_PATH指向的目录了。

make all时也报错,类似:

[zjh@hs-10-20-30-193 rocksdb-8.5.4]$ make all
$DEBUG_LEVEL is 1, $LIB_MODE is shared
Makefile:166: Warning: Compiling in debug mode. Don't use the resulting binary in production
CCLD table_reader_bench
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::DB'
./librocksdb_test_debug.so: undefined reference to `rocksdb::DBImpl::TEST_MaxNextLevelOverlappingBytes(rocksdb::ColumnFamilyHandle*)'
./librocksdb_test_debug.so: undefined reference to `rocksdb::DBImpl::TEST_WaitForCompact()'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::Env'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::ClearAllCallBacks()'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::Process(rocksdb::Slice const&, void*)'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::ClearCallBack(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::DBImpl'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::DisableProcessing()'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::MemTableRep'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::Cache'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::WritableFile'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::SystemClockWrapper'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::EnvWrapper'
./librocksdb_test_debug.so: undefined reference to `rocksdb::DBImpl::TEST_CompactRange(int, rocksdb::Slice const*, rocksdb::Slice const*, rocksdb::ColumnFamilyHandle*, bool)'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::LoadDependency(std::vector<rocksdb::SyncPoint::SyncPointPair, std::allocator<rocksdb::SyncPoint::SyncPointPair> > const&)'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::EnableProcessing()'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::MergeOperator'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::SequentialFile'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::Customizable'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::CompositeEnvWrapper'
./librocksdb_test_debug.so: undefined reference to `typeinfo for rocksdb::RandomAccessFile'
./librocksdb_test_debug.so: undefined reference to `rocksdb::DBImpl::TEST_WaitForFlushMemTable(rocksdb::ColumnFamilyHandle*)'
./librocksdb_test_debug.so: undefined reference to `rocksdb::SyncPoint::GetInstance()'
collect2: error: ld returned 1 exit status

原因:rocksdb.so和rocksdb.a用release版本编译,make使用debug,是不兼容的。

参见:https://github.com/facebook/rocksdb/issues/10072、https://github.com/facebook/rocksdb/issues/4329。

解决方法就是:用cmake编译release版本,或都是debug版。

delete db后,rocksdb仍然还有很多rocksdb:low, rocksdb:high线程,如下:

原因是:这俩是后台清理线程,详见https://blog.csdn.net/qq_30708747/article/details/120307971。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/777589.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

WPF【无限滚动图片浏览】自定义控件

自定义控件自定义控件是我比较陌生的一个主题。我好久没练习过wpf了,需要巩固记忆。我想了一会儿,打开动漫之家,忽然觉得这个看漫画的图片浏览控件有意思。于是特地花了一天做了这个图片控件。我原本以为很容易,但实际上并不简单。这个图片浏览控件比我想象中要难许多,有技…

矩阵乘法内核优化CUDA杂谈

矩阵乘法内核优化CUDA杂谈矩阵乘法内核优化CUDA杂谈How to Optimize a CUDA Matmul Kernel for cuBLAS-like Performance: a Workloghttps://siboehm.com/articles/22/CUDA-MMM在这篇文章中,我将迭代优化用CUDA编写的矩阵乘法的实现。我的目标不是构建cuBLAS的替代品,而是深入…

Cocos Creator 3.8.x bundle核心知识点

bundle官网知识文档: https://docs.cocos.com/creator/3.8/manual/zh/asset/bundle.html bundle核心知识点如下:

python-sum()返回所有元素的总和

lb=[10,30,5,40,89,100] i=sum(lb) #返回所有元素的总和 #参数:序列 print(i)

python-max()返回最大值

lb=[10,30,5,40,89,100] i=max(lb) #返回最大值 #参数:序列 print(i)

python-min返回最小值

lb=[10,30,5,40,89,100] i=min(lb) #返回最小值 #参数:序列 print(i)

windows 隐藏桌面了解此图片

1. 桌面上有了解此图片图标无法删除这是因为在windows背景设置中选择了Window聚焦。如果想关闭可以选择其他选项。如果不想关闭Window聚焦还想隐藏桌面了解此图片图标,可以参考下面设置。 2. 打开注册表 win + x打开运行,输入regedit 回车。 3. 新建或修改注册表 在注册表的地…

[vue3] vue3对比vue2优化项简要概述

Vue2存在源码可维护性差、性能问题和API兼容性不足等缺点。Vue3通过monorepo管理、TypeScript开发、性能优化和引入Composition API等方式,显著提升了源码可维护性、编程体验、TypeScript支持和逻辑复用实践,从源码、性能和语法API三方面进行了优化。不足与展望 Vue2的不足源…

DevOps实践

DevOps 一、DevOps介绍 软件开发最开始是由两个团队组成:开发计划由开发团队从头开始设计和整体系统的构建。需要系统不停的迭代更新。 运维团队将开发团队的Code进行测试后部署上线。希望系统稳定安全运行。这看似两个目标不同的团队需要协同完成一个软件的开发。 在开发团队…

高考结束咯,录取结束咯,通知书下来咯,即将开启大学生活咯!

高考结束咯,录取结束咯,通知书下来咯,即将开启大学生活咯!高考结束咯,自我感觉良好,期待着结果出来 结果高考成绩一出来吓我一大跳,657分,比预想中的高了几十分,哈哈哈哈哈哈但是我最关心的人却考砸了,也不知道是不是我的问题(虽然ta比我高),真是逆天!下面是高考…

LeetCode 1557. Minimum Number of Vertices to Reach All Nodes

原题链接在这里:https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/description/ 题目: Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed e…