octo-rpc 和 octo-ns
参考 https://github.com/Meituan-Dianping/octo-rpc/blob/master/whale/docs/Quick_start.md
和
https://github.com/Meituan-Dianping/octo-ns/tree/master/sdk/mns-sdk
###########.注意的地方:
#############centos7
这个依赖thrift和muduo,
主要检查thrift的配置 和muduo的配置, 如果是/usr/local/之类的我们都可能要改,
我们thrift装在/usr/local/thrift下
muduo自己装可能有问题,尽量用cmake下的
如果是一堆错误,可能是这个
SET( CMAKE_CXX_FLAGS "-std=c++11 -O3")
octo-ns/sdk/mns-sdk/src/mns_worker.h:144:19: 错误:字段‘wp_conn_info’类型不完全
这种错误是boost错误,用 yum的,不要自己装,会把系统装坏了,再yum也不行了
######octo-ns ###############.
### sdk 参考https://github.com/Meituan-Dianping/octo-ns/tree/master/sdk/mns-sdk
#
git clone https://github.com/Meituan-Dianping/octo-ns yum install epel-release yum install git gcc-c++ cmake yum install uuid uuid-devel libuuid-devel -y #在编译example的时候需要uuid yum install boost-devel zlib-devel log4cplus-devel rapidjson-devel yum install cmake curl curl-devel openssl openssl-devel protobuf protobuf-devel -y
muduo用octo来安装 ,boost也yum装
手动安装thrift-0.8.0 前提是要装好boost和protobuf和openssl
./configure --prefix=/usr/local/thrift --without-python --without-csharp --without-erlang --without-go --without-haskell --without-ruby --without-perl --without-php --without-php_extension make make install
export LANG=en_US.UTF-8
提示错误方便点
###########
./build.sh init的时候
可能出现
muduo的安装有问题
#####错误:
‘off_t’ does not name a type
vim muduo/base/StringPiece.h
#include
可能有很多错误,尝试-std=c++11
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3")
############
./build.sh only_lib
如果thrift找不到
CMakeLists.txt
SET(THRIFT_COMPILER "/usr/local/thrift/bin/thrift") SET(THRIFT_INCLUDE_DIR "/usr/local/thrift/include") #SET(THRIFT_LIBRARY "/usr/local/thrift/lib") SET(THRIFT_LIBRARY "/usr/local/thrift/lib/libthrift.a")
这三个变量检查一下
INCLUDE_DIRECTORIES("/usr/local/thrift/include")
或者INCLUDE_DIRECTORIES("/usr/local/thrift/include/thrift")
LINK_DIRECTORIES("/usr/local/thrift/lib")
#########################octo-rpc 框架
git clone https://github.com/Meituan-Dianping/octo-rpc #thrift和zookeeper的位置 octo-rpc/whale cmake/FindThrift.cmake #set(THRIFT_INCLUDE_DIR_S /usr/include) #set(THRIFT_INCLUDE_DIR_S /usr/lib64/) 改成 set(THRIFT_INCLUDE_DIR_S /usr/local/thrift/include) set(THRIFT_LIB_DIR_S /usr/local/thrift/lib) find_path(THRIFT_INCLUDE_DIR NAMES thrift/ PATHS ${THRIFT_INCLUDE_DIR_S}) #find_library(THRIFT_LIBRARY NAMES libthrift.a PATHS ${THRIFT_INCLUDE_DIR_S}) find_library(THRIFT_LIBRARY NAMES libthrift.a PATHS ${THRIFT_LIB_DIR_S}) CMakeLists.txt SET(THRIFT_COMPILER "/usr/local/thrift/bin/thrift") SET(THRIFT_INCLUDE_DIR "/usr/local/thrift/include") SET(THRIFT_LIBRARY "/usr/local/thrift/lib")
###########
zookeeper: 3.4.6版本,版本不一样api不一样,
yum install automake autoconf cppunit cppunit-devel ant -y yum install libtool libtool-devel -y
没有会报错:possibly undefined macro: AC_PROG_LIBTOOL
ant compile-native
前面加
SET(ZOOKEEPER_INCLUDE_DIR "/opt/mt/setup/zookeeper/build/c/build/include")
SET(ZOOKEEPER_LIBRARY "/opt/mt/setup/zookeeper/build/c/build/lib")
后面加
INCLUDE_DIRECTORIES("/opt/mt/setup/zookeeper/build/c/build/include")
LINK_DIRECTORIES("/opt/mt/setup/zookeeper/build/c/build/lib")
否则可能报错:
/opt/mt/octo-rpc/whale/cthrift/util/zk_client.cc:273:70: error: ‘zoo_get’ was not declared in this scope
ret = zoo_get(m_zh, path, watch, buff_ptr.get(), buffer_len, stat);
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3")
########错误 htonll ntoll 这个在thrift 0.8.0里面重新定义了,和系统的不一样, 所以注意thrift的include的路径,有的带thrift有的不带thrift,这个容易出错
/data2/octo/mtransport/setup/octo-ns/sg_agent/thrid_party/cthrift/include/cthrift/cthrift_tbinary_protocol.tcc:296:39: error: use
of undeclared identifier 'htons'
int16_t net = static_cast
这种问题都是include路径不对
检查SET 变量 和
INCLUDE_DIRECTORIES("")
LINK_DIRECTORIES("")
INCLUDE_DIRECTORIES(system ${CMAKE_SOURCE_DIR}/thrid/include/thrift)
要改
INCLUDE_DIRECTORIES(system ${CMAKE_SOURCE_DIR}/thrid/include)
#INCLUDE_DIRECTORIES(system ${CMAKE_SOURCE_DIR}/thrid/include/thrift)
INCLUDE_DIRECTORIES(/usr/local/thrift/include/thrift)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/thrid/lib/)
LINK_DIRECTORIES(/usr/local/thrift/lib/)
########错误:
/opt/mt/octo-rpc/whale/cthrift/cthrift_client.cc:105:74: error: no matching function for call to ‘make_pair(std::string&, boost::shared_ptr
sp_cthrift_client_worker_));
https://www.cnblogs.com/zl1991/p/7699510.html
https://codeday.me/bug/20170727/45258.html
这个在c++11 的时候,类似java的泛型变严格了 ,需要去掉严格限制
把
map_appkey_worker_.insert(
std::make_pair
改成
//modify by hao
map_appkey_worker_.insert(
//std::make_pair
std::make_pair(map_key,sp_cthrift_client_worker_));
##################在编译example的时候,可能找不到thrift的库或者 muduo的库
要仔细看,如果加了 -std=c++11的选项
则mudo的库在
/usr/local/lib/libmuduo_base_cpp11.a
/usr/local/lib/libmuduo_net_cpp11.a
-- MUDUO_BASE_LIBRARY /usr/local/lib/libmuduo_base_cpp11.a
-- MUDUO_NET_LIBRARY /usr/local/lib/libmuduo_net_cpp11.a
要修改cmake/FindMuduo.cmake
find_library(MUDUO_LIBRARY NAMES libmuduo_base_cpp11.a PATHS ${MUDUO_LIBRARY_S})
和 CMakeLists.txt中的
#find_library(MUDUO_BASE_LIBRARY libmuduo_base.a) find_library(MUDUO_BASE_LIBRARY libmuduo_base_cpp11.a) #find_library(MUDUO_NET_LIBRARY libmuduo_net.a) find_library(MUDUO_NET_LIBRARY libmuduo_net_cpp11.a)
如果是thrift找不到:
在CMakeLists.txt里面加
INCLUDE_DIRECTORIES(/usr/local/thrift/include/thrift)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/thrid/lib/)
LINK_DIRECTORIES(/usr/local/thrift/lib/)
检查
SET(THRIFT_COMPILER "/usr/local/thrift/bin/thrift")
SET(THRIFT_INCLUDE_DIR "/usr/local/thrift/include")
#SET(THRIFT_LIBRARY "/usr/local/thrift/lib")
SET(THRIFT_LIBRARY "/usr/local/thrift/lib/libthrift.a")
#################