Skip to content

Instantly share code, notes, and snippets.

@you21979
Last active January 3, 2016 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save you21979/8481694 to your computer and use it in GitHub Desktop.
Save you21979/8481694 to your computer and use it in GitHub Desktop.
monacoind を centos6.xで動かすメモ

monacoindのコンパイル方法

ansibleで自動インストールする手順です

ansibleのインストール

curl -L https://raw.github.com/you21979/ansible-centos6/master/ansible-centos-install.sh | bash

コンパイル

wget https://gist.github.com/you21979/8481694/raw/60b6c3c7b02a19eab45f2531eb38a816cd1a8c47/monacoin.yml
echo "[app]" > hosts
echo "localhost" >> hosts 
ansible-playbook monacoin.yml -i hosts -k

設定ファイルを作る

  • /opt/monacoin/etc/monacoin.conf

上書きしちゃうとあぶないので手動で。

echo rpcuser=monacoinrpc > /opt/monacoin/etc/monacoin.conf
echo rpcpassword=`date | sha256sum|cut -b 1-44` >> /opt/monacoin/etc/monacoin.conf
echo rpcallowip=127.0.0.1 >> /opt/monacoin/etc/monacoin.conf
echo rpcport=4444 >> /opt/monacoin/etc/monacoin.conf

起動ファイルを設定

wget https://gist.github.com/you21979/8481694/raw/8c9955bf64dd438d6883dea53545019748302784/mona-init.sh
cp mona-init.sh /etc/init.d
chmod 755 /etc/init.d/mona-init.sh
/etc/init.d/mona-init.sh start

よければJSON-RPCのテスト代わりに投げ銭を。

  • monacoin:MNMAEMEiDqupwG7chfXxxGX9tWt8Y44PJx
#!/bin/sh
#
# monacoind Start monacoind
#
# chkconfig: 2345 08 92
# description: Starts, stops
#
# Source function library.
. /etc/init.d/functions
#
MONA=/opt/monacoin
DAEMON=$MONA/bin/monacoind
CONF=$MONA/etc/monacoin.conf
DATA=$MONA/data
start() {
$DAEMON -conf=$CONF -datadir=$DATA -daemon
}
stop() {
kill `ps -ef|grep $DAEMON|grep -v grep|awk '{print $2}'`
}
restart() {
stop
sleep 1
start
}
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
restart
RETVAL=$?
;;
*)
echo $"Usage: {start|stop|restart}"
RETVAL=2
;;
esac
exit $RETVAL
---
- hosts: all
user: root
vars:
tmpdir: /tmp
installdir: /opt/monacoin
tasks:
- name: yum install
yum: name={{item}} state=latest
with_items:
- git
- gcc
- gcc-c++
- boost-*
- zlib-devel
- zlib-static
- db4-cxx
- db4-devel
- name: www download openssl
get_url: url=http://www.openssl.org/source/openssl-1.0.1f.tar.gz dest={{tmpdir}} mode=0440
- name: git download miniupnp
git: repo=https://github.com/miniupnp/miniupnp.git dest={{tmpdir}}/miniupnp
- name: git download monacoin
git: repo=https://github.com/monacoinproject/monacoin.git dest={{tmpdir}}/monacoin
- name: expand openssl
command: tar zxvf {{tmpdir}}/openssl-1.0.1f.tar.gz chdir={{tmpdir}}
- name: configure openssl
command: ./config chdir={{tmpdir}}/openssl-1.0.1f
- name: make openssl
command: make chdir={{tmpdir}}/openssl-1.0.1f
- name: make miniupnpc
command: make chdir={{tmpdir}}/miniupnp/miniupnpc
- name: prepare
file: src={{tmpdir}}/openssl-1.0.1f/include/openssl path={{tmpdir}}/monacoin/src/openssl state=link
- name: prepare
file: src={{tmpdir}}/miniupnp/miniupnpc path={{tmpdir}}/monacoin/src/miniupnpc state=link
- name: prepare
file: src={{tmpdir}}/miniupnp/miniupnpc/libminiupnpc.a path={{tmpdir}}/monacoin/src/libminiupnpc.a state=link
- name: make monacoin
command: make -f makefile.unix BOOST_LIB_SUFFIX=-mt LDFLAGS="-L{{tmpdir}}/openssl-1.0.1f -L." chdir={{tmpdir}}/monacoin/src
- name: install directory create
file: dest={{installdir}}/{{item}} state=directory
with_items:
- bin
- etc
- data
- name: install monacoind {{installdir}}/bin/monacoind
copy: src={{tmpdir}}/monacoin/src/monacoind dest={{installdir}}/bin/monacoind mode=0755
var bitcoin = require('bitcoin');
var client = new bitcoin.Client({
host: 'localhost',
port: 4444,
user: 'monacoinrpc',
pass: 'your password'
});
client.getDifficulty(function(err, difficulty) {
if (err) {
return console.error(err);
}
console.log('Difficulty: ' + difficulty);
});
@you21979
Copy link
Author

opensslが原因でコアダンプするんかな

@you21979
Copy link
Author

opensslを自前でコンパイルする必要があり、centos6のopensslだと機能足りなくてコアダンプする

@you21979
Copy link
Author

monacoindを起動するとmonacoin.confを作れといわれるので作って起動する

@you21979
Copy link
Author

あとでansible用意しよう

@you21979
Copy link
Author

monacoin.confの設定を最初からローカルのJSON-RPCを通すようにしておきました。ポート4444で。

@you21979
Copy link
Author

monacoin.ymlのmonacoinをlitecoinに置き換えるだけでlitecoinもコンパイルできます。git cloneの部分はlitecoinに変える必要あるけども

@you21979
Copy link
Author

bitcoin,litecoin,sakuracoin,sha1coinのビルド用のansibleも↓にあります
https://github.com/you21979-storage/ansible-sakuravps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment