并行实验1
修改镜像源:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
修改教程1:https://blog.csdn.net/qq_41822647/article/details/85122467
ubuntu修改教程2:https://blog.csdn.net/u013541411/article/details/81410964
一级目录
二级目录
三级目录
下载docker
curl -sSL https://get.daocloud.io/docker | sh
如没有curl,执行下面的安装,安装好了curl后,再次执行上面的命令
sudo apt install curl
docker安装成功
查看docker安装状态
docker -v
查看版本
启动Docker
sudo service docker start
docker run hello-world
报如下错误:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $XXX docker #检测当前用户是否已经在docker用户组中,其中XXX为用户名,例如我的,liangll
sudo gpasswd -a $USER docker #将当前用户添加至docker用户组
newgrp docker #更新docker用户组
将该用户添加到docker的目录下
执行更新命令:newgrp docker
再次执行:docker run hello-world
MPICH下载和安装
mpich下载
使用wget 命令下载:http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
wget http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
在root中创建文件需要提权,使用root用户,所以使用sudo passwd进行重新设置root的密码
创建root/mpich文件夹
mkdir mpich
解压mpich的压缩包
tar -zxvf mpich-3.2.tar.gz -C /root/mpich/
进入mpich的安装文件夹,配置安装路径
./configure --prefix=/root/mpich
make && make install
GCC安装
apt install g++
which gcc
再次重新配置
./configure --prefix=/root/mpich/mpich_intall --disable-fortran
执行make命令
make
如果make出错需要运行下面的重新构建
make clean
make
安装 install
make install
查看安装文件的目录
配置环境变量
找到mpich的安装目录
vim ~/.bashrc
在文件的开头放入以下文字
export PATH=$PATH:/root/mpich/mpich_install/bin
执行案例程序
mpicc /root/mpich/mpich-3.2/examples/hellow.c -o /root/mpich/mpproject/hello.o
mpirun /root/mpich/mpproject/hello.o
执行结果:
设置ssh
ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_dsa
Your public key has been saved in /root/.ssh/id_dsa.pub
The key fingerprint is:
SHA256:Z5nYgdAotLIG8LN9MRW68sdEtlydRkpn/FFlgzFxVB4 root@pan-virtual-machine
The key's randomart image is:
+---[RSA 3072]----+
|. .. .oo...++=EB|
|.. ...+.o *.o+oo|
|. + ..+ + + +. ..|
| . * B = = . |
| + o o S * |
| . + o o |
| . o |
| . |
| |
+----[SHA256]-----+
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
#安装ssh
sudo apt-get install openssh-server
sudo apt-get install openssh-client
制作mpi镜像
cantos
FROM centos:centos7
WORKDIR /root
ADD mpich-3.2.tar.gz .
RUN yum install -y gcc gcc-c++ automake autoconf libtool make openssl openssh-server
RUN mkdir ./mpich && ./mpich-3.2/configure --prefix=/root/mpich --disable-fortran && make && make install && mkdir /root/program
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' && cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \
sed -i 's/PermitEmptyPasswords yes/PermitEmptyPasswords no /' /etc/ssh/sshd_config && \
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes /' /etc/ssh/sshd_config && \
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \
echo "root:1234" | chpasswd
ENV PATH=$PATH:/root/mpich/bin
EXPOSE 22
CMD [ "sh", "-c", "/etc/init.d/ssh start; bash"]
ubuntu
# 指定新镜像所基于的镜像,必须为第一条指令
FROM ubuntu
MAINTAINER 65782152
#ADD等命令的执行目录
WORKDIR /root
#将压缩包加入,且会自动解压ADD src target
ADD mpich-3.2.tar.gz .
#执行相关的命令
#安装G环境
RUN sed -i 's#http://archive.ubuntu.com/#http://mirrors.tuna.tsinghua.edu.cn/#' /etc/apt/sources.list
RUN apt-get update
#RUN apt-get install -y build-essential
RUN apt-get install g++ --fix-missing
#安装ssh环境
RUN sudo apt-get install openssh-server
RUN sudo apt-get install openssh-client
RUN mkdir ./mpich && ./mpich-3.2/configure --prefix=/root/mpich --disable-fortran && make && make install
#创建程序目录
RUN mkdir /root/program
#ssh命令 以及相关的配置
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' && cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \
sed -i 's/PermitEmptyPasswords yes/PermitEmptyPasswords no /' /etc/ssh/sshd_config && \
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes /' /etc/ssh/sshd_config && \
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \
echo "root:root" | chpasswd
#环境变量的配置
ENV PATH=$PATH:/root/mpich/bin
#端口开启
EXPOSE 22
CMD [ "sh", "-c", "/etc/init.d/ssh start; bash"]
docker build . -t my-mpich:1.0
构建docker网络
创建多个节点
Ping节点3
|