问题: 搭建私有链并开始挖矿出现OOM。内存一直增长直到杀geth进程
搭建以太坊私有链
Dockerfile
-----------------------------------
FROM ubuntu
LABEL version="1.0"
LABEL maintainer="test@outlook.com"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --yes software-properties-common
RUN add-apt-repository ppa:ethereum/ethereum
RUN apt-get update && apt-get install --yes geth
COPY genesis.json /home/root/genesis.json
RUN chown -R root:root /home/root/genesis.json
USER root
WORKDIR /home/root
ENTRYPOINT bash
-----------------------------------
- 构建Docker镜像
docker build -t eth_node .
- 启动Docker镜像
docker run --rm -it -p 8546:8545 -v /eth/data/node1:/home/root --name eth_dev_node1 eth_node
- 进入/eth/data/node1/ 创建 genesis.json 创世纪
``
{
"alloc": {
},
"config": {
"chainId": 1800,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x000000000000002a",
"difficulty": "0x002000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x2fefd8"
}
- 进入节点
docker exec -it {cointainerId} /bin/bash
- geth 版本
geth version 1.8.12-stable
- 初始化
geth --datadir /home/root/ init genesis.json
- 启动命令
nohup geth --datadir /home/root/ --identity "NODE_1" --gcmode archive --rpc --rpccorsdomain "*" --networkid=1800 --rpc --rpcaddr 0.0.0.0 --rpcport "8545" --port "30303" --rpcapi "db,eth,net,web3,admin,personal,miner" --nodiscover --cache 16 &
- 进入geth
geth attach geth.ipc
- 创建账号
personal.newAccount("123456")
- 启动挖矿
miner.start(1)
在docker启动的端口8546上链接其他节点过,现在端口号修改后重新启动就可以了,或许同步节点异常导致内存爆。