Kidoisaboy 2019-06-20
gRPCæ¯ç±Google主导å¼åçRPCæ¡æ¶ï¼ä½¿ç¨HTTP/2å议并ç¨ProtoBufä½ä¸ºåºååå·¥å·ãå¶å®¢æ·ç«¯æä¾Objective-CãJavaæ¥å£ï¼æå¡å¨ä¾§åæJavaãGolangãC++çæ¥å£ï¼ä»è为移å¨ç«¯ï¼iOS/Androiï¼å°æå¡å¨ç«¯é讯æä¾äºä¸ç§è§£å³æ¹æ¡ã å½ç¶å¨å½ä¸çç¯å¢ä¸ï¼è¿ç§è§£å³æ¹æ¡æ´çé¨çæ¹å¼æ¯RESTFull APIæ¥å£ã该æ¹å¼éè¦èªå·±å»éæ©ç¼ç æ¹å¼ãæå¡å¨æ¶æãèªå·±æ建æ¡æ¶ï¼JSON-RPCï¼ã
1. åæ
2. ä¸è½½protocol buffer v3çæ¬ç¼è¯å¨
ä¸è½½å°åï¼ https://github.com/google/protobuf/releases
å½åææ°çæ¬ä¸ºv3.5.1
3. ä¸è½½protocçgolangæ件
go get -u github.com/golang/protobuf/protoc-gen-go ## ä¸è½ç´æ¥è®¿é®google.golang.orgç½åæ¶, ä»githubä¸è½½ç¶åæ¾å°google.golang.orgç®å½ mkdir -p src/google.golang.org/ cd src/google.golang.org git clone https://github.com/google/go-genproto genproto
4. ä¸è½½golangå®ç°çgrpc
## å¯ç´æ¥è®¿é®google.golang.orgæ¶ go get -u google.golang.org/grpc ## åæ ·ä¸è½è®¿é®google.golang.orgæ¯éç¨çæ¹æ³ mkdir -p src/google.golang.org cd src/google.golang.org git clone https://github.com/grpc/grpc-go grpc cd - ## å¦å¤ï¼ grpcä¾èµçå¶ä»åéè¦ä¸å¹¶ä¸è½½ mkdir -p src/golang.org/x cd src/golang.org/x git clone https://github.com/golang/net git clone https://github.com/golang/text cd -
5. ç¼åç¨äºgRPCçpbæ件
6. ç¼è¯pbçægo代ç
7. ç¼å客æ·ç«¯æå¡ç«¯ä»£ç 并ç¼è¯è¿è¡
ä¸è¿°ä¸æ¥å¯ä»¥åègrpc-goç示ä¾ä»£ç
8. è¡¥åglibcå级æ¥éª¤
æ¥çglibcçæ¬å·
strings /lib64/libc.so.6 | grep GLIBC_
ä¸è½½å¹¶å®è£glibc
tar -zxf glibc-2.14.tar.gz cd glibc-2.14 mkdir build cd build ../configure --prefix=/opt/glibc-2.14 make && make install
å¶ä½è½¯è¿æ¥
rm -f /lib64/libc.so.6 ln -s /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
注æé®é¢
å é¤libc.so.6ä¹åä¼å¯¼è´ç³»ç»å½ä»¤ä¸å¯ç¨çæåµ
ä¾å¦æ示ï¼
rm: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
解å³åæ³ï¼
LD_PRELOAD=/opt/glibc-2.14/lib/libc-2.14.so ln -s /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
å¦æå级失败ï¼åæ»æ¹æ³ï¼
LD_PRELOAD=/lib64/libc-2.12.so ln -s /lib64/libc-2.12.so /lib64/libc.so.6
æ»ç»
以ä¸æè¿°æ¯å°ç¼ç»å¤§å®¶ä»ç»çgo grpcå®è£ä½¿ç¨æç¨ï¼å¸æ对大家ææ帮å©ï¼å¦æ大家æä»»ä½çé®è¯·ç»æçè¨ï¼å°ç¼ä¼åæ¶åå¤å¤§å®¶çãå¨æ¤ä¹é常æ谢大家对èæ¬ä¹å®¶ç½ç«çæ¯æï¼