1. 程式人生 > 其它 >【FATE】FATE 單機部署全流程(使用Docker映象安裝FATE )

【FATE】FATE 單機部署全流程(使用Docker映象安裝FATE )

Docker 容器

注意:Linux 伺服器上安裝 Docker 需要 root 許可權,安裝完成之後可以設定 Docker 組使用者訪問 Docker 的許可權。

docker 18.09 -> 19.03sy

官方文件:https://docs.docker.com/engine/install/ubuntu/

1,檢視本地是否有安裝過舊版 Docker
$ docker --version

2,解除安裝舊版本的 Docker

$ sudo apt-get remove docker docker-engine docker.io containerd runc

3,Install using the repository
有兩種安裝方式,這裡使用官方推薦的方式,使用 Docker 倉庫進行安裝

4,Set up the repository
Update the apt package index

$ sudo apt-get update

install packages to allow apt to use a repository over HTTPS

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Add Docker’s official GPG key

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

驗證是否擁有帶指紋的金鑰(參考這裡,好像已經失效了,先碼著)

$ sudo apt-key fingerprint

set up the stable repository

 echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

5,Install Docker Engine
Update the apt package index
$ sudo apt-get update

install a specific version of Docker Engine and containerd

a,List the version available in your repo:
$ apt-cache madison docker-ce

 docker-ce | 5:20.10.7~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.6~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.5~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.4~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.3~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.2~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.1~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.0~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.15~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.14~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.13~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

b,這裡沒有需要的18.09版本,先新增阿里雲的docker GPG金鑰

$ curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
> OK

c,新增阿里映象源

$ sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

d,再次檢視版本列表
$ apt-cache madison docker-ce

e,這個時候還是沒有的話,直接安裝,把<VERSION_STRING>中的版本號手動更改一下試試(再不行就安裝現有版本吧..)

$ sudo apt-get install docker-ce=5:19.03.9~3-0~ubuntu-focal docker-ce-cli=5:19.03.9~3-0~ubuntu-focal containerd.io

f,Verify that Docker Engine is installed correctly by running the hello-world image

$ sudo docker run hello-world
> Hello from Docker!
> This message shows that your installation appears to be working correctly.

6,allow non-privileged users to run Docker commands

Create the docker group
$ sudo groupadd docker

Add your user to the docker group (\(USER 替換為使用者名稱) `\) sudo usermod -aG docker $USER`

activate the changes to groups
$ newgrp docker

Verify that you can run docker commands without sudo
$ docker run hello-world

(可選)7,阿里雲映象加速

a,阿里雲映象地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

b,登入賬號,獲取加速器地址

c,配置加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["加速器地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

docker-compose 1.24.0

官方文件:https://docs.docker.com/compose/install/

download the current stable release of Docker Compose (替換相應的版本號)

$ 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

Apply executable permissions to the binary

$ sudo chmod +x /usr/local/bin/docker-compose

Test the installation
$ docker-compose --version

配置開發環境和依賴庫(略)

JDK 1.8+
Python 3.6
Python virtualenv
MySQL 5.6+
Redis 5.0.2
...

安裝 FATE

官方文件:https://github.com/FederatedAI/FATE/blob/master/standalone-deploy/doc/Fate-standalone_deployment_guide_zh.md
注意:安裝FATE之前可以切換環境

1,查詢埠號8080,9360,9380是否被佔用
sudo netstat -nultp | grep 9360

2,獲取和解壓安裝包(fate.env 查詢 version)

$ wget https://webank-ai-1251170195.cos.ap-guangzhou.myqcloud.com/docker_standalone_fate_1.6.0.tar.gz
$ tar -xzvf docker_standalone_fate_1.6.0.tar.gz

3,切換資料夾並執行部署

$ cd docker_standalone_fate_1.6.0
$ bash install_standalone_docker.sh

4,驗證和單元測試

$ CONTAINER_ID=`docker ps -aqf "name=fate"`
$ docker exec -t -i ${CONTAINER_ID} bash
$ bash ./python/federatedml/test/run_test.sh
> ...
> there are 0 failed test

5,Toy測試

$ python ./examples/toy_example/run_toy_example.py 10000 10000 0
> ...
> success to calculate secure_sum, it is 1999.9999999999998

6,安裝 FATE-Client 和 FATE-Test

$ pip install fate-client
$ pip install fate-test

7,使用 FATE Board
a,規則與jupyter notebook相同那個,localhost:8080,使用PuTTy的隧道,並在本地瀏覽器開啟即可
b,在fate#下進入examples/ federatedml-1.x-examples/,執行python quick_run.py,檢視 FATE Board進度