仮想通貨サービス BitCapitalZ の日記

仮想通貨関連のブログです Ripple, Ethereum 仮想通貨2.0に注目しています

【Ripple】Ripple Data API サーバーを自前で用意する方法

必要なパッケージを入れる

$ sudo apt-get install make
$ sudo apt-get install g++
$ sudo apt-get install couchdb

couchdb セットアップ

$ curl -i -X PUT "http://localhost:5984/ripple-data-api"
$ curl -X PUT http://localhost:5984/_config/admins/user -d '"password"'

nodebrewを入れる

$ curl -L git.io/nodebrew | perl - setup
$ echo "export PATH=$HOME/.nodebrew/current/bin:$PATH" >> ~/.bashrc
$ source ~/.bashrc

nodejs と npm 入れる。nodejs のバーションはv0.10.25だとまともに動かなかったのでv0.10.26を使いました

$ nodebrew install-binary v0.10.26 
$ nodebrew use v0.10.26
$ node -v
v0.10.26
$ npm -v
1.4.3
$ npm install -g grunt-cli

ripple-data-api の用意

$ git clone https://github.com/ripple/ripple-data-api.git
$ cd ripple-data-api
$ git checkout master
$ npm install
$ cp db.config.json.example db.config.json
$ cp deployment.environments.json.example deployment.environments.json

db.config.json を以下のように編集

{
  "development" : {
    "username" : "user",
    "password" : "password",
    "host"     : "localhost",
    "port"     : 5984,
    "database" : "ripple-data-api",
    "protocol" : "http"
  },

  "staging" : {
    "username" : "REDACTED",
    "password" : "REDACTED",
    "host"     : "localhost",
    "port"     : 5984,
    "database" : "REDACTED",
    "protocol" : "http"
  },

  "production" : {
    "username" : "REDACTED",
    "password" : "REDACTED",
    "host"     : "localhost",
    "port"     : 5984,
    "database" : "REDACTED",
    "protocol" : "http"
  }
}

deployment.environments.json を以下のように編集

{
  "development": {
    "port"       : 5993,
    "datadogURL"  : "localhost",
    "datadogPort" : 8125,
    "maxSockets" : 150,
    "batchSize"  : 100,
    "startIndex" : 10000000,
    "rippleds"   :  [
      "http://s-east.ripple.com:51234",
      "http://s-west.ripple.com:51234"
    ],
    "redis" : {
      "enabled" : false,
      "port"    : 6379,
      "host"    : "127.0.0.1",
      "options" : {
        "auth_pass" : null
      }
    },
    "hbase" : {
      "host" : "",
      "port" : 9090
    },
  },

  "staging": {
    "port"       : 5993,
    "datadogURL"  : "localhost",
    "datadogPort" : 8125,
    "maxSockets" : 150,
    "batchSize"  : 100,
    "startIndex" : 32570,
    "rippleds"   :  [
      "http://s_east.ripple.com:51234",
      "http://s_west.ripple.com:51234"
    ],
    "redis" : {
      "enabled" : true,
      "port"    : 6379,
      "host"    : "127.0.0.1",
      "options" : {
        "auth_pass" : null
      }
    },
    "hbase" : {
      "host" : "",
      "port" : 9090
    },
  },
  "production": {
    "port"        : 5993,
    "datadogURL"  : "localhost",
    "datadogPort" : 8125,
    "maxSockets"  : 150,
    "batchSize"   : 100,
    "startIndex"  : 32570,
    "rippleds"    :  [
      "http://s_east.ripple.com:51234",
      "http://s_west.ripple.com:51234"
    ],
    "redis" : {
      "enabled" : true,
      "port"    : 6379,
      "host"    : "127.0.0.1",
      "options" : {
        "auth_pass" : null
      }
    },
    "hbase" : {
      "host" : "",
      "port" : 9090
    },
  }
}

いよいよ実行

$ grunt updateViews
$ node db/importer live debug2 &
$ grunt