1. 硬件要求
- 500GB+ SSD硬盘;(数据每月大约增加20GB)
- 8GB+ 内存;
- 互联网带宽400kbps+;
2. 下载
前往以太坊官网下载安装程序,如:
mkdir /opt/install
cd /opt/install
wget -c 'https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.9.18-f5382591.tar.gz'
3. 安装及配置
mkdir -p /opt/geth
cd /opt/geth
tar -zxvf /opt/install/geth-alltools-linux-amd64-1.9.18-f5382591.tar.gz
mv geth-1.9.18 1.9.18
chmod -R 755 /opt/geth/1.9.18
生成配置文件:
mkdir -p /data/geth/conf
/opt/geth/1.9.18/geth dumpconfig --datadir "/data/geth" --keystore "/data/geth/keystore" --port 19003 --syncmode "fast" --ethash.dagdir "/data/geth/geth/ethash" --rpc --rpcaddr 192.168.0.1 --rpcport 19190 --wsport 18546 --graphql.port 18547 --rpcapi "db,eth,miner,net,web3,personal" --cache 4096 --mine --minerthreads 1 --rpccorsdomain "*" --ipcpath "/data/geth/geth.ipc" --allow-insecure-unlock > /data/geth/conf/geth.conf
groupadd geth
useradd -M -d /data/geth -g geth -G geth -s /usr/sbin/nologin geth
chown -R geth:geth /data/geth
同时,注意开启以上配置端口19003
(TCP
和UDP
)、19190
(TCP
)的防火墙(安全组)规则以允许访问。注意:其中19190
尽量不暴露到公网,仅供私网资源访问。
4. 启动/停止服务
Ubuntu 18.04上推荐使用systemd
进行启动/停止服务。将以下内容保存到/etc/systemd/system/geth.service
作为systemd
的启/停服务脚本:
[Unit]
Description=Go Ethereum
After=network.target
[Service]
Type=simple
User=geth
Group=geth
ExecStart=/opt/geth/1.9.18/geth --config /data/geth/conf/geth.conf
PIDFile=/var/run/geth/geth.pid
Restart=on-failure
CapabilityBoundingSet=
PrivateTmp=true
PrivateDevices=true
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true
RuntimeDirectory=geth
RuntimeDirectoryMode=775
MemoryDenyWriteExecute=true
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
[Install]
WantedBy=multi-user.target
注意:根据安装目录和配置文件目录修改其中的geth
、geth.conf
所在的路径,以及rpcconnect
的主机IP、启/停服务的用户属主(User
)/属组(Group
)值。
配置完成,执行下面的命令加载systemd
服务脚本:
systemctl daemon-reload
执行下面的命令,启动服务:
systemctl start geth.service
执行下面的命令,停止服务:
systemctl stop geth.service
扫码或搜一搜关注微信公众号:才见,获取更多干货和资源