Ubuntu16.04使用docker安装MADlib+Post

2018-12-28  本文已影响0人  田丰w

曾经尝试在Ubuntu16.04上直接安装PostgreSQL,结果导致操作系统经常崩溃,尤其是输入法(sogou).故考虑使用docker安装.

1. 安装docker

参考: docker的Ubuntu安装官方文档
按步骤进行即可.

经测试,docker主站在大陆像是被墙了,若要使用官方源需备梯子.

sudo sudo -s    # 使用root账号

# 配置代理 (privoxy代理转发请自行配置)
# set privoxy as proxy
PROXY_HOST=127.0.0.1
all_proxy=http://$PROXY_HOST:8118
ftp_proxy=http://$PROXY_HOST:8118
https_proxy=http://$PROXY_HOST:8118
http_proxy=http://$PROXY_HOST:8118
no_proxy=localhost,192.168.0.0/16,127.0.0.1
export http_proxy https_proxy ftp_proxy no_proxy

然后按照docker官网进行即可.

2. 安装MADlib的docker环境

参考: MADlib官方文档

摘录关键步骤如下

  1. 拉取docker镜像(这个镜像提供了需要的postgres等环境,并没有安装madlib) Pull down the madlib/postgres_9.6:latest`image from docker hub:
docker pull madlib/postgres_9.6:latest
  1. 下载MADlib源码 Download the madlib source repository from github. 假定下载的源码位置为 /home/my/git-repo/github/madlib
cd /home/my/git-repo/github && git clone git@github.com:apache/madlib.git
  1. 用镜像启动容器,并建立本机目录与容器中系统的路径映射.共享的目录在容器和本机之间是读写共享的. Launch a container corresponding to the MADlib image, mounting the source code folder to the container:
docker run -d -it --name madlib -v /home/my/git-repo/github/madlib:/incubator-madlib/ madlib/postgres_9.6
  1. 启动容器后,连接容器编译madlib组件.编译用时约30分钟. When the container is up, connect to it and build MADlib:
docker exec -it madlib bash
mkdir /incubator-madlib/build-docker
cd /incubator-madlib/build-docker
cmake ..
make
make doc
make install
  1. 在容器中安装MADlib. Install MADlib:
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres install
  1. 运行MADlib测试. Several other madpack commands can now be run:
# Run install check, on all modules:
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres install-check

# Run install check, on a specific module, say svm:
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres install-check -t svm

# Run dev check, on all modules (more comprehensive than install check):
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres dev-check

# Run dev check, on a specific module, say svm:
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres dev-check -t svm

# 如果需要,重新安装 Reinstall MADlib:
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres reinstall
  1. 如果需要,关掉并删除容器,删完再起新容器需要重新安装. Kill and remove containers (after exiting the container):
docker kill madlib
docker rm madlib
  1. 用配置好的容器制作新镜像.

先查看容器ID, 在用容器ID创建新镜像

docker ps -a
docker commit <container id> my/madlib_pg9.6_dev

用新镜像创建新容器

docker run -d -it -p 5432:5432 --name madlib_dev -v /home/my/git-repo/github/madlib:/incubator-madlib/ madlib/postgres_9.6 

连接容器进行交互(发现新容器还是没有安装,但是不用编译了,安装也很快.装完测试一下)

docker exec -it madlib_dev bash
cd  /incubator-madlib/build-docker
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres install
src/bin/madpack -p postgres -c postgres/postgres@localhost:5432/postgres install-check

在docker之外,可以连接docker容器里的postgresql了(假定没有修改登录用户和密码,默认没有密码)

psql -U postgres -h 127.0.0.1 -p 5432
上一篇下一篇

猜你喜欢

热点阅读