CentOS7でbitzenyプールを建てる
参考 :
https://cryptomamiya.com/index.php/category/mpos/
参考2 :
https://qiita.com/you21979@github/items/1567d6d91588e53f15d6
■OS初期設定
// SELINUXを無効化
# vi /etc/sysconfig/selinux
SELINUX=disabled
// アップデート
# yum -y update
# reboot
// VMware ESXi 用のソフトウェアをインストール
# yum -y install open-vm-tools
# reboot
// 基本的なソフトと開発ツール一式をインストール
# yum -y groupinstall Base “Development tools”
■ firewalldの代わりにiptablesを使用
// firewalldを停止
# systemctl stop firewalld
# systemctl disable firewalld
// iptablesのインストール
yum -y install iptables-services
// iptablesの起動と自動起動の設定
systemctl start iptables
systemctl enable iptables
■1. bitzenyd
// bitzenydをダウンロードして解凍する
# wget https://github.com/BitzenyCoreDevelopers/bitzeny/releases/download/z1.2.1/bitzeny-1.2.1-linux.tar.gz
# tar zxvf bitzeny-1.2.1-linux.tar.gz
// bitzeny用フォルダを作成
mkdir -p /opt/bitzeny/bin
mkdir -p /opt/bitzeny/etc
mkdir -p /opt/bitzeny/data
// bitzenydの実行ファイルをコピー
# cp bitzeny-1.2.1-linux/bin/64/bitzenyd /opt/bitzeny/bin
# cp bitzeny-1.2.1-linux/bin/64/bitzeny-cli /opt/bitzeny/bin
// 設定ファイルを作成
# vi /opt/bitzeny/etc/bitzeny.conf
# RPCを使うときのユーザー名
rpcuser=bitzenyrpc
# RPCを使うときのパスワード
rpcpassword=SETYOURPASSWORD
# RPCを利用できるIPアドレス
rpcallowip=127.0.0.1
# RPCを受け付けるポート番号
rpcport=9252
# RPCを同時に受け付ける数
rpcthreads=10
# マイニングするかどうか。0でしない
gen=0
# P2Pのコネクション数
maxconnections=200
// bitzenyd起動用シェル作成
# vi /etc/init.d/bitzenyd
#!/bin/sh
#
# bitzenyd Start bitzenyd
#
# chkconfig: 2345 08 92
# description: Starts, stops
#
# Source function library.
. /etc/init.d/functions
#
COINDIR=/opt/bitzeny
DAEMON=$COINDIR/bin/bitzenyd
CONF=$COINDIR/etc/bitzeny.conf
DATA=$COINDIR/data
start() {
$DAEMON -conf=$CONF -datadir=$DATA -daemon
}
stop() {
$DAEMON -conf=$CONF stop
}
restart() {
stop
sleep 3
start
}
getinfo() {
$DAEMON -conf=$CONF getinfo
$DAEMON -conf=$CONF getmininginfo
$DAEMON -conf=$CONF getdifficulty
}
case “$1″ in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
restart
RETVAL=$?
;;
getinfo)
getinfo
RETVAL=$?
;;
*)
echo $”Usage: {start|stop|restart|getinfo}”
RETVAL=2
;;
esac
exit $RETVAL
// 作成したシェルに実行権限付与
# chmod +x /etc/init.d/bitzenyd
// bitzenyd起動
# /etc/init.d/bitzenyd start
// 起動状態確認
# /etc/init.d/bitzenyd getinfo
// bitzenyd自動起動設定
# chkconfig bitzenyd on
■2. mpos
// DBソフトのインストール
# yum -y install mariadb-server
// mariadb設定ファイル編集
# vi /etc/my.cnf.d/server.cnf
// mariadb起動+自動起動設定
# systemctl start mariadb
# systemctl enable mariadb
// mariadb 初期設定
# mysql_secure_installation
Enter current password for root (enter for none): ←空Enter
Set root password? [Y/n] ←空Enter
New password: ←任意のmariadb用rootパスワードを入力
Re-enter new password: ←上記と同じパスワードを入力
Remove anonymous users? [Y/n] ←空Enter
Disallow root login remotely? [Y/n] ←空Enter
Remove test database and access to it? [Y/n] ←空Enter
Reload privilege tables now? [Y/n] ←空Enter
// mpos用DB作成
# mysql -u root -p -e “create database mpos”
Enter password: ←mariadb用rootパスワードを入力
// mpos用DBユーザー作成
# mysql -u root -p -e “grant all privileges on mpos.* to [email protected] identified by ‘mpos’;”
Enter password: ←mariadb用rootパスワードを入力
// MOPSを入手
# git clone https://github.com/MPOS/php-mpos.git mpos
// mpos用テーブルを挿入
# mysql -u root -p mpos < mpos/sql/000_base_structure.sql
Enter password: ←mariadb用rootパスワードを入力
// Webサーバー関連のソフトウェアをインストール
# yum -y install httpd php php-mysqlnd memcached
// php-pecl-memcachedを入れるためにepelをインストール
// epelを入れないとphp-pecl-memcacheしか入れられない
// インストールしたいのはmemcacheではなく、memcached(最後にdが付く方)
# yum -y install epel-release
# yum -y update
// phpでmemcachedを使用する為にインストール
# yum -y install php-pecl-memcached
// mposをapacheで使用するディレクトリ配下にコピー
# cp -r mpos /var/www
// ディレクトリの権限を変更
# chown -R apache:apache /var/www/mpos/
// mposの設定ファイル雛形をコピー
# cd /var/www/mpos/include/config/
# cp global.inc.dist.php global.inc.php
// 設定ファイルを編集
# vi global.inc.php
$config['SALT'] = 'PLEASEMAKEMESOMETHINGRANDOM'; ←長いパスワードを作成して入力
$config['SALTY'] = 'THISSHOULDALSOBERRAANNDDOOM';←長いパスワードを別に作成して入力
$config[‘db’][‘host’] = ‘127.0.0.1’;
$config[‘db’][‘user’] = ‘mpos’;
$config[‘db’][‘pass’] = ‘mpos’;
$config[‘db’][‘port’] = 3306;
$config[‘db’][‘name’] = ‘mpos’;
$config[‘wallet’][‘host’] = ‘127.0.0.1:9252’;
$config[‘wallet’][‘username’] = ‘bitzenyrpc’; ←/opt/bitzeny/etc/bitzeny.confに設定したユーザ名を入力
$config[‘wallet’][‘password’] = ‘rpcpass’; ←/opt/bitzeny/etc/bitzeny.confに設定したパスワードを入力
$config[‘currency’] = ‘ZNY’;
// ファイアウォール設定
# vi /etc/sysconfig/iptables
〜 省略 〜
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT ←追記
〜 省略 〜
// iptables再起動
systemctl restart iptables
// memcached起動+自動起動設定
# systemctl start memcached
# systemctl enable memcached
// Apacheバーチャルホスト設定
# vi /etc/httpd/conf.d/virtual.conf
ServerName 58.80.51.120
DocumentRoot /var/www/mpos/public
ErrorLog logs/mpos-error_log
CustomLog logs/mpos-access_log combined env=!no_log
// httpd起動+自動起動設定
# systemctl start httpd
# systemctl enable httpd
// ブラウザからmposへアクセスしてみる
// いつものプール画面表示されればOK。
// はまったのはmemcachedとmemcacheの違い。epelを入れないとphp-pecl-memachedが入れられなかった
// うまく表示的無いときにはapacheのログを見てみる(/var/log/httpd/mpos-error_log)
http://IPアドレス/
いつものプール画面表示されればOK。
はまったのはmemcachedとmemcacheの違い。epelを入れないとphp-pecl-memachedが入れられなかった
■3. stratum
// stratumに必要なソフトウェアを準備
# git clone https://github.com/ahmedbodi/stratum-mining.git stratum-mining
# git clone https://github.com/bitzeny/zny_yescrypt_python.git zny_yescrypt_addon
# git clone https://gist.github.com/9db1723161bc2650a1b1.git stratum-mining-znypatch
# yum -y install python-devel python-setuptools python-simplejson libffi-devel libmemcached-devel python-memcached zlib-devel MySQL-python
# easy_install -U distribute
# easy_install pip
# pip install autobahn
# pip install cryptography
# pip install service_identity
# pip install pylibmc
# pip install pycrypto
// パッチファイルのtypoを修正
// 「zny_yesscrypt」を「zny_yescrypt」に修正(sが1つ多いので直す)
# vi stratum-mining-znypatch/stratum.patch
+ if settings.COINDAEMON_ALGO == ‘zny_yescrypt’:
// stratum-miningをyescryptに対応させるための準備(1)
# cd zny_yescrypt_addon/
# python setup.py install
// stratum-miningをyescryptに対応させるための準備(2)
# cd
# cp ./stratum-mining-znypatch/stratum.patch ./stratum-mining/
# cd stratum-mining
# patch -p1 < stratum.patch
// stratum-miningを最適化
# git submodule init
# git submodule update
# cd externals/litecoin_scrypt/
# python setup.py install
// setup.pyを編集
# cd ~/stratum-mining/externals/stratum
# vi setup.py
-----
#!/usr/bin/env python
#from distribute_setup import use_setuptools ←コメントアウト
#use_setuptools() ←コメントアウト
#python setup.py sdist upload
-----
// setup.pyを実行
# python setup.py install
# cp ~/stratum-mining/conf/config_sample.py ~/stratum-mining/conf/config.py
# vi ~/stratum-mining/conf/config.py
-----
-----
// 設定ファイルに必要なウォレットアドレスを取得
# /opt/bitzeny/bin/bitzeny-cli -conf=/opt/bitzeny/etc/bitzeny.conf -datadir=/opt/bitzeny/data getaccountaddress ""
Z******************
// 設定ファイルを編集
# vi ~/stratum-mining/conf/config.py
-----
CENTRAL_WALLET = 'set_valid_addresss_in_config!'
COINDAEMON_TRUSTED_HOST = '127.0.0.1'
COINDAEMON_TRUSTED_PORT = 9252
COINDAEMON_TRUSTED_USER = 'bitzenyrpc' ←/opt/bitzeny/etc/bitzeny.confに設定したユーザ名を入力
COINDAEMON_TRUSTED_PASSWORD = 'somepassword' ←/opt/bitzeny/etc/bitzeny.confに設定したパスワードを入力
COINDAEMON_ALGO = 'zny_yescrypt'
HOSTNAME = '127.0.0.1'
LISTEN_SOCKET_TRANSPORT = 3333 ←stratumで使用する任意のポート(このポートをiptablesで空ける)
PASSWORD_SALT = 'some_crazy_string' ←長いランダムなパスワードを設定
DB_MYSQL_HOST = '127.0.0.1'
DB_MYSQL_DBNAME = 'mpos'
DB_MYSQL_USER = 'mpos'
DB_MYSQL_PASS = 'mpos'
DB_MYSQL_PORT = 3306 # Default port for MySQL
POOL_TARGET = 1 # Pool-wide difficulty target int >= 1
MEMCACHE_HOST = “127.0.0.1” # Hostname or IP that runs memcached
—–
// バグを修正
# vi ~/stratum-mining/externals/stratum/stratum/server.py
—–
from autobahn.websocket import listenWS
↓
from autobahn.twisted.websocket import listenWS
—–
// 再コンパイル
# cd ~/stratum-mining/externals/stratum
# python setup.py install
// launcher.tacを編集
sys.path = [os.path.join(os.getcwd(), ‘conf’),os.path.join(os.getcwd(), ‘externals’, ‘stratum-mining-proxy’),] + sys.path
↓
sys.path = [os.path.join(os.getcwd(), ‘conf’),os.path.join(os.getcwd(), ‘.’),os.path.join(os.getcwd(), ‘externals’, ‘stratum-mining-proxy’),] + sys.path
//stratumを起動
# twistd -ny ~/stratum-mining/launcher.tac
//ログが大量に表示されるので、最初の方に以下のようなものが表示されたらOK
DEBUG halfnode # ########################################### Loading Yescrypt Support #########################################################
==================================================
//起動シェルスクリプト作成
# yum install screen
# vi ~/start_stratum.sh
—–
#!/bin/sh
cd ~/stratum-mining
/bin/screen -AmdS stratum /bin/twistd -ny launcher.tac
—–
// セッションを切り替え
# screen -r stratum
// stratumを再びバックグラウンドに戻す
Ctrl+Aを押した後、Dを押す
// 実行権限を付与
# chmod +x start_stratum.sh
// OS起動時に自動実行
# vi /etc/rc.local
—–
/bin/sh /root/start_stratum.sh
—–
// MPOS定期実行ジョブ設定
# crontab -e
*/5 * * * * /var/www/mpos/cronjobs/run-crons.sh
以上
コメントを残す