sudo apt-get install libgoogle-perftools-dev
sudo apt-get install cmake
sudo apt-get install git
git clone https://github.com/crossroads-io/libxs.git
git clone https://github.com/zeromq/cppzmq.git
git clone https://github.com/250bpm/cppxs.git
sudo apt-get install libmysqlclient18
sudo apt-get install libmysqlclient-dev
sudo apt-get install libmysql-cil-dev
sudo apt-get install libsqlite3-dev
git clone https://github.com/zeromq/libzmq.git
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev
http://blog.csdn.net/csfreebird/article/details/9626577 install gcc 4.8.1
http://sourceforge.net/projects/boost/files/boost/1.55.0.beta.1/ install boost 1.55a1
http://sourceforge.net/projects/stlsoft/files/STLSoft%201.9/1.9.117/ stlsoft
http://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/1.0.1%20%28beta%20214%29/ pantheios
http://sourceforge.net/projects/fastformat/files/fastformat/0.7/0.7.1/0.7.1%20%28alpha%209%29/ fastformat
http://code.google.com/p/leveldb/downloads/list leveldb
http://code.google.com/p/protobuf/downloads/list protobuf
http://sourceforge.net/projects/cppcms/files/cppcms/1.0.4/ cppcms
http://sourceforge.net/projects/cppcms/files/cppdb/0.3.1/ cppdb
http://www.codeblocks.org/downloads/26 codeblocks
http://dev.mysql.com/downloads/connector/cpp/ mysql c++ conn
(二)、CppCMS的安装
cd cppcms-1.0.4/
mkdir build
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
在/etc/profile中配置一下变量
STLSOFT=/home/dm/lib/stlsoft-1.9.117
export STLSOFT
PANTHEIOS_ROOT=/home/dm/lib/pantheios-1.0.1-beta214
export PANTHEIOS_ROOT
FASTFORMAT_ROOT=/home/dm/lib/fastformat-0.7.1-alpha-9
export FASTFORMAT_ROOT
Leveldb是一个google实现的非常高效的kv数据库,
目前的版本1.2能够支持billion级别的数据量了。
在这个数量级别下还有着非常高的性能,主要归功于它的良好的设计。特别是LSM算法
LevelDB 是单进程的服务,性能非常之高,在一台4个Q6600的CPU机器上,
每秒钟写数据超过40w,而随机读的性能每秒钟超过10w。
此处随机读是完全命中内存的速度,如果是不命中 速度大大下降
LevelDB 只是一个 C/C++ 编程语言的库, 不包含网络服务封装,
所以无法像一般意义的存储服务器(如 MySQL)那样, 用客户端来连接它.
LevelDB 自己也声明, 使用者应该封装自己的网络服务器.
1、打开数据库
#include "leveldb/db.h"
leveldb::DB* db;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
编译带上参数 -lleveldb -lpthread
2、关闭数据库
delete db;
3、大部分的leveldb的函数都会返回Status,可检测他的状态status.ok()来查询是否执行成功
4、增删改
std::string value;
leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
if (s.ok()) s = db->Put(leveldb::WriteOptions(), key2, value);
if (s.ok()) s = db->Delete(leveldb::WriteOptions(), key1);
5、原子操作
#include "leveldb/write_batch.h"
std::string value;
leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
if (s.ok()) {
leveldb::WriteBatch batch;
batch.Delete(key1);
batch.Put(key2, value);
s = db->Write(leveldb::WriteOptions(), &batch);
}