[VerneMQ]_在RaspberrPi 3上編譯並安裝VerneMQ
因為Mosquitto不支援多thread以及Clustering的功能,所以接下來可能會棄Mosquitto轉往使用VerneMQ
而這東西在pc上很好裝,deb裝一裝就好,不過到了RPI3上,可是要過五關斬六將。
廢話不多說直接進入正題
編譯用的版本是
前置作業,你必須先裝好erlang跟libssl-dev
sudo apt-get install erlang libssl-dev
接著跟官方過程下的一樣:
git clone git://github.com/erlio/vernemq.git
cd vernemq
make rel
注意,不要加上-j,否則有可能會出問題…(問題三的可能來源)
首先先遭遇到的問題是
/home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.cc: In function ‘ERL_NIF_TERM parse_open_option(ErlNifEnv*, ERL_NIF_TERM, leveldb::Options&)’: /home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.cc:332:58: error: invalid conversion from ‘size_t* {aka unsigned int*}’ to ‘long unsigned int*’ [-fpermissive] if (enif_get_ulong(env, option[1], &memory_sz)) ^ In file included from /home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.h:27:0, from /home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.cc:35: /usr/lib/erlang/erts-6.2/include/erl_nif_api_funcs.h:43:27: note: initializing argument 3 of ‘int enif_get_ulong(ErlNifEnv*, ERL_NIF_TERM, long unsigned int*)’ ERL_NIF_API_FUNC_DECL(int,enif_get_ulong,(ErlNifEnv*, ERL_NIF_TERM term, unsigned long* ip)); ^ /usr/lib/erlang/erts-6.2/include/erl_nif.h:232:71: note: in definition of macro ‘ERL_NIF_API_FUNC_DECL’ # define ERL_NIF_API_FUNC_DECL(RET_TYPE, NAME, ARGS) extern RET_TYPE NAME ARGS ^ /home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.cc: In function ‘ERL_NIF_TERM eleveldb::async_open(ErlNifEnv*, int, const ERL_NIF_TERM*)’: /home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.cc:584:24: warning: integer overflow in expression [-Woverflow] if (8*1024*1024*1024L < gCurrentTotalMemory) ^ Makefile:65: recipe for target '/home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.o' failed make[1]: *** [/home/pi/vernemq/_build/default/lib/eleveldb/c_src/eleveldb.o] Error 1 make[1]: Leaving directory '/home/pi/vernemq/_build/default/lib/eleveldb/c_src' ===> Hook for compile failed! Makefile:56: recipe for target 'rel' failed make: *** [rel] Error 1
是因為ARM/Scaleway架構上兩處變數無法將int轉型成long unsigned int
因此需手動直接修改兩處宣告變數的地方
sudo vim ./_build/default/lib/eleveldb/c_src/eleveldb.cc
修改第243行,size_t memory_sz;變成unsigned long memory_sz;
修改第331行,size_t memory_sz;變成unsigned long memory_sz;
解法參考:https://github.com/bougueil/eleveldb/commit/bca0888ae8767f3759a2b002fc244b1a1f534c82、https://github.com/erlio/vernemq/issues/25
第二個問題基本上如果你前面有裝libssl-dev,則你不會碰到
===> Compiling vmq_acl ===> Compiling eper ===> Compiling vmq_passwd make[1]: Entering directory '/home/pi/vernemq/_build/default/lib/vmq_passwd/c_src' gcc vmq_passwd.c -lcrypto -o vmq_passwd vmq_passwd.c:32:25: fatal error: openssl/evp.h: No such file or directory #include <openssl/evp.h> ^ compilation terminated. Makefile:3: recipe for target 'compile' failed make[1]: *** [compile] Error 1 make[1]: Leaving directory '/home/pi/vernemq/_build/default/lib/vmq_passwd/c_src' ===> Hook for compile failed! Makefile:56: recipe for target 'rel' failed make: *** [rel] Error 1
解法就是裝好libssl-dev吧!
解法參考:http://stackoverflow.com/questions/3016956/how-do-i-install-the-openssl-c-library-on-ubuntu
第三個問題更奇怪了
/home/pi/vernemq/rebar3 release --overlay_vars vars.config ===> Verifying dependencies... ===> Compiling vmq_graphite ===> Compiling vmq_systree ===> Compiling vmq_bridge ===> Compiling recon ===> Compiling vmq_snmp ===> Running cuttlefish schema generator ===> Starting relx build process ... ===> Resolving OTP Applications from directories: /home/pi/vernemq/_build/default/lib /usr/lib/erlang/lib ===> Resolved vernemq-0.12.5p4 ===> Including Erts from /usr/lib/erlang ===> release successfully created! ===> Unable to copy from /home/pi/vernemq/_build/default/lib/vmq_passwd/c_src/vmq_passwd to /home/pi/vernemq/_build/default/rel/vernemq/bin/vmq-passwd because of {copy_failed, enoent} Makefile:56: recipe for target 'rel' failed make: *** [rel] Error 127
解法就是刪除vernemq/_build/default/lib/vmq_passwd/c_src/vmq_passwd整個資料夾,並且重新make rel
解法參考:https://github.com/erlio/vernemq/issues/122
若還是碰到…
pi@raspberrypi:~/vernemq $ sudo make rel /home/pi/vernemq/rebar3 release --overlay_vars vars.config ===> Verifying dependencies... ===> Fetching vmq_passwd ({git, "git://github.com/erlio/vmq_passwd.git", {ref, "a2a2ea7786e8bc9e2bfb1fbe516b0d54c6b060d8"}}) ===> Failed to fetch and copy dep: {git,"git://github.com/erlio/vmq_passwd.git", {ref, "a2a2ea7786e8bc9e2bfb1fbe516b0d54c6b060d8"}} Makefile:56: recipe for target 'rel' failed make: *** [rel] Error 1 pi@raspberrypi:~/vernemq $ sudo make rel
檢查網路ok後,重新下一次make rel即可!
2016/08/07 補充
若你要PORT的版本是0.13以上,可能會遭遇ARM架構上因為沒有CPUID.H而編譯失敗的問題,這個問題我有發ISSUE,得到官方回覆的快速骯髒解XD
因為ARM本來就沒在支援清單上,但官方還是簡單的說明如何拿掉CPU最佳化的CODE,測試後一般功能大致上沒什麼問題
英文好的可以直接參考:https://github.com/erlio/vernemq/issues/175
簡單來說就是在遭遇錯誤時,在vernemq資料夾底下建立一個 _checkouts 資料夾,並把 _build/default/lib/mzmetrics 移動到該_checkouts資料夾內
並修改 _checkouts/mzmetrics/c_src/mzmetrics_counters_no_preallocation.c
將第三行的 #include <cpuid.h> 移除或者註解
接著第三十三行的mycpu function內前置處理器部分修改成下列樣子
int mycpu(void) { #ifdef PCPU_COUNTERS #ifdef __linux__ return sched_getcpu(); #else unsigned int eax, ebx, ecx, edx; if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) return 0; return 0; #endif #else return 0; #endif }
儲存後再make rel試試看~
Leave a comment
很抱歉,必須登入網站才能發佈留言。