学习使用MongoDB C Driver需要首先在本机安装mongodb,安装过程参考如下链接:
How to Install and Configure MongoDB on CentOS 7

启动mongodb存在告警信息,解决方法可以参考stackoverflow

升级cmake

由于centos7自带的cmake版本过低,因此需要升级cmake

root@localhost ~]# yum -y install gcc gcc-c++ kernel-devel  ##先安装编译软件
[root@localhost ~]# wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz
[root@localhost ~]# tar -zxvf cmake-3.10.2.tar.gz  
[root@localhost ~]# cd cmake-3.10.2
[root@localhost cmake-3.10.2]# ./bootstrap --prefix=安装目录(默认为/usr/local)
[root@localhost cmake-3.10.2]# gmake
[root@localhost cmake-3.10.2]# make install

安装完成查看cmake版本确认安装成功:

[root@centos-7 cmake-3.10.2]# cmake -version
cmake version 3.10.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

安装mongodb c driver

安装过程参考mongodb c driver官方网站mongodb c driver,具体安装步骤如下:

$ wget https://raw.githubusercontent.com/mongodb/mongo-c-driver/releases/download/x.y.z/mongo-c-driver-x.y.z.tar.gz
$ tar xzf mongo-c-driver-x.y.z.tar.gz
$ cd mongo-c-driver-x.y.z
$ mkdir cmake-build
$ cd cmake-build
$ cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
$ make
$ sudo make install

启动过程告警

输入mongo启动,显示如下告警:

2019-03-06T21:01:15.526-0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-03-06T21:01:15.526-0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

参考官方文档解决方法mongodb

mongodb入门

学习gitbook中mongodb入门教程