前言
本教程将手把手教你如何搭建自己的简易以太坊矿池。
一、服务器要求
要求配置:最低16G内存,500G硬盘(建议32G内存,1T硬盘)以同步以太坊数据,系统请使用Ubuntu 16.04 LTS。
二、操作步骤
1.环境初始化
使用root用户登录,执行如下命令:
sudo apt-get update
sudo apt-get dist-upgrade
2.安装依赖
apt-get install curl git make -y
apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev -y
apt-get install libboost-all-dev git npm nodejs nodejs-legacy libminiupnpc-dev redis-server -y
apt-get install libdb4.8-dev libdb4.8++-dev -y
apt-get install golang -y
apt-get install nginx -y
安装NODE版本管理工具n:
npm install -g n
要安装最新的 Node.js 版本,请运行以下命令:
n latest
更新软件库并安装Ethereum:
sudo apt-get install software-properties-common -y
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
创建ETH账户:
geth account new
启动geth客户端开始同步区块数据(使用nohup和&后台运行,并生成实时日志nohup.out):
mkdir /home/ethdata
nohup geth -datadir "/home/ethdata" --http --http.addr 127.0.0.1 --http.corsdomain="*" --http.api "eth,net,personal,admin" --http.port 50002 --syncmode "full" --maxpeers 100 --cache 2048 --allow-insecure-unlock &
运行完以上命令,如果没有错误,geth客户端就会开始同步区块了.
3.下载并配置运行矿池
配置并启动池:
git config --global http.https://gopkg.in.followRedirects true
git clone https://github.com/sammy007/open-ethereum-pool.git
git clone https://github.com/fuckgm/ethereum-pool
把ethereum-pool目录的文件复制到open-ethereum-pool目录中覆盖原有文件,并配置config.json文件:
{
"threads": 2,
"coin": "eth",
"name": "main",
"proxy": {
"enabled": true,
"listen": "0.0.0.0:9999",
"limitHeadersSize": 1024,
"limitBodySize": 256,
"behindReverseProxy": false,
"stratum": {
"enabled": true,
"listen": "0.0.0.0:8008",
"timeout": "120s",
"maxConn": 8192
},
"blockRefreshInterval": "120ms",
"stateUpdateInterval": "3s",
"difficulty": 2000000000,
"healthCheck": true,
"maxFails": 100,
"hashrateExpiration": "3h",
"policy": {
"workers": 8,
"resetInterval": "60m",
"refreshInterval": "1m",
"banning": {
"enabled": false,
"ipset": "blacklist",
"timeout": 1800,
"invalidPercent": 30,
"checkThreshold": 30,
"malformedLimit": 5
},
"limits": {
"enabled": false,
"limit": 30,
"grace": "5m",
"limitJump": 10
}
}
},
"api": {
"enabled": true,
"listen": "0.0.0.0:8080",
"statsCollectInterval": "5s",
"purgeInterval": "10m",
"hashrateWindow": "30m",
"hashrateLargeWindow": "3h",
"luckWindow": [64, 128, 256],
"payments": 50,
"blocks": 50,
"purgeOnly": false
},
"upstreamCheckInterval": "5s",
"upstream": [
{
"name": "main",
"url": "http://127.0.0.1:50002",
"timeout": "10s"
},
{
"name": "backup",
"url": "http://127.0.0.2:50002",
"timeout": "10s"
}
],
"redis": {
"endpoint": "127.0.0.1:6379",
"poolSize": 10,
"database": 0,
"password": ""
},
"unlocker": {
"enabled": false,
"poolFee": 1.0,
"poolFeeAddress": "0x7f1dC5932a1A6C860Cf5949cD66883111baFd954",
"donate": true,
"depth": 120,
"immatureDepth": 20,
"keepTxFees": false,
"interval": "10m",
"daemon": "http://127.0.0.1:50002",
"timeout": "10s"
},
"payouts": {
"enabled": false,
"requirePeers": 25,
"interval": "12h",
"daemon": "http://127.0.0.1:50002",
"timeout": "10s",
"address": "0x7f1dC5932a1A6C860Cf5949cD66883111baFd954",
"autoGas": true,
"gas": "21000",
"gasPrice": "50000000000",
"threshold": 500000000,
"bgsave": false
}
}
附配置文件(带备注):
{
"threads": 2,
"coin": "eth",
"name": "main",
"proxy": {
"enabled": true,
"listen": "0.0.0.0:8888",
"limitHeadersSize": 1024,
"limitBodySize": 256,
"behindReverseProxy": false,
"stratum": {
"enabled": true,
"listen": "0.0.0.0:8008",
"timeout": "120s",
"maxConn": 8192
},
"blockRefreshInterval": "120ms",
"stateUpdateInterval": "3s",
"difficulty": 2000000000,
"healthCheck": true,
"maxFails": 100,
"hashrateExpiration": "3h",
"policy": {
"workers": 8,
"resetInterval": "60m",
"refreshInterval": "1m",
"banning": {
"enabled": false,
"ipset": "blacklist",
"timeout": 1800,
"invalidPercent": 30,
"checkThreshold": 30,
"malformedLimit": 5
},
"limits": {
"enabled": false,
"limit": 30,
"grace": "5m",
"limitJump": 10
}
}
},
"api": {
"enabled": true,
"listen": "0.0.0.0:8080",
"statsCollectInterval": "5s",
"purgeInterval": "10m",
"hashrateWindow": "30m",
"hashrateLargeWindow": "3h",
"luckWindow": [64, 128, 256],
"payments": 50,
"blocks": 50,
"purgeOnly": false
},
"upstreamCheckInterval": "5s",
"upstream": [
{
"name": "main",
"url": "http://127.0.0.1:8545",
"timeout": "10s"
},
{
"name": "backup",
"url": "http://127.0.0.2:8545",
"timeout": "10s"
}
],
"redis": {
"endpoint": "127.0.0.1:6379",
"poolSize": 10,
"database": 0,
"password": ""
},
"unlocker": {
"enabled": false,
"poolFee": 1.0,
"poolFeeAddress": "",
"donate": true,
"depth": 120,
"immatureDepth": 20,
"keepTxFees": false,
"interval": "10m",
"daemon": "http://127.0.0.1:8545",
"timeout": "10s"
},
"payouts": {
"enabled": false,
"requirePeers": 25,
"interval": "12h",
"daemon": "http://127.0.0.1:8545",
"timeout": "10s",
"address": "0x0",
"autoGas": true,
"gas": "21000",
"gasPrice": "50000000000",
"threshold": 500000000,
"bgsave": false
}
}
在ethereum-pool目录下运行:
nohup ./ethereum-pool config.json &
没有报错则运行成功.
3.Web界面前端配置
进入www目录,执行:
npm install -g ember-cli@2.9.1
npm install -g bower
npm install
bower install
./build.sh
然后编辑config/environment.js文件:
module.exports = function(environment) {
var ENV = {
modulePrefix: 'pool',
environment: environment,
rootURL: 'https://www.3pool.cn/',
locationType: 'hash',
EmberENV: {
FEATURES: {
}
},
APP: {
ApiUrl: '//api.3pool.cn:8080/',
BlockTime: 14.4
}
};
if (environment === 'development') {
ENV.APP.ApiUrl = 'https://api.3pool.cn:8080/'
}
if (environment === 'test') {
ENV.locationType = 'none';
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
编辑文件/etc/nginx/nginx.conf文件,并添加以下行:
upstream api {
server 127.0.0.1:8080;
}
location /api {
proxy_pass http://api;
}
至此,我们的矿池搭建完成
|