Centos7 builds bsc full chain node
server configuration
CPU:8 Cores - 16 Threads
RAM:131072 MB
Storage:2x 2000GB NVMe
Bandwidth:8400.65 GB of 10000 GB
OS:
CentOS 7 x64
服务器位置: 东京
Because you need to download a 1.4T node snapshot and decompress it, it is best to have a 4T disk
The server is composed of two 2T disks, so first mount the disk
mount new disk
1. View the current mount device of the server
fdisk -l
#(当前服务器已经挂载好了,新磁盘为nvme1n1, 应输入fdisk -l查看自己服务器未挂载的磁盘)
磁盘 /dev/nvme1n1:2000.4 GB, 2000398934016 字节,3907029168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/nvme0n1:2000.4 GB, 2000398934016 字节,3907029168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000e0a65
设备 Boot Start End Blocks Id System
/dev/nvme0n1p1 * 2048 3907029134 1953513543+ fd Linux raid autodetect
磁盘 /dev/md0:2000.4 GB, 2000394722816 字节,3907020943 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
2. Delete the original partition
fdisk /dev/nvme1n1
#nvme1n1位需挂载的设备名
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):d
已选择分区 1
分区 1 已删除
命令(输入 m 获取帮助):p
磁盘 /dev/nvme1n1:2000.4 GB, 2000398934016 字节,3907029168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x04fc5a3c
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
3. Create a new partition
fdisk /dev/nvme1n1
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-3907029167,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-3907029167,默认为 3907029167):
将使用默认值 3907029167
分区 1 已设置为 Linux 类型,大小设为 1.8 TiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
4. Format the partition
mkfs.ext3 /dev/nvme1n1
5. Mount and use
# 新建一个挂载点。
mkdir /data
# 挂载。
mount /dev/sdb1 /data
#查看是否挂载成功
[root@guest ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 34M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/md0 1.8T 1.5T 208G 89% /
tmpfs 13G 0 13G 0% /run/user/0
/dev/nvme1n1 1.8T 1.4T 322G 82% /data
在最后一行
磁盘因为已经使用过了所以有占用
6. Automatically mount when booting
vim /etc/fstab
在底部添加
/dev/nvme1n1 /data ext3 defaults 1 2
So far the disk has been mounted successfully
upgrade of centos7 git
Because the default git version of centos7 is 1.8, there will be version problems when using git in the future, so you must upgrade git first
install dependencies
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install gcc perl-ExtUtils-MakeMaker
Uninstall the old version of git
yum remove git
open folder
cd /usr/local/src/
Download the git compressed package
The compressed package version is 2.32
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.32.0.tar.xz
unzip
tar -xvf git-2.32.0.tar.xz
Open the decompressed git file
cd git-2.32.0
compile
make prefix=/usr/local/git all
install git
make prefix=/usr/local/git install
Configure environment variables
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile && source /etc/profile
#验证git版本
git --version
Install other required plugins
yum -y upgrade
yum install wget -y
yum install golang -y
#验证go的版本
go version
#如正确显示版本号则安装正确
#go version go1.18.1 linux/amd64
yum -y install screen
At this point, the preparations have been done, and the bsc chain will be formally built below
Construction of BSC chain
cd / #进入根目录
mkdir -p jiedian/kuaizhao #创建jiedian及kuaizhao文件夹
cd /jiedian #进入jiedian文件夹
git clone https://github.com/binance-chain/bsc
cd bsc/
make geth
configuration path
vim /etc/profile
#把下列一行写到最后边然后 :wq 保存退出
export PATH=$PATH:/jiedian/bsc/build/bin
#然后使命令生效
source /etc/profile
#使用geth version确认安装正确
Configure Genesis Block
wget https://github.com/binance-chain/bsc/releases/download/v1.1.9/mainnet.zip
unzip mainnet.zip
geth --datadir node init genesis.json
Download BSC Snapshot
Create a screen window for downloading snapshots
- After entering the screen window, if you want to exit, press and hold ctrl+a+d successively
- After exiting the window, enter screen -ls in the main window to view other windows opened
- screen -x <window name> connect into the window
Note that the link address in the wget -O geth.tar.lz4 command below must be within double quotes
Notice! ! ! ! ! : The download address given on the official website is an https connection. If the network environment is poor, it will easily lead to ssl failure to verify the problem, which will interrupt the download and waste server traffic. If this problem occurs, you can copy and download the connection and change the https at the beginning to http.
screen -S xiazai
cd /data #下载至上文所挂载的新磁盘
wget -O geth.tar.lz4 "最新下载地址"
Snapshot download link: https://github.com/binance-chain/bsc-snapshots
The compressed package is about 1.4T
After the download is complete, unzip the file to /jiedian/kuaizhao
And move the chaindata and triecache in this file to the /jiedian/bsc/node/geth folder
The node folder is automatically generated after configuring mainnet above
tar -I lz4 -xvf geth.tar.lz4
mv /jiedian/kuaizhao/server/data-seed/geth/chaindata /jiedian/bsc/node/geth
mv /jiedian/kuaizhao/server/data-seed/geth/triecache /jiedian/bsc/node/geth
ctrl+ad #退出xiazai窗口
Start BSC full node
screen -S bsc #创建bsc节点启动窗口
1
geth --config ./config.toml --datadir ./node --diffsync --cache 86016 --rpc.allow-unprotected-txs --txlookuplimit 0 --rpc.txfeecap 0 --rpc.gascap 0
Parameter Description:
–config: specify the BSC node configuration file
–datadir: specify the data directory of the BSC node database and key repository (the default is fine)
–cache: Set the maximum memory allocated to the internal cache, default: 1024 (the larger the setting, the more data will be synchronized each time, and the more memory will be consumed)
--rpc.allow-unprotected-txs: Allow submitting unprotected (non-EIP155 signed) transactions via RPC
–txlookuplimit 0 : disable deleting transaction index
--diffsync: enable the diff sync protocol to help nodes sync faster
–rpc.txfeecap: unlimited gas fee
–rpc.gascap: No transaction fee cap
ctrl + a + a #返回主窗口
node monitoring
geth attach http://127.0.0.1:8545
#这里的端口如果修改配置文件了,就填写配置文件的端口即可
> eth.syncing #查看当前块情况
> net.peerCount #查看当前连接节点数量,结果为false为同步完成
> eth.blockNumber #当前同步到块高度
nginx configuration file
Let the node provide ws connection to the external server
server{
listen 80;
server_name # 你的网址名称
# 重点,转发websocket需要的设置
location / {
proxy_pass http://127.0.0.1:8545/;
}
# 所有请求都转发
location /ws {
proxy_pass http://127.0.0.1:8546/;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X_Forward_For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
}
If you have any questions about building a node, you can join our community group to ask questions
There are also some experience sharing about solidity learning in the group
And some free gadgets to share
Reference article: https://learnblockchain.cn/article/3888
Get more blockchain learning materials through Github!