5月 302018
https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
添加软件仓库(软件仓库管理工具)
root@localhost:~# add-apt-repository ppa:bitcoin/bitcoin The program 'add-apt-repository' is currently not installed. You can install it by typing: apt install software-properties-common root@localhost:~# apt-get install software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic Use 'apt autoremove' to remove them. The following additional packages will be installed: python3-pycurl python3-software-properties unattended-upgrades Suggested packages: libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg bsd-mailx The following NEW packages will be installed: python3-pycurl python3-software-properties software-properties-common unattended-upgrades 0 upgraded, 4 newly installed, 0 to remove and 80 not upgraded. Need to get 104 kB of archives. After this operation, 799 kB of additional disk space will be used. Do you want to continue? [Y/n]
添加软件仓库
root@localhost:~# add-apt-repository ppa:bitcoin/bitcoin Stable Channel of bitcoin-qt and bitcoind for Ubuntu, and their dependencies Note that you should prefer to use the official binaries, where possible, to limit trust in Launchpad/the PPA owner. No longer supports precise, due to its ancient gcc and Boost versions. More info: https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmpn1f_v7v0/secring.gpg' created gpg: keyring `/tmp/tmpn1f_v7v0/pubring.gpg' created gpg: requesting key 8842CE5E from hkp server keyserver.ubuntu.com gpg: /tmp/tmpn1f_v7v0/trustdb.gpg: trustdb created gpg: key 8842CE5E: public key "Launchpad PPA for Bitcoin" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK root@localhost:~#
更新软件仓库索引
root@localhost:~# apt update Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security InRelease Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates InRelease Hit:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-proposed InRelease Hit:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-backports InRelease Get:6 http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu xenial InRelease [17.5 kB] Get:7 http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu xenial/main amd64 Packages [2,788 B] Get:8 http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu xenial/main i386 Packages [2,788 B] Get:9 http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu xenial/main Translation-en [1,712 B] Fetched 24.8 kB in 3s (7,783 B/s) Reading package lists... Done Building dependency tree Reading state information... Done 80 packages can be upgraded. Run 'apt list --upgradable' to see them. root@localhost:~#
搜索软件包
root@localhost:~# apt search bitcoin Sorting... Done Full Text Search... Done bfgminer/xenial 5.2.0+dfsg-1build1 amd64 multi-threaded multi-pool ASIC, FPGA and GPU bitcoin miner bitcoin-qt/xenial 0.16.0-xenial1 amd64 peer-to-peer network based digital currency - Qt GUI bitcoin-tx/xenial 0.16.0-xenial1 amd64 peer-to-peer digital currency - standalone transaction tool bitcoind/xenial 0.16.0-xenial1 amd64 peer-to-peer network based digital currency - daemon cgminer/xenial 4.9.2-1build1 amd64 multi-threaded multi-pool Bitcoin miner libbase58-0/xenial 0.1.4-1 amd64 library for Bitcoin's base58 encoding libbase58-dev/xenial 0.1.4-1 amd64 library for Bitcoin's base58 encoding -- development files libbitcoin-dev/xenial 2.0-2.4 amd64 Bitcoin toolkit library for asynchronous apps - development headers libbitcoin0v5/xenial 2.0-2.4 amd64 Bitcoin toolkit library for asynchronous apps libbitcoin0v5-dbg/xenial 2.0-2.4 amd64 Bitcoin toolkit library for asynchronous apps - debugging symbols libblkmaker-0.1-6/xenial 0.5.2-1 amd64 implementation of getblocktemplate protocol libblkmaker-0.1-dev/xenial 0.5.2-1 amd64 C implementation of getblocktemplate protocol - development files python-btchip/xenial,xenial 0.1.16-1 all Python library to communicate with BTChip dongle python-mnemonic/xenial,xenial 0.12-1 all Implementation of Bitcoin BIP-0039 python-trezor/xenial,xenial 0.6.10-1 all library for communicating with TREZOR Bitcoin HW wallet root@localhost:~#
安装服务节点程序
root@localhost:~# apt-get install bitcoind Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic Use 'apt autoremove' to remove them. The following additional packages will be installed: libboost-chrono1.58.0 libboost-filesystem1.58.0 libboost-program-options1.58.0 libdb4.8++ libevent-core-2.0-5 libevent-pthreads-2.0-5 libminiupnpc10 libsodium18 libzmq5 Suggested packages: minissdpd The following NEW packages will be installed: bitcoind libboost-chrono1.58.0 libboost-filesystem1.58.0 libboost-program-options1.58.0 libdb4.8++ libevent-core-2.0-5 libevent-pthreads-2.0-5 libminiupnpc10 libsodium18 libzmq5 0 upgraded, 10 newly installed, 0 to remove and 80 not upgraded. Need to get 2,994 kB of archives. After this operation, 10.3 MB of additional disk space will be used. Do you want to continue? [Y/n]
查看软件包安装结构
root@localhost:~# dpkg -L bitcoind /. /usr /usr/bin /usr/bin/bitcoind /usr/bin/bitcoin-cli /usr/share /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/bitcoind /usr/share/doc /usr/share/doc/bitcoind /usr/share/doc/bitcoind/changelog.Debian.gz /usr/share/doc/bitcoind/examples /usr/share/doc/bitcoind/examples/bitcoin.conf.gz /usr/share/doc/bitcoind/copyright /usr/share/bash-completion /usr/share/bash-completion/completions /usr/share/bash-completion/completions/bitcoind /usr/share/bash-completion/completions/bitcoin-cli /usr/share/man /usr/share/man/man1 /usr/share/man/man1/bitcoin-cli.1.gz /usr/share/man/man1/bitcoind.1.gz root@localhost:~#
配置启动脚本
不指定rpcallowip时,RPC仅监听127.0.0.1地址
root@localhost:~# mkdir -p /data/bitcoin root@localhost:~# vi start.sh #!/bin/bash # /usr/bin/bitcoind -daemon -datadir=/data/bitcoin -bind=192.168.199.100 -port=8333 \ -server -rpcbind=192.168.199.100 -rpcport=8332 -rpcallowip=192.168.199.0/24 \ -rpcthreads=4 -rpcuser=tom -rpcpassword=123456; exit 0; root@localhost:~# chmod 700 start.sh root@localhost:~# ./start.sh Bitcoin server starting root@localhost:~#
查看监听
root@localhost:~# netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN tcp 0 0 192.168.199.100:8332 0.0.0.0:* LISTEN tcp 0 0 192.168.199.100:8333 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:42832 0.0.0.0:* LISTEN tcp6 0 0 :::36003 :::* LISTEN root@localhost:~# netstat -tn Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.199.100:691 10.22.107.25:2049 ESTABLISHED tcp 0 0 192.168.199.100:50502 144.76.98.163:8333 TIME_WAIT tcp 0 164 192.168.199.100:22 10.22.100.1:33336 ESTABLISHED tcp 0 0 192.168.199.100:44482 117.81.184.11:8333 ESTABLISHED tcp 0 0 192.168.199.100:48848 163.172.186.236:8333 TIME_WAIT tcp 0 0 127.0.0.1:32000 127.0.0.1:31000 ESTABLISHED tcp 0 0 192.168.199.100:39614 78.46.177.74:8333 TIME_WAIT tcp 0 0 192.168.199.100:40814 100.100.35.4:3128 ESTABLISHED tcp 0 0 127.0.0.1:31000 127.0.0.1:32000 ESTABLISHED tcp 0 127 192.168.199.100:45176 82.118.242.132:8333 FIN_WAIT1 tcp 0 0 192.168.199.100:56672 39.105.48.188:8333 ESTABLISHED tcp 0 0 192.168.199.100:46430 47.75.168.155:8333 ESTABLISHED tcp 0 0 192.168.199.100:55654 106.11.68.13:80 ESTABLISHED root@localhost:~#
调试请求接口
[root@oms ~]# curl --user 'tom:123456' --data-binary ''' > { > "method": "getblockhash", > "params": [0], > "id": "foo" > }''' \ > --header 'Content-Type: text/plain;' 192.168.199.100:8332 {"result":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f","error":null,"id":"foo"} [root@oms ~]#