最新版本系统软件
yum update -y
yum install -y yum-utils device-mapper-persistent-data lvm2
设置yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
可以查看所有仓库中所有docker版本,并选择特定版本安装
yum list docker-ce --showduplicates | sort -r
安装
yum install docker-ce-18.06.3.ce-3.el7 -y
启动
systemctl enable docker && systemctl start docker
配置镜像加速器,通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://ijdk512y.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload && systemctl restart docker
运行此命令以下载 Docker Compose 的当前稳定版本
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
二进制文件应用可执行权限
chmod +x /usr/local/bin/docker-compose
创建链接
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
查看版本
docker-compose -version
mkdir /usr/local/java && cd /usr/local/java
tar -C /usr/local/java -zxvf jdk-8u321-linux-x64.tar.gz
配置Java环境,编辑/etc/profile文件
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_321
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
安装依赖包
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
mkdir /usr/local/python3
tar -xf Python-3.7.10.tgz && cd Python-3.7.10
编译安装
./configure --prefix=/usr/local/python3
make && make install
建立Python3的软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
安装pykmip等
pip3 install pykmip toml requests requests_toolbelt
yum -y install centos-release-scl
yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
scl enable devtoolset-8 bash
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
cd /usr/local
tar -xf make-4.2.tar.gz
cd make-4.2
./configure
make
make install
rm -rf /usr/bin/make
cp ./make /usr/bin/
make -v
升级GLIBCXX
出现这个错误,是因为CentOS7当前版本默认的GCC的版本太老,里面的动态链接库没有GLIBCXX_3.4.21。
cd /usr/local/lib64/
# 解压
unzip libstdc.so_.6.0.26.zip
# 将下载的最新版本拷贝到 /usr/lib64
cp libstdc++.so.6.0.26 /usr/lib64
cd /usr/lib64
# 查看 /usr/lib64下libstdc++.so.6链接的版本
ls -l | grep libstdc++
# 删除原先的软连接(不放心可以备份)
rm libstdc++.so.6
# 使用最新的库建立软连接
ln -s libstdc++.so.6.0.26 libstdc++.so.6
# 查看新版本,成功
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
升级GLIBC
/usr/local/app/tars/tarsnode/bin/tarsnode: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/app/tars/tarsnode/bin/tarsnode)
出现这个错误,会使tarsnode节点服务启动失败。
cd /usr/local/
tar -xf glibc-2.31.tar.gz
cd glibc-2.31
mkdir build
cd build
yum install bison -y
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make
make install
strings /usr/lib64/libstdc++.so.6 | grep GLIBC_
192.168.229.189 |
20200 |
30300 |
192.168.229.190 |
20201 |
30301 |
选择在192.168.229.189服务器上安装tars服务
cd /opt/blockchain/fiscobcosV3
修改配置
1、修改tarsFramework的docker-compose配置,设置密码、ip(物理ip),指定网卡
cd /opt/blockchain/fiscobcosV3/BcosBuilder/docker/host/linux/framework
vi docker-compose.yml
version: "3"
services:
tars-mysql:
image: mysql:5.6
network_mode: "host"
environment:
MYSQL_ROOT_PASSWORD: "FISCO"
MYSQL_TCP_PORT: 3310
restart: always
volumes:
- ~/app/tars/framework-mysql:/var/lib/mysql
- /etc/localtime:/etc/localtime
tars-framework:
image: tarscloud/framework:v3.0.1
network_mode: "host"
environment:
MYSQL_HOST: "192.168.229.189"
MYSQL_ROOT_PASSWORD: "FISCO"
MYSQL_PORT: 3310
REBUILD: "false"
INET: ens33
SLAVE: "false"
restart: always
volumes:
- ~/app/tars/framework:/data/tars
- /etc/localtime:/etc/localtime
depends_on:
- tars-mysql
注:使用host模式时,需要在配置文件的INET项指定网卡,可使用ip addr查看网卡。
若使用默认网卡会出现以下错误:
2、修改tarsnode的docker-compose配置
cd /opt/blockchain/fiscobcosV3/BcosBuilder/docker/host/linux/node
vi docker-compose.yml
version: "3"
services:
tars-node:
image: tarscloud/tars-node:latest
network_mode: "host"
environment:
INET: ens33
WEB_HOST: "http://192.168.229.189:3000"
restart: always
volumes:
- ~/app/tars:/data/tars
- /etc/localtime:/etc/localtime
创建tars管理服务
cd /opt/blockchain/fiscobcosV3/BcosBuilder/docker/host/linux/framework
docker-compose up -d
启动tars管理服务
cd /opt/blockchain/fiscobcosV3/BcosBuilder/docker/host/linux/framework
docker-compose start
查看
docker ps -a
访问
http://192.168.229.189:3000/ admin
安装tarsnode服务(重要)
为192.168.229.190服务器安装tarsnode服务
点击【运维管理】 -> 【节点管理】 -> 【自动安装节点】,填写服务器ip、登录用户/密码;
先【测试联通性】,连接成功后,点击【安装】;
在192.168.229.190服务器上查看;
ps -ef | grep tars
至此192.168.229.190服务器上的tarsnode服务安装成功。
申请token
【用户中心】 -> 【Token管理】 -> 【新增Token】
下载二进制
cd /opt/blockchain/fiscobcosV3/BcosBuilder/pro
python3 build_chain.py download_binary
修改配置文件
修改配置文件中ip、token。可参照官方文档进行修改。
cp conf/config-deploy-example.toml config.toml
vi config.toml
[tars]
tars_url = "http://192.168.229.189:3000"
tars_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJhZG1pbiIsImlhdCI6MTY2ODA1ODI3NCwiZXhwIjoxNzYyODM5MDc0fQ.6wl-tvAJTLZk4YFdw9GQPJHh4aVZxESH8GaEMBdHsk4"
tars_pkg_dir = "binary/"
[chain]
chain_id="chain0"
# the rpc-service enable sm-ssl or not, default disable sm-ssl
rpc_sm_ssl=false
# the gateway-service enable sm-ssl or not, default disable sm-ssm
gateway_sm_ssl=false
# the existed rpc service ca path, will generate new ca if not configured
#rpc_ca_cert_path=""
# the existed gateway service ca path, will generate new ca if not configured
#gateway_ca_cert_path="
[[group]]
group_id="group0"
# the genesis configuration path of the group, will generate new genesis configuration if not configured
# genesis_config_path = ""
# VM type, now only support evm/wasm
vm_type="evm"
# use sm-crypto or not
sm_crypto=false
# enable auth-check or not
auth_check=false
init_auth_address=""
# the genesis config
# the number of blocks generated by each leader
leader_period = 1
# the max number of transactions of a block
block_tx_count_limit = 1000
# consensus algorithm now support PBFT(consensus_type=pbft)
consensus_type = "pbft"
# transaction gas limit
gas_limit = "3000000000"
# compatible version, can be dynamically upgraded through setSystemConfig
# the default is 3.0.0-rc4
compatibility_version="3.0.0"
[[agency]]
name = "agencyA"
# enable data disk encryption for rpc/gateway or not, default is false
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# cipher_data_key =
[agency.rpc]
deploy_ip=["192.168.229.189"]
listen_ip="0.0.0.0"
listen_port=20200
thread_count=4
[agency.gateway]
deploy_ip=["192.168.229.189"]
listen_ip="0.0.0.0"
listen_port=30300
peers=["192.168.229.189:30300", "192.168.229.190:30301"]
[[agency.group]]
group_id = "group0"
[[agency.group.node]]
node_name = "node0"
deploy_ip = "192.168.229.189"
# enable data disk encryption for bcos node or not, default is false
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# cipher_data_key =
monitor_listen_port = "3902"
# monitor log path example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""
[[agency]]
name = "agencyB"
# enable data disk encryption for rpc/gateway or not, default is false
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# cipher_data_key =
[agency.rpc]
deploy_ip=["192.168.229.190"]
listen_ip="0.0.0.0"
listen_port=20201
thread_count=4
[agency.gateway]
deploy_ip=["192.168.229.190"]
listen_ip="0.0.0.0"
listen_port=30301
peers=["192.168.229.189:30300", "192.168.229.190:30301"]
[[agency.group]]
group_id = "group0"
[[agency.group.node]]
node_name = "node0"
deploy_ip = "192.168.229.190"
# enable data disk encryption for bcos node or not, default is false
enable_storage_security = false
# url of the key center, in format of ip:port, please refer to https://github.com/FISCO-BCOS/key-manager for details
# key_center_url =
# cipher_data_key =
monitor_listen_port = "3901"
# monitor log path example:"/home/fisco/tars/framework/app_log/"
monitor_log_path = ""
部署RPC服务
cd /opt/blockchain/fiscobcosV3/BcosBuilder/pro
部署并启动RPC服务
python3 build_chain.py chain -o deploy -t rpc
部署Gateway服务
cd /opt/blockchain/fiscobcosV3/BcosBuilder/pro
部署并启动Gateway服务
python3 build_chain.py chain -o deploy -t gateway
部署区块链节点服务
cd /opt/blockchain/fiscobcosV3/BcosBuilder/pro
部署并启动区块链节点服务
python3 build_chain.py chain -o deploy -t node
在192.168.229.190服务器上部署控制台
将192.168.229.189服务器目录下/opt/blockchain/fiscobcosV3/BcosBuilder/pro/generated/rpc/chain0/agencyBBcosRpcService/192.168.229.190/sdk/的证书拷贝到192.168.229.190服务器的/opt/blockchain/fiscobcosV3/console/conf目录下
cp -n config-example.toml config.toml
vi config.toml
[network]
messageTimeout = "10000"
defaultGroup="group0" # Console default group to connect
peers=["127.0.0.1:20201"] # The peer list to connect
启动控制台,部署HelloWorld合约并执行合约。
./start.sh
至此,FiscoBcos v3.0.1 pro版 host网络模式部署成功!