Tips: 按照官方说法,每两周会重置一次数据
操作系统建议采用Linux,发行版建议采用 Debian
或 Ubuntu
,官方测试的版本是:Ubuntu version 18.04 (Bionic Beaver),建议使用 Ubunt 18.04。
$ apt-get update \
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC && \
apt-get install -y --no-install-recommends \
tzdata \
git \
ca-certificates \
curl \
build-essential \
libssl-dev \
pkg-config \
libclang-dev \
cmake
配置全节点有两种方式,第一种方式是通过 Docker
,第二种方式采用 源码编译
下面介绍采用docker的方式运行全节点
如果系统自带了docker,建议删除,因为系统自带的docker一般版本都比较低,删除命令如下:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
1、更新apt源,并安装相关工具
$ sudo apt-get update &&apt-get install ca-certificates curl gnupg lsb-release
2、增加 docker 官方 GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
3、使用以下命令设置存储库
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
1、更新 apt
包索引,以及安装docker、containerd、以及docker-compose
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
root@sui-devnet-fullnode:~# systemctl status docker -l
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-07-19 07:01:50 UTC; 1min 24s ago
Docs: https://docs.docker.com
Main PID: 4603 (dockerd)
Tasks: 9
CGroup: /system.slice/docker.service
└─4603 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.676161749Z" level=warning msg="Your kernel does not support CPU realtime scheduler"
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.676174578Z" level=warning msg="Your kernel does not support cgroup blkio weight"
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.676245166Z" level=warning msg="Your kernel does not support cgroup blkio weight_device"
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.676568360Z" level=info msg="Loading containers: start."
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.788875689Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP ad
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.861608788Z" level=info msg="Loading containers: done."
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.878429267Z" level=info msg="Docker daemon" commit=a89b842 graphdriver(s)=overlay2 version=20.10.17
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.878611210Z" level=info msg="Daemon has completed initialization"
Jul 19 07:01:50 instance-1 systemd[1]: Started Docker Application Container Engine.
Jul 19 07:01:50 instance-1 dockerd[4603]: time="2022-07-19T07:01:50.907320312Z" level=info msg="API listen on /var/run/docker.sock"
首先建议创建一个目录用于存放相关的配置文件,这里我会创建一个 /blockchain/sui/devtest
目录,并 cd /blockchain/sui/devnet
进入该目录
root@sui-devnet-fullnode:~# mkdir -p /blockchain/sui/devtest
root@sui-devnet-fullnode:~# cd !$
cd /blockchain/sui/devtest
root@sui-devnet-fullnode:/blockchain/sui/devtest# pwd
/blockchain/sui/devtest
root@sui-devnet-fullnode:/blockchain/sui/devtest#
Tips: 后续所有的操作均在该目录中执行
为了防止由于网络中断导ssh断开,我一般会使用 tmux工具进行session的管理,防止网络断开。
1、安装 tmux
sudo apt install tmux
2、创建 session
tmux new -s "sui-devnet-docker-full-node"
Tips: 命名规则 项目-网络-运行环境-服务
wget https://raw.githubusercontent.com/MystenLabs/sui/main/docker/fullnode/docker-compose.yaml
下载配置文件并修改监听的地址
wget https://github.com/MystenLabs/sui/raw/main/crates/sui-config/data/fullnode-template.yaml
sed -i 's/127.0.0.1:9184/0.0.0.0:9184/' fullnode-template.yaml
sed -i 's/127.0.0.1:9000/0.0.0.0:9000/' fullnode-template.yaml
wget https://github.com/MystenLabs/sui-genesis/raw/main/devnet/genesis.blob
docker-compose up
Tips: 这个过程会同步全网的交易信息,需要等待同步完成。
一旦全节点启动并运行,测试一些 JSON-RPC 接口。
root@sui-devnet-fullnode:~# curl --location --request POST 'http://127.0.0.1:9000/' --header 'Content-Type: application/json' --data-raw '{ "jsonrpc":"2.0", "id":1, "method":"sui_getRecentTransactions", "params":[5] }' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 384 100 305 100 79 148k 39500 --:--:-- --:--:-- --:--:-- 375k
{
"jsonrpc": "2.0",
"result": [
[
5453,
"zJOQcvMU4pxDlb6OdyCFBUzUKn7Uo24ItMUkJvpwTDY="
],
[
5454,
"LBxEhZ0qFFNHJYHaAtYEeAkD/JhFyuKVqIw/0Xuy42M="
],
[
5455,
"+6c8+hkWruOBgCqnh/sL2M7doqRkocR3OQII+8F8Jo8="
],
[
5456,
"BUuM254vnSaSLKl+9lxXvxie0Yh0FqxqXnXLQRvYe9Y="
],
[
5457,
"76Vc5FiTd28mK43XM4FiRZNAdYoqXri5da7KuTt3R8c="
]
],
"id": 1
}
curl --location --request POST 'http://127.0.0.1:9000/' \
--header 'Content-Type: application/json' \
--data-raw '{ "jsonrpc":"2.0", "id":1, "method":"sui_getTransaction", "params":["$RECENT_TXN_FROM_ABOVE"] }'
docker-compose up -d
docker-compose stop
重置之前建议备份您的相关配置文件
docker-compose down --volumes
docker ps
docker exec -it -u 0 $CONTAINER_ID /bin/bash
ls -la suidb/
更新全节点配置中的 json-rpc-address 以监听所有地址:
sed -i 's/127.0.0.1/0.0.0.0/' fullnode-template.yaml
-json-rpc-address: "127.0.0.1:9000"
+json-rpc-address: "0.0.0.0:9000"
针对以上的步骤,本人编写了一个脚本用于自动安装,请了解的朋友自行安装。
https://raw.githubusercontent.com/iopssre/sui-install/master/sui-full-node-install.sh