官方文档:https://github.com/NarrativeScience/Log.io/wiki/v0.3.4-Build-Recipe-(Ubuntu-14.04)node
The following recipe was used to build a Log.io environment on a fresh Ubuntu 14.04 install (ami-864d84ee), using node.js v0.10.29nginx
1.安装node.js和cnpm
详细步骤:https://blog.51cto.com/qiangsh/2095944
2.安装log.iocnpm install -g log.io --user "root"
----root为用户名,这里必须指定一个用户名。由于 log.io 须要在用户的根目录里面创建目录,存放配置信息。c++
报错信息:git
> node-gyp rebuild make: Entering directory `/usr/local/node/lib/node_modules/log.io/node_modules/contextify/build' CXX(target) Release/obj.target/contextify/src/contextify.o In file included from ../src/contextify.cc:3: ../../nan/nan.h:47:3: error: #error This version of node/NAN/v8 requires a C++11 compiler In file included from /root/.node-gyp/4.8.7/include/node/node.h:42, from ../src/contextify.cc:1: ......................................................................................................................................... ......................................................................................................................................... make: *** [Release/obj.target/contextify/src/contextify.o] Error 1 make: Leaving directory `/usr/local/node/lib/node_modules/log.io/node_modules/contextify/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:258:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12) gyp ERR! System Linux 2.6.32-696.18.7.el6.x86_64 gyp ERR! command "/usr/local/node/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/node/lib/node_modules/log.io/node_modules/contextify gyp ERR! node -v v4.8.7 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! contextify@0.1.15 install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the contextify@0.1.15 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-04-10T05_36_19_069Z-debug.log
解决方法:github
wget http://people.centos.org/tru/devtools-2/devtools-2.repo yum install devtoolset-2-gcc devtoolset-2-gcc-c++ scl-utils export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++ scl enable devtoolset-2 bash
3.上三步在server和client端都要安装,安装完成后,会在~/.log.io/目录下生成如下几个文件web
harvester.conf #客户端配置 log_server.conf web_server.conf #服务端配置
4.服务端配置express
vim web_server.conf exports.config = { host: '0.0.0.0', port: 28778, // Enable HTTP Basic Authentication auth: { user: "admin", pass: "123456" }, /* // Enable HTTPS/SSL ssl: { key: '/path/to/privatekey.pem', cert: '/path/to/certificate.pem' }, */ /* // Restrict access to websocket (socket.io) // Uses socket.io 'origins' syntax restrictSocket: '*:*', */ /* // Restrict access to http server (express) restrictHTTP: [ "192.168.29.39", "10.0.*" ] */ }
5.客户端配置,设置日志收集来源npm
vim /root/.log.io/harvester.conf exports.config = { nodeName: "nodeB", ####修改节点名称(自定义) logStreams: { nginx_access: [ ####日志服务的名称(自定义) "/var/log/nginx/access.log", ###日记存储路径 ], nginx_error: [ ####日志服务的名称(自定义) "/var/log/nginx/error.log" ###日记存储路径 ] }, server: { host: '10.10.0.2', ####log.io Server端的IP port: 28777 ####log.io Server端的端口(默认端口) } }
6.启动服务端nohup log.io-server &
vim
7.启动客户端nohup log.io-harvester &
centos
8.修改log.io的一处bug
vi /usr/local/lib/node_modules/log.io/lib/harvester.js if (event === 'change') { return fs.stat(path, function(err, stat) { var tmp_total = !err ? (stat.size || 0) : 0; if (tmp_total > 0) { _this._readNewLogs(path, tmp_total, currSize); return currSize = tmp_total; } else { return tmp_total; } }); }
9.其余问题
给npm设置代理
npm config set proxy=http://127.0.0.1:8087 npm config set registry=http://registry.npmjs.org
切换npm源,能够用淘宝的