docker-compose部署BCH节点

2023-10-14 15:30
文章标签 部署 docker compose bch 节点

本文主要是介绍docker-compose部署BCH节点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

BCH gitlab
BCH github
1、下载BCH二进制文件

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# wget https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v26.1.0/bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz
--2023-07-05 16:30:46--  https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v26.1.0/bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gzConnecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31056067 (30M) [application/octet-stream]
Saving to: ‘bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz’bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz            100%[=========================================================================================================================================>]  29.62M  20.1MB/s    in 1.5s    2023-07-05 16:30:49 (20.1 MB/s) - ‘bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz’ saved [31056067/31056067]

2、编写Dockerfile

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim Dockerfile
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# cat Dockerfile 
FROM ubuntu:20.04# 安装依赖库和工具
RUN apt-get update && apt-get install -y \curl \libssl-dev \libevent-dev \software-properties-commonADD bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz .
# 解压并复制二进制文件到 /usr/local/bin 目录
RUN mv bitcoin-cash-node-26.1.0/bin/bitcoind /usr/local/bin/ && \mv bitcoin-cash-node-26.1.0/bin/bitcoin-cli /usr/local/bin/ && \rm -rf bitcoin-cash-node-26.1.0 # 配置 Bitcoin Cash 节点
COPY bitcoin.conf /root/.bitcoin/bitcoin.conf# 暴露节点端口
EXPOSE 8332 8333# 启动 Bitcoin Cash 节点
CMD ["/usr/local/bin/bitcoind"]

3、编写bitcoin配置文件
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim bitcoin.conf

server=1
txindex=1
listen=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
rpcport=8332
rpcuser=bch
rpcpassword=asfefsdfwefdsafedsdfwe
uacomment=bitcore-bch
datadir=/bitcoin/data
#timestampindex=1

4、编写docker-compose.yml文件

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim docker-compose.yml
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# cat docker-compose.yml 
version: '3'services:bch-node:image: bch/bitcoin-cash-node:v26.1.0volumes:- ./bitcoin.conf:/root/.bitcoin/bitcoin.conf- ./data:/bitcoin/dataports:- 8332:8332- 8333:8333

5、打镜像

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker build . -t bch/bitcoin-cash-node:v26.1.0
[+] Building 54.0s (10/10) FINISHED                                                                                                                                                                                                           => [internal] load .dockerignore                                                                                                                                                                                                        0.0s=> => transferring context: 2B                                                                                                                                                                                                          0.0s=> [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s=> => transferring dockerfile: 670B                                                                                                                                                                                                     0.0s=> [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                          2.5s=> [internal] load build context                                                                                                                                                                                                        0.1s=> => transferring context: 31.06MB                                                                                                                                                                                                     0.1s=> [1/5] FROM docker.io/library/ubuntu:20.04@sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01                                                                                                                    2.0s=> => resolve docker.io/library/ubuntu:20.04@sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01                                                                                                                    0.0s=> => sha256:01085d60b3a624c06a7132ff0749efc6e6565d9f2531d7685ff559fb5d0f669f 27.51MB / 27.51MB                                                                                                                                         1.5s=> => sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01 1.13kB / 1.13kB                                                                                                                                           0.0s=> => sha256:8c38f4ea0b178a98e4f9f831b29b7966d6654414c1dc008591c6ec77de3bf2c9 424B / 424B                                                                                                                                               0.0s=> => sha256:14be0685b7682b182af5b862c9638cb1cb4ca1a70bd5aa90deed96e9cca881e7 2.30kB / 2.30kB                                                                                                                                           0.0s=> => extracting sha256:01085d60b3a624c06a7132ff0749efc6e6565d9f2531d7685ff559fb5d0f669f                                                                                                                                                0.4s=> [2/5] RUN apt-get update && apt-get install -y     curl     libssl-dev     libevent-dev     software-properties-common                                                                                                              47.6s=> [3/5] ADD bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz .                                                                                                                                                                         0.5s=> [4/5] RUN mv bitcoin-cash-node-26.1.0/bin/bitcoind /usr/local/bin/ &&     mv bitcoin-cash-node-26.1.0/bin/bitcoin-cli /usr/local/bin/ &&     rm -rf bitcoin-cash-node-26.1.0                                                         0.3s => [5/5] COPY bitcoin.conf /root/.bitcoin/bitcoin.conf                                                                                                                                                                                  0.0s => exporting to image                                                                                                                                                                                                                   1.0s => => exporting layers                                                                                                                                                                                                                  1.0s => => writing image sha256:bb00a8466266b6e11326bc5b2241f1b7610f27cbbe0611c22105a966bf8f818f                                                                                                                                             0.0s => => naming to docker.io/bch/bitcoin-cash-node:v26.1.0

6、启动容器

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# mkdir bitcoin
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# chmod 777 bitcoin -R
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# mv bitcoin data
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker-compose up -d
Starting bch_bch-node_1 ... done

7、查看节点同步情况

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker exec -it bch_bch-node_1 /bin/bash
root@496cbc45ff5a:/# bitcoin-cli -conf=/root/.bitcoin/bitcoin.conf  getblockchaininfo
{"chain": "main","blocks": 220892,"headers": 800413,"bestblockhash": "00000000000001faa5f06c81b98ef9d008b5853243fa8449c1b4b1f2e6c76194","difficulty": 3275464.586565617,"mediantime": 1360719428,"verificationprogress": 0.03421628954813776,"initialblockdownload": true,"chainwork": "00000000000000000000000000000000000000000000002a375ba8ca11508bcd","size_on_disk": 6433940923,"pruned": false,"warnings": ""
}

区块浏览器上对比
区块浏览器地址
在这里插入图片描述
curl测试
获取区块高度

curl --user bch:asfefsdfwefdsafedsdfwe --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "ping", "params": [] }' -H 'content-type: text/plain;' http://localhost:8332
{"result":null,"error":null,"id":"curltest"}

获取最新区块信息

curl --user bch:asfefsdfwefdsafedsdfwe --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": [] }' -H 'content-type: text/plain;' http://localhost:8332
{"result":null,"error":{"code":-1,"message":"getblock \"blockhash\" ( verbosity )\n\nIf verbosity is 0 or false, returns a string that is serialized, hex-encoded data for block 'hash'.\nIf verbosity is 1 or true, returns an Object with information about block <hash>.\nIf verbosity is 2, returns an Object with information about block <hash> and information about each transaction, including fee.\nIf verbosity is >=3, returns an Object with information about block <hash> and information about each transaction, including fee, and including prevout information for inputs (only for unpruned blocks in the current best chain).\n\nArguments:\n1. \"blockhash\"    (string, required) The block hash\n2. verbosity      (numeric, optional, default=1) 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data, and 3 for JSON object with transaction data including prevout information for inputs\n\nResult (for verbosity = 0):\n\"data\"                   (string) A string that is serialized, hex-encoded data for block 'hash'.\n\nResult (for verbosity = 1):\n{\n  \"hash\" : \"hash\",       (string) The block hash (same as provided)\n  \"confirmations\" : n,   (numeric) The number of confirmations, or -1 if the block is not on the main chain\n  \"size\" : n,            (numeric) The block size\n  \"height\" : n,          (numeric) The block height or index\n  \"version\" : n,         (numeric) The block version\n  \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n  \"merkleroot\" : \"xxxx\", (string) The merkle root\n  \"tx\" : [               (array of string) The transaction ids\n     \"transactionid\"     (string) The transaction id\n     ,...\n  ],\n  \"time\" : ttt,          (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n  \"mediantime\" : ttt,    (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n  \"nonce\" : n,           (numeric) The nonce\n  \"bits\" : \"1d00ffff\",   (string) The bits\n  \"difficulty\" : x.xxx,  (numeric) The difficulty\n  \"chainwork\" : \"xxxx\",  (string) Expected number of hashes required to produce the chain up to this block (in hex)\n  \"nTx\" : n,             (numeric) The number of transactions in the block.\n  \"previousblockhash\" : \"hash\",  (string) The hash of the previous block\n  \"nextblockhash\" : \"hash\"       (string) The hash of the next block\n}\n\nResult (for verbosity = 2):\n{\n  ...,                   Same output as verbosity = 1\n  \"tx\" : [               (json array)\n    {                    (json object)\n      ...,               The transactions in the format of the getrawtransaction RPC; different from verbosity = 1 \"tx\" result\n      \"fee\" : n          (numeric) The transaction fee in BCH, omitted if block undo data is not available\n    },\n    ...\n  ],\n  ...                    Same output as verbosity = 1\n}\n\nResult (for verbosity >= 3):\n{\n  ...,                   Same output as verbosity = 2\n  \"tx\" : [               (json array)\n    {                    (json object)\n      ...,               Same output as verbosity = 2\n      \"vin\" : [          (json array)\n        {                (json object)\n          ...,           Same output as verbosity = 2\n          \"prevout\" : {                 (json object, optional) (Only if undo information is available)\n            \"generated\" : true|false,   (boolean) Coinbase or not\n            \"height\" : n,               (numeric) The height of the prevout\n            \"value\" : n,                (numeric) The value in BCH\n            \"scriptPubKey\" : {          (json object)\n              \"asm\" : \"str\",            (string) The asm\n              \"hex\" : \"str\",            (string) The hex\n              \"type\" : \"str\",           (string) The type (one of: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata)\n              \"address\" : \"str\"         (string, optional) The Bitcoin Cash address (only if well-defined address exists)\n            },\n            \"tokenData\" : {             (json object, optional) CashToken data (only if the input contained a token)\n              \"category\" : \"hex\",       (string) Token id\n              \"amount\" : \"xxx\",         (string) Fungible amount (is a string to support >53-bit amounts)\n              \"nft\" : {                 (json object, optional) NFT data (only if the token has an NFT)\n                \"capability\" : \"xxx\",   (string) One of \"none\", \"mutable\", \"minting\"\n                \"commitment\" : \"hex\"    (string) NFT commitment formatted as hexadecimal\n              },\n            }\n          }\n        },\n        ...\n      ]\n    },\n    ...\n  ],\n  ...                    Same output as verbosity = 2\n}\n\nExamples:\n> bitcoin-cli getblock \"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"\n> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"getblock\", \"params\": [\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n"},"id":"curltest"}

这篇关于docker-compose部署BCH节点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/211394

相关文章

centos7基于keepalived+nginx部署k8s1.26.0高可用集群

《centos7基于keepalived+nginx部署k8s1.26.0高可用集群》Kubernetes是一个开源的容器编排平台,用于自动化地部署、扩展和管理容器化应用程序,在生产环境中,为了确保集... 目录一、初始化(所有节点都执行)二、安装containerd(所有节点都执行)三、安装docker-

在Ubuntu上部署SpringBoot应用的操作步骤

《在Ubuntu上部署SpringBoot应用的操作步骤》随着云计算和容器化技术的普及,Linux服务器已成为部署Web应用程序的主流平台之一,Java作为一种跨平台的编程语言,具有广泛的应用场景,本... 目录一、部署准备二、安装 Java 环境1. 安装 JDK2. 验证 Java 安装三、安装 mys

更改docker默认数据目录的方法步骤

《更改docker默认数据目录的方法步骤》本文主要介绍了更改docker默认数据目录的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1.查看docker是否存在并停止该服务2.挂载镜像并安装rsync便于备份3.取消挂载备份和迁

Docker集成CI/CD的项目实践

《Docker集成CI/CD的项目实践》本文主要介绍了Docker集成CI/CD的项目实践,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学... 目录一、引言1.1 什么是 CI/CD?1.2 docker 在 CI/CD 中的作用二、Docke

如何在一台服务器上使用docker运行kafka集群

《如何在一台服务器上使用docker运行kafka集群》文章详细介绍了如何在一台服务器上使用Docker运行Kafka集群,包括拉取镜像、创建网络、启动Kafka容器、检查运行状态、编写启动和关闭脚本... 目录1.拉取镜像2.创建集群之间通信的网络3.将zookeeper加入到网络中4.启动kafka集群

Jenkins中自动化部署Spring Boot项目的全过程

《Jenkins中自动化部署SpringBoot项目的全过程》:本文主要介绍如何使用Jenkins从Git仓库拉取SpringBoot项目并进行自动化部署,通过配置Jenkins任务,实现项目的... 目录准备工作启动 Jenkins配置 Jenkins创建及配置任务源码管理构建触发器构建构建后操作构建任务

若依部署Nginx和Tomcat全过程

《若依部署Nginx和Tomcat全过程》文章总结了两种部署方法:Nginx部署和Tomcat部署,Nginx部署包括打包、将dist文件拉到指定目录、配置nginx.conf等步骤,Tomcat部署... 目录Nginx部署后端部署Tomcat部署出现问题:点击刷新404总结Nginx部署第一步:打包

Nginx、Tomcat等项目部署问题以及解决流程

《Nginx、Tomcat等项目部署问题以及解决流程》本文总结了项目部署中常见的four类问题及其解决方法:Nginx未按预期显示结果、端口未开启、日志分析的重要性以及开发环境与生产环境运行结果不一致... 目录前言1. Nginx部署后未按预期显示结果1.1 查看Nginx的启动情况1.2 解决启动失败的

闲置电脑也能活出第二春?鲁大师AiNAS让你动动手指就能轻松部署

对于大多数人而言,在这个“数据爆炸”的时代或多或少都遇到过存储告急的情况,这使得“存储焦虑”不再是个别现象,而将会是随着软件的不断臃肿而越来越普遍的情况。从不少手机厂商都开始将存储上限提升至1TB可以见得,我们似乎正处在互联网信息飞速增长的阶段,对于存储的需求也将会不断扩大。对于苹果用户而言,这一问题愈发严峻,毕竟512GB和1TB版本的iPhone可不是人人都消费得起的,因此成熟的外置存储方案开

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06