日誌流聚集工具Log.io V0.3.4安裝過程

官方文檔: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.io
cnpm 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源,能夠用淘寶

相關文章
相關標籤/搜索