Centos7+Maya2017+Pbspro

1 简介

1 在Centos7基础上,编写Dockerfile,安装各种依赖库,build成mayabase-centos7镜像

2 在mayabase-centos7基础上,编写Dockerfile,安装Maya2017,build成maya-mayabase镜像

3 在maya-mayabase基础上,编写Dockerfile,安装pbspro的依赖库,使用RPM制作Pbspro的安装包,build成pbspro-maya镜像

4 在pbspro-maya镜像上开启三个容器master、salve1、salve2,分别进入容器,进行安装管理节点和计算节点。

2 制作镜像

制作镜像完成如下:

镜像列表

2.1 构建fpk/mayabase-centos7镜像

安装docker后,pull一个centos7的镜像

$docker pull centos

编写Dockerfile,如下:

#The centos imgae's version is 7, python version to 3.2,and build the base images for install maya
FROM centos

MAINTAINER  aboy

RUN yum install -y gstreamer-plugins-base.x86_64

RUN yum update -y && yum install -y \
    nano \
    csh \
    libXp \
    libXmu \
    libXpm \
    libXi \
    libtiff \
    libXinerama \
    elfutils \
    gcc \
    gamin \
    git \
    mesa-utils \
    mesa-libGL-devel \
    tcsh \
    xorg-x11-server-Xorg \
    xorg-x11-server-Xvfb \
    wget && \
    yum groupinstall -y "X Window System" && \
    yum clean all

RUN wget https://bootstrap.pypa.io/3.2/get-pip.py && \
    python get-pip.py && \
    pip install --target=/usr/local/lib/python3.2/site-packages \
        nose \
        mock \
        unittest2

# Enable playblasts with Quicktime
ENV LIBQUICKTIME_PLUGIN_DIR=/usr/autodesk/maya/lib

# Start Xvfb
# Provide an in-memory X-session for parts of Maya that require a GUI
# such as cmds.playblast()
ENV DISPLAY :99

# Run on user login, this has the limitation of being run
# each time a user logs into the Docker image. Suggestions
# are welcome to make this only run once at startup.
RUN echo "# Start Xvfb" >> ~/.bashrc && \
    echo "Xvfb :99 -screen 0 1024x768x16 2>/dev/null &" >> ~/.bashrc && \
    echo "while ! ps aux | \grep -q '[0]:00 Xvfb :99 -screen 0 1024x768x16';" >> ~/.bashrc && \
    echo "  do echo 'Waiting for Xvfb...'; sleep 1; done" >> ~/.bashrc

# Expose Python libraries to Maya
ENV PYTHONPATH=/usr/local/lib/python3.2/site-packages

构建fpk/mayabase-centos7镜像

$docker build -t fpk/mayabase-centos7 .

2.2 构建fpk/maya-mayabase镜像

编写Dockerfile,如下:

#Use fpk/mayabase-centos7 images,continue install the maya
FROM fpk/mayabase-centos7

MAINTAINER aboy

# Download and unpack distribution first, Docker's caching
# mechanism will ensure that this only happens once.
RUN wget http://edutrial.autodesk.com/NET17SWDLD/2017/MAYA/ESD/Autodesk_Maya_2017_EN_JP_ZH_Linux_64bit.tgz -O maya.tgz && \
    mkdir /maya && tar -xvf maya.tgz -C /maya && \
    rm maya.tgz && \
    rpm -Uvh /maya/Maya*.rpm && \
    rm -r /maya

# Make mayapy the default Python
RUN echo alias hpython="\"/usr/autodesk/maya/bin/mayapy\"" >> ~/.bashrc && \
    echo alias hpip="\"mayapy -m pip\"" >> ~/.bashrc

# Setup environment
ENV MAYA_LOCATION=/usr/autodesk/maya/
ENV PATH=$MAYA_LOCATION/bin:$PATH

# Workaround for "Segmentation fault (core dumped)"
# See https://forums.autodesk.com/t5/maya-general/render-crash-on-linux/m-p/5608552/highlight/true
ENV MAYA_DISABLE_CIP=1

# Cleanup
WORKDIR /root

构建fpk/maya-mayabase镜像

$docker build -t fpk/maya-mayabase .

2.3 构建fpk/pbspro-maya镜像

编写Dockerfile,如下:

#install pbspro on the fpk/maya-mayabase
FROM fpk/maya-mayabase
MAINTAINER aboy

#ssh need dependent libraries
RUN yum install -y openssh-clients net-tools vim passwd openssl openssh-server

#pbspro need dependent libraries
RUN yum install -y rpm-build gcc autoconf automake libtool hwloc-devel libX11-devel libXt-devel libedit-devel libical-devel ncurses-devel postgresql-devel python-devel python-devel tcl-devel tk-devel swig expat-devel openssl-devel libXext libXft

#rpm-build the pbspro 
RUN mkdir -p /root/rpmbuild/SOURCES/
ADD pbspro-14.1.0.tar.gz /root/rpmbuild/SOURCES/
RUN cd /root/rpmbuild/SOURCES/ && tar zcvf pbspro-14.1.0.tar.gz pbspro-14.1.0 
RUN cd /root/rpmbuild/SOURCES/pbspro-14.1.0 && rpmbuild -ba pbspro.spec

构建fpk/maya-mayabase镜像

$docker build -t fpk/pbspro-maya .

3 开启容器

容器名称hostnameIP
mastermaster172.18.0.3
salve1salve1172.18.0.4
salve2salve2172.18.0.5

3.1 创建容器

创建三个容器,创建之前创建自定义网络,三个容器都需要有固定的网段和固定的IP

#创建mynetwork网络
$docker network create --subnet=172.18.0.0/16 mynetwork
#查看网络
$docker network ls
#创建三个容器
$docker run -tid --name master -h master --add-host master:172.18.0.3 --add-host salve1:172.18.0.4 --add-host salve2:172.18.0.5 --net=mynetwork --ip=172.18.0.3 fpk/pbspro-maya bash

$docker run -tid --name salve1 -h salve1 --add-host master:172.18.0.3 --add-host salve1:172.18.0.4 --add-host salve2:172.18.0.5 --net=mynetwork --ip=172.18.0.4 fpk/pbspro-maya bash

$docker run -tid --name salve2 -h salve2 --add-host master:172.18.0.3 --add-host salve1:172.18.0.4 --add-host salve2:172.18.0.5 --net=mynetwork --ip=172.18.0.5 fpk/pbspro-maya bash

创建三个容器

3.2 安装Pbspro

参照此前的博客安装Pbspro(Centos7安装-多节点PbsPro),分别在管理节点和计算节点安装,安装运行文件此前在制作镜像时,已经存在每个容器中了,进入/root/rpmbuild/RPMS/x86_64进行安装配置

1 安装配置

2 开启pbs服务

3 添加统一的UID用户

4 测试作业

测试截图

ok!完毕,其实可以把2.1、2.2和2.3的Dockerfile写到一块,只不过构建时间有点长。

4 参考资料

1 Centos7安装-多节点PbsPro

2 使用ssh在Docker容器间建立互信

3 mottosso/mayabase-centos

4 mottosso/docker-maya


​ 2017-11-22-Boy

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐