入门介绍
准备条件
- 硬盘:推荐200G以上
- 内存:推荐4G或以上
- 环境:centos
- 安装包:https://bitcoin.org/en/download
centos操作指南(普通权限用户)
- 下载:wget https://bitcoin.org/bin/bitcoin-core-0.17.1/bitcoin-0.17.1-x86_64-linux-gnu.tar.gz
- 解压:tar -zvxf bitcoin-*
- 安装:
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-*/bin/*
- 配置:(普通用户)
- mkdir ~/.bitcoin
- touch ~/.bitcoin/bitcoin.conf
- chmod 600 ~/.bitcoin/bitcoin.conf
- echo "server=1 # server=1 告知 Bitcoin-QT 接受 JSON-RPC 命令 " >> ~/.bitcoin/bitcoin.conf
- echo "rpcuser=BitRpc # 用户名 " >> ~/.bitcoin/bitcoin.conf
- echo "rpcpassword=123456 # 密码 " >> ~/.bitcoin/bitcoin.conf
- echo "rpcport=18332 # 监听 端口 " >> ~/.bitcoin/bitcoin.conf
- echo "rpctimeout=30 " >> ~/.bitcoin/bitcoin.conf
- echo "txindex=1 " >> ~/.bitcoin/bitcoin.conf
- 运行:(普通用户)
- bitcoind -daemon
- bitcoind -testnet -daemon
- 开机启动:(切换到root账户)
- vim /etc/init.d/bitcoincore
- chmod +x /etc/init.d/bitcoincore
- chkconfig --add bitcoincore
- chkconfig bitcoincore on
- 文件内容:xxxx 为指定普通权限用户
#bitcoincore start scripts
#chkconfig: 235 80 30 --235指定的启动级别,在哪写启动级别下启动;--80 启动的优先级;--30 关闭的优先级
su xxxx -c "bitcoind -daemon"
- 测试:(普通用户)
- bitcoin-cli getblockcount
- bitcoin-cli getblockchaininfo
- curl --user BitRpc:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockhash", "params": [1000] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
补充知识 防火墙相关配置:(root用户)
- 查看已开放的端口:firewall-cmd --list-ports
- 开启端口:firewall-cmd --zone=public --add-port=8332/tcp --permanent
- 关闭端口:firewall-cmd --zone=public --remove-port=8332/tcp --permanent
- 重启防火墙:firewall-cmd --reload
- 关闭防火墙:systemctl stop firewalld.service
命令含义:
- zone #作用域
- add-port=80/tcp #添加端口,格式为:端口/通讯协议
- permanent #永久生效,没有此参数重启后失效
补充知识 普通用户无sudo权限
[bitcoin01@localhost tmpDir]$ sudo install -m 0755 -o root -g root -t /usr/local/bin/ bitcoin-0.17.1/bin/*
我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:
#1) 尊重别人的隐私。
#2) 输入前要先考虑(后果和风险)。
#3) 权力越大,责任越大。
[sudo] bitcoin01 的密码:
bitcoin01 不在 sudoers 文件中。此事将被报告。
解决办法:切换到root账户,通过编辑器来打开/etc/sudoers,打开sudoers后,像如下那样加上自己的帐号强制保存后就可以了。(wq!)
root ALL=(ALL:ALL) ALL
bitcoin01 ALL=(ALL:ALL) ALL
网友评论