我已经尝试过" carauction-network"在我当地的例子。但是,当我使用" startFabric.sh"启动网络时文件,它正在删除Couch DB&再次创建Couch DB,由于这些旧数据丢失了。请建议我们如何在不清除数据的情况下启动结构服务器。
答案 0 :(得分:18)
fabric-dev-servers (以前称为fabric-tools)下的startFabric.sh
不仅可以启动Fabric,还可以删除现有的Fabric容器并从Docker Images重新创建新容器。这样做的影响是您从Fabric中丢失了所有数据和业务网络。除了PeerAdmin @ hlfv1之外的所有商业网卡现在都没用了。
如果您想在创建Fabric后停止并启动它,请保留您的业务网络和数据,请遵循以下命令:
docker-compose.yml
文件所在的目录(例如/home/<user>/fabric-tools/fabric-scripts/hlfv1/composer
)docker-compose stop
以覆盖Fabric Containers docker-compose start
以重新开始。 在使用docker-compose命令之前,必要位于正确的文件夹中。
VERSION UPDATE
使用Composer v0.20.x(适用于Fabric 1.2)文件夹&#39;名称/版本已更改:
/home/<user>/fabric-dev-servers/fabric-scripts/hlfv12/composer
使用Composer v0.19.x(旧版,适用于Fabric v1.1),文件夹名称/版本已更改:
/home/<user>/fabric-dev-servers/fabric-scripts/hlfv11/composer
答案 1 :(得分:5)
在fabric-dev-server / fabric-scripts / hlfv11中编辑你的startFabric.sh,如下所示
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Exit on first error, print all commands.
set -e
Usage() {
echo ""
echo "Usage: ./startFabric.sh [-d || --dev]"
echo ""
echo "Options:"
echo -e "\t-d or --dev: (Optional) enable fabric development mode"
echo ""
echo "Example: ./startFabric.sh"
echo ""
exit 1
}
Parse_Arguments() {
while [ $# -gt 0 ]; do
case $1 in
--help)
HELPINFO=true
;;
--dev | -d)
FABRIC_DEV_MODE=true
;;
esac
shift
done
}
Parse_Arguments $@
if [ "${HELPINFO}" == "true" ]; then
Usage
fi
#Detect architecture
ARCH=`uname -m`
# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "${FABRIC_DEV_MODE}" == "true" ]; then
DOCKER_FILE="${DIR}"/composer/docker-compose-dev.yml
else
DOCKER_FILE="${DIR}"/composer/docker-compose.yml
fi
ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" stop
ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" up -d
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
echo "sleeping for ${FABRIC_START_TIMEOUT} seconds to wait for fabric to complete start up"
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
#docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
# Join peer0.org1.example.com to the channel.
#docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b composerchannel.block
if [ "${FABRIC_DEV_MODE}" == "true" ]; then
echo "Fabric Network started in chaincode development mode"
fi
答案 2 :(得分:4)
要扩展R Thatcher的解决方案,如果您可以访问bash shell,则可以将此脚本放入fabric-dev-server文件夹中。它将按照上述步骤重新启动网络,而不会丢失数据。只需将cd插入正确的目录并运行docker-compose stop和docker-compose start。重新启动以恢复网络后,也可以正常运行。
#!/bin/bash
cd ./fabric-scripts/hlfv1/composer
docker-compose stop
docker-compose start
似乎微不足道,并没有增加太多讨论,但节省了时间。