安装ceph环境:ceph 客户端配置_worker_program的博客-优快云博客
默认安装的话头文件位置为/usr/include/rados
安装成功配置好配置文件后
[root@bogon StorageMedia]# rados lspools
.rgw.root
default.rgw.control
default.rgw.meta
default.rgw.log
rdb
tmVideoPool
tmVideoDataPool
default.rgw.buckets.index
default.rgw.buckets.data
说明客户端连接配置正常,测试代码:
#include <rados/librados.hpp>
#include <iostream>
#include <string>
#include <list>
int main(int argc, const char **argv)
{
int ret = 0 ;
// Get cluster handle and connect to cluster
std::string cluster_name("ceph");
std::string user_name("client.admin");
librados::Rados cluster ;
cluster.init2(user_name.c_str(), cluster_name.c_str(), 0);
cluster.conf_read_file("/etc/ceph/ceph.conf");
cluster.connect();
// Print the list of pools
std::list<std::string> pools ;
cluster.pool_list(pools );
std::cout << "List of pools from this cluster handle" << std::endl ;
for (std::list<std::string>::iterator i = pools.begin(); i != pools.end(); ++i)
std::cout << *i << std::endl;
// Cleanup
io_ctx.close();
cluster.shutdown();
return 0 ;
}
编译命令:g++ -std=c++11 rados_test.cpp -lrados -o rados_test
[root@bogon test]# ./radio_test
List of pools from this cluster handle
.rgw.root
default.rgw.control