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的安裝
在Terminal中輸入:
cd cppcms-1.0.4/
mkdir build
cd build
cmake ..
make
make test
sudo make install
(三)、leveldb的安裝()
1、下載 leveldb-1.14.0.tar.gz(http://code.google.com/p/leveldb/downloads/detail?name=leveldb-1.14.0.tar.gz&can=2&q=)
2、tar zxvf leveldb-1.14.0.tar.gz
3、cd leveldb-1.14.0
4、make
5、sudo cp -r include/leveldb /usr/local/include
6、sudo cp libleveldb.a /usr/local/lib (或把libleveldb.a放到程序的統一路徑下)
(五)、protobuf的安裝(ok)
1、下載並解壓protobuf-2.5.0
2、cd protobuf-2.5.0/
3、./configure
4、make
5、make check
6、sudo make install
結果
Libraries have been installed in:
/usr/local/lib
Head files hava been installed in:
/usr/local/include/google/protobuf/
(六)mysql-connector-c++驅動安裝(ok)
1、下載mysql-connector-c++-1.1.3-linux-glibc2.3-x86-64bit.tar.gz
2、解壓:tar -zxvf mysql-connector-c++-1.1.3-linux-glibc2.3-x86-64bit.tar.gz
3、sudo cp mysql-connector-c++-1.1.3-linux-glibc2.3-x86-64bit/lib/* /usr/local/lib
4、sudo cp -r mysql-connector-c++-1.1.3-linux-glibc2.3-x86-64bit/include/* /usr/local/include
Linux 編譯安裝Boost
sudo yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
tar xvzf boost_1_50_0.tar.gz
cd boost_1_50_0
./bootstrap.sh
./b2
漫長的等待後
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/gang/BAK/boost_1_50_0
The following directory should be added to linker library paths:
/home/gang/BAK/boost_1_50_0/stage/lib
安裝
sudo./b2 install --prefix=/usr/local
安裝 zeromq
tar -zxvf zeromq-2.2.0.tar.gz
cd zeromq-2.2.0
./configure # 選擇安裝路徑可以(./configure --prefix=/data/zeromq)
make
sudo make install
ldconfig
如果在編譯過程中報錯找不到
zmq.hpp
文件
將
zmq.hpp
拷貝到
/usr/local/include/
即可。
#tar zxvf libunwind-0.98.6.tar.gz
#cd libunwind-0.98.6
#./configure
#make
#make install
#tar zxvf google-perftools-0.94.1.tar.gz
#cd google*
#./configure
#make
#make install
libxs的安裝
cd libxs
sudo ./autogen.sh
./configure
make
sudo make install
cppdb 的安裝
cd
cmake .
make
sudo make install
git clone https://github.com/zeromq/libzmq.git
cd libzmq
sudo ./autogen.sh
./configure
make
sudo make install
mysql 數據庫管理軟件的安裝
sudo apt-get install mysql-server
sudo apt-get install apache2
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
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);
}