BTC 主网节点搭建
source link: https://learnblockchain.cn/article/823
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
本文介绍在 CentOS 上 搭建 BTC 主网节点
节点安装先准备: 环境 Centos7.2 硬盘500GB
下载安装
节点下载页面 https://bitcoin.org/zh_CN/download
cd /opt/ wget https://bitcoin.org/bin/bitcoin-core-0.17.0.1/bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
解压,建软连接
tar zxf bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz ln -fs /opt/bitcoin-0.17.0 /opt/bitcoin ln -fs /opt/bitcoin-0.17.0/bin/bitcoind /usr/local/bin/bitcoind ln -fs /opt/bitcoin-0.17.0/bin/bitcoin-cli /usr/local/bin/bitcoin-cli</pre>
创建配置
mkdir -p /data/btc_data mkdir ~/.bitcoin vim ~/.bitcoin/bitcoin.conf
编辑 ~/.bitcoin/bitcoin.conf
:
datadir=/data/btc_data dbcache=10240 txindex=1 rpcuser=btc rpcpassword=btc2019 daemon=1 server=1 rest=1 rpcbind=0.0.0.0:8332 rpcallowip=0.0.0.0/0 deprecatedrpc=accounts</pre>
后台启动
bitcoind -daemon
关闭
bitcoin-cli stop
查看区块链同步
bitcoin-cli getblockchaininfo bitcoin-cli getmininginfo
区块浏览器 1. https://btc.com/ 2. http://blockchain.info
rpc api访问
#curl访问rpc测试 curl -s -X POST --user btc:btc2018 \ -H 'content-type: text/plain;' http://127.0.0.1:8332/ \ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' #查询最新区块高度 curl -s -X POST --user btc:btc2018 \ -H 'content-type: text/plain;' http://127.0.0.1:8332/ \ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' \ |awk -F '[:,]' '{print $3}'
配置参数说明
rpcuser 远程访问的认证用户 rpcpassword 远程访问密码 daemon 在后台运行 rpcallowip 远程访问的ip或网段 txindex 所有交易进行索引;否则只保留钱包地址交易索引记录 deprecatedrpc=accounts 启用账户"account"API ,V0.18版将被完全移除,新版"标签-label"API
注意事项
-
关闭后,再次启动时报错 Cannot obtain a lock on wallet directory 删除data目录.lock文件后,再次启动。
-
不配置datadir时,默认保存在 ~/.bitcoin/
节点安装先准备: 环境 Centos7.2 硬盘500GB
下载安装
节点下载页面 https://bitcoin.org/zh_CN/download
cd /opt/ wget https://bitcoin.org/bin/bitcoin-core-0.17.0.1/bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
解压,建软连接
tar zxf bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz ln -fs /opt/bitcoin-0.17.0 /opt/bitcoin ln -fs /opt/bitcoin-0.17.0/bin/bitcoind /usr/local/bin/bitcoind ln -fs /opt/bitcoin-0.17.0/bin/bitcoin-cli /usr/local/bin/bitcoin-cli</pre>
创建配置
mkdir -p /data/btc_data mkdir ~/.bitcoin vim ~/.bitcoin/bitcoin.conf
编辑 ~/.bitcoin/bitcoin.conf
:
datadir=/data/btc_data dbcache=10240 txindex=1 rpcuser=btc rpcpassword=btc2019 daemon=1 server=1 rest=1 rpcbind=0.0.0.0:8332 rpcallowip=0.0.0.0/0 deprecatedrpc=accounts</pre>
后台启动
bitcoind -daemon
关闭
bitcoin-cli stop
查看区块链同步
bitcoin-cli getblockchaininfo bitcoin-cli getmininginfo
区块浏览器 1. https://btc.com/
rpc api访问
#curl访问rpc测试 curl -s -X POST --user btc:btc2018 \ -H 'content-type: text/plain;' http://127.0.0.1:8332/ \ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' #查询最新区块高度 curl -s -X POST --user btc:btc2018 \ -H 'content-type: text/plain;' http://127.0.0.1:8332/ \ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' \ |awk -F '[:,]' '{print $3}'
配置参数说明
rpcuser 远程访问的认证用户 rpcpassword 远程访问密码 daemon 在后台运行 rpcallowip 远程访问的ip或网段 txindex 所有交易进行索引;否则只保留钱包地址交易索引记录 deprecatedrpc=accounts 启用账户"account"API ,V0.18版将被完全移除,新版"标签-label"API
注意事项
-
关闭后,再次启动时报错 Cannot obtain a lock on wallet directory 删除data目录.lock文件后,再次启动。
-
不配置datadir时,默认保存在 ~/.bitcoin/
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。
- 发表于 26分钟前
- 阅读 ( 11 )
- 学分 ( 0 )
- 分类:比特币
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK