Skip to content

Commit

Permalink
[CE-85] Fix setup scripts and docs
Browse files Browse the repository at this point in the history
As new lib imported, there's problem by rebuilding images.

In this patchset, we add new image-clean scripts and re-org the scripts
and docs, to make the setup much easier to follow.

Change-Id: I4a9ba38546b0965902019f899974fd5f2772d09b
Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
  • Loading branch information
yeasy committed Jul 14, 2017
1 parent 0817214 commit affbdad
Show file tree
Hide file tree
Showing 31 changed files with 452 additions and 343 deletions.
58 changes: 36 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Copyright IBM Corp, All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -36,17 +35,19 @@ else
endif

.PHONY: \
all \
check \
clean \
doc \
log \
logs \
redeploy \
restart \
setup \
start \
stop \
all \ # default to run check
check \ # ci checking
clean \ # clean up the env, remove temp files
doc \ # start a doc server locally
image-clean \ # clean up all cello related images
log \ # show logs of specify service
logs \ # show logs of all services
setup-master \ # setup the master node
setup-worker \ # setup the worker node
redeploy \ # redeploy service(s)
start \ # start all services
restart \ # restart all services
stop \ # stop all services

all: check

Expand All @@ -55,22 +56,28 @@ check: ##@Code Check code format
make start && sleep 10 && make stop

clean: ##@Code Clean tox result
rm -rf .tox
rm -rf .tox .cache *.egg-info
find . -name "*.pyc" -o -name "__pycache__" -exec rm -rf "{}" \;

doc: ##@Create local online documentation
pip install mkdocs
mkdocs serve

# Use like "make log service=dashboard"
log: ##@Log tail special service log, Use like "make log service=dashboard"
docker-compose logs -f ${service} --tail=100
docker-compose logs -f ${service} --tail=200

logs: ##@Log tail for all service log
docker-compose logs -f --tail=200

# Use like "make redeploy service=dashboard"
redeploy: ##@Service Redeploy single service, Use like "make redeploy service=dashboard"
bash scripts/redeploy.sh ${service}
bash scripts/master_node/redeploy.sh ${service}

image-clean: ##@Clean all existing images to rebuild
echo "Clean all cello related images, may need to remove all containers before"
docker images | grep "cello-" | awk '{print $1}' | xargs docker rmi -f
docker rmi $(docker images -f dangling=true -q)

initial-env: ##@Configuration Initial Configuration for dashboard
$(SED) 's/\(STATIC_FOLDER=\).*/\1${STATIC_FOLDER}/' .env
Expand All @@ -79,24 +86,31 @@ initial-env: ##@Configuration Initial Configuration for dashboard

start: ##@Service Start service
@$(MAKE) $(START_OPTIONS)
bash scripts/start.sh
echo "Start all services..."
docker-compose up -d --no-recreate

stop: ##@Service Stop service
bash scripts/stop.sh
echo "Stop all services..."
docker-compose stop
echo "Remove all services..."
docker-compose rm -f -a

restart: stop start ##@Service Restart service

setup: ##@Environment Setup dependency for service environment
bash scripts/setup.sh
setup-master: ##@Environment Setup dependency for master node
bash scripts/master_node/setup.sh

setup-worker: ##@Environment Setup dependency for worker node
bash scripts/worker_node/setup.sh

build-js: ##@Nodejs Build js files for react
bash scripts/build_reactjs.sh
bash scripts/master_node/build_reactjs.sh

watch-mode: ##@Nodejs Run watch mode with js files for react
bash scripts/watch_mode.sh
bash scripts/master_node/watch_mode.sh

npm-install: ##@Nodejs Install modules with npm package management
bash scripts/npm_install.sh
bash scripts/master_node/npm_install.sh

HELP_FUN = \
%help; \
Expand Down
193 changes: 5 additions & 188 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,201 +12,18 @@ Cello follows a typical Master-Worker architecture. Hence there will be two type
For each Node, it is suggested as a Linux-based (e.g., Ubuntu 14.04+) server/vm:

## Worker Node
Currently we support Docker Host or Swarm Cluster as Worker Node. More types will be added soon.

For the Worker Node with meeting the [system requirements](#system-requirements), three steps are required:

* [Docker daemon setup](#docker-daemon-setup)
* [Docker images pulling](#docker-images-pulling)
* [Firewall Setup](#firewall-setup)

### System Requirements
* Hardware: 8c16g100g
* Docker engine:
- 1.10.0~1.13.0
* aufs-tools (optional): Only required on ubuntu 14.04.

### Docker Daemon Setup

Let Docker daemon listen on port 2375, and make sure Master can reach Worker Node through this port.

#### Ubuntu 14.04
Simple add this line into your Docker config file `/etc/default/docker`.

```sh
DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384"
```

Then restart the docker daemon with:

```sh
$ sudo service docker restart
```

#### Ubuntu 16.04
Update `/lib/systemd/system/docker.service` like

```
[Service]
DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384"
EnvironmentFile=-/etc/default/docker
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
```

Regenerate the docker service script and restart the docker engine:

```sh
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker.service
```

### Alternatively (for all Linux distro):
This will run the docker-daemon on port 2375 as long as the system is restarted or docker-daemon is killed.

```sh
$ sudo systemctl stop docker.service
$ sudo dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384 -D &
```

At last, run the follow test at Master node and get OK response, to make sure it can access Worker node successfully.

```sh
[Master] $ docker -H Worker_Node_IP:2375 version
```

### Docker Images Pulling
Pulling the necessary images.

#### Fabric v1.0

```bash
$ cd scripts/worker_node_setup && bash download_images.sh
```

#### Fabric v0.6 (TODO: deprecated soon)

For fabric v0.6, need to run the following command.

```bash
$ docker pull hyperledger/fabric-peer:x86_64-0.6.1-preview \
&& docker pull hyperledger/fabric-membersrvc:x86_64-0.6.1-preview \
&& docker pull yeasy/blockchain-explorer:latest \
&& docker tag hyperledger/fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-peer \
&& docker tag hyperledger/fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-baseimage \
&& docker tag hyperledger/fabric-membersrvc:x86_64-0.6.1-preview hyperledger/fabric-membersrvc
```


### Artifacts Preparation

Copy required artifacts to the `/opt/cello`, e.g.,

```bash
$ cp -r src/agent/docker/_compose_files/fabric-1.0 /opt/cello
```

### Firewall Setup
Make sure ip forward is enabled, you can simply run the follow command.
Currently we support Docker Host or Swarm Cluster as Worker Node. More types will be added soon.

```sh
$ sysctl -w net.ipv4.ip_forward=1
```
And check the os iptables config, to make sure host ports are open (e.g., 2375, 7050~10000)
`Docker Host`: See [Installation on Worker Docker Node](installation_worker_docker.md).
`Docker Swarm `: TODO.
`Kubernetes`: TODO.

## Master Node
The Master Node includes several services:

* dashboard: Provide Web UI for operators.
* restserver: Provide RESTful APIs for chain consumers.
* watchdog: Watch for health checking.

*More details can be found at the [architecture doc](docs/arch.md).*

It can be deployed by in 3 steps.

* Clone code
* Pull Docker images
* Run setup script

### System Requirement
* Hardware: 8c16g100g
* Docker engine: 1.10.0~1.13.0
* docker-compose: 1.8.0+

### Clone Code

You may check `git` and `make` are installed to clone the code.

```sh
$ sudo aptitude install git make -y
$ git clone http://gerrit.hyperledger.org/r/cello && cd cello
```

### Docker Images Pulling

Pull the following images

```bash
$ docker pull python:3.5 \
&& docker pull mongo:3.2 \
&& docker pull yeasy/nginx:latest \
&& docker pull mongo-express:0.30
```

*Note: mongo-express:0.30 is for debugging the db, which is optional for basic setup.*

### Run Setup

For the first time running, please setup the master node with

```sh
$ make setup
```

Make sure there is no error during the setup. Otherwise, please check the log msgs.

### Usage

#### Start/Stop/Restart
To start the whole services, please run

```sh
$ make start
```

To stop or restart the whole services, run `make stop` or `make restart`.

#### Redploy a service
To redeploy one specific service, e.g., dashboard, please run

```sh
$ make redeploy service=dashboard
```

#### Check Logs
To check the logs for all the services, please run

```sh
$ make logs
```

To check the logs for one specific service, please run
```sh
$ make log service=watchdog
```

Now you can access the `MASTER_NODE_IP:8080` to open the Web-based [operational dashboard](docs/dashboard.md).

### Configuration
The application configuration can be imported from file named `CELLO_CONFIG_FILE`.

By default, it also loads the `config.py` file as the configurations.
See [Installation on Master Node](installation_master.md).

### Data Storage
The mongo container will use local `/opt/cello/mongo` directory for persistent storage.

Please keep it safe by backups or using more high-available solutions.

*Licensed under Creative Commons Attribution 4.0 International License
https://creativecommons.org/licenses/by/4.0/*
Expand Down
80 changes: 80 additions & 0 deletions docs/installation_master.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
## Master Node Setup
The Master Node includes several services:

* dashboard: Provide Web UI for operators.
* restserver: Provide RESTful APIs for chain consumers.
* watchdog: Watch for health checking.

*More details can be found at the [architecture doc](docs/arch.md).*

It can be deployed by in 2 steps.

* Clone code
* Run setup script

### System Requirement
* Hardware: 8c16g100g
* Docker engine: 1.10.0~1.13.0 (Docker 17.0+ support is experimental)
* docker-compose: 1.8.0~1.12.0

### Clone Code

You may check `git` and `make` are installed to clone the code.

```sh
$ sudo aptitude install git make -y
$ git clone http://gerrit.hyperledger.org/r/cello && cd cello
```

### Run Setup

For the first time running, please setup the master node with the [setup.sh](https://github.com/hyperledger/cello/blob/master/scripts/setup.sh).

```sh
$ make setup-master
```

Make sure there is no error during the setup. Otherwise, please check the log msgs.

### Usage

#### Start/Stop/Restart
To start the whole services, please run

```sh
$ make start
```

To stop or restart the whole services, run `make stop` or `make restart`.

#### Redploy a service
To redeploy one specific service, e.g., dashboard, please run

```sh
$ make redeploy service=dashboard
```

#### Check Logs
To check the logs for all the services, please run

```sh
$ make logs
```

To check the logs for one specific service, please run
```sh
$ make log service=watchdog
```

Now you can access the `MASTER_NODE_IP:8080` to open the Web-based [operational dashboard](docs/dashboard.md).


### Configuration
The application configuration can be imported from file named `CELLO_CONFIG_FILE`.

By default, it also loads the `config.py` file as the configurations.

### Data Storage
The mongo container will use local `/opt/cello/mongo` directory for persistent storage.

Please keep it safe by backups or using more high-available solutions.
Loading

0 comments on commit affbdad

Please sign in to comment.