时间:2023-06-28 21:39:01 | 来源:网站运营
时间:2023-06-28 21:39:01 来源:网站运营
通过虚拟机搭建集群:/etc/selinux/config
文件,将变量修改为 SELINUX=disabled
。 随后调用 systemctl 命令,关闭防火墙 systemctl stop firewalld
ifcfg-enp0s3
文件,包括 ONBOOT=yes #系统启动时是否自动加载 BOOTPROTO=static #启用地址协议 --static:静态协议 --bootp协议 --dhcp协议 IPADDR=10.59.0.4 #网卡IP地址 NETMASK=255.255.255.0 #网卡网络地址 GATEWAY=10.59.0.254 #网卡网关地址
注意虚拟系统的 IP 地址设置为 10.59.0.1 ,这个地址与其他节点地址不能重复,并且网关地址需要与其他节点相同。 $ ifdown enp0s3 Device 'enp0s3' sucessfully disconnected. $ ifup enp0s3 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
# /etc/hosts 10.59.0.1 mu01 10.59.0.2 cu01 10.59.0.3 cu02 10.59.0.4 cu03
更新 hosts 文件后,使用ifdown和ifup命令重启网络服务,随后输入 hostname 检查节点名,查看节点名修改是否正确。/dev/sr0
,路径为/run/media/li12242/CentOS/ 7/ x86_64/
。 由于路径包含空格,因此无法直接使用此路径。 新建目录 /rhel7.3/,并使用mount命令将镜像挂载在此位置。 & mount /dev/sr0 /rhel7.3
在yum源配置目录 /etc/yum.repos.d/ 下新建新的配置文件 rhel7.3.repo,其内容为 [rhel7.3] name=rhel7.3 baseurl=file:///rhel7.3/ gpgcheck=0
输入命令清空本地 yum 源,并列出可用 yum 仓库,看到 rhel7.3 即完成了本地 yum 配置。 $ yum clean all $ yum repolist
对于其他节点,则需要配置局域网yum源,来直接使用mu01上加载yum源。 在mu01节点上安装并启动httpd服务 $ yum insall httpd $ systemctl start httpd
启动httpd服务默认目录是 /var/www/html,因此在此目录下也新建文件夹 YUM,并使用mount命令将镜像也挂载在此目录下 $ mkdir /var/www/html/YUM $ mount /dev/sr0 /var/www/html/YUM
在计算节点cu03中,修改对应的yum源配置文件 rhel7.3.repo 文件为 [rhel7.3] name=rhel7.3 baseurl=http://10.59.0.1/YUM gpgcheck=0
其中 10.59.0.1 为 mu01 管理节点 IP 地址。 $ yum install nfs-utils $ systemctl restart nfs.service
随后编辑配置文件 /etc/exports/,内容包括共享目录以及权限等,配置内容包括 /home *(rw,insecure,async,no_root_squash) /opt *(rw,insecure,async,no_root_squash)
启动后即可在计算节点上挂载对应目录,命令为 $ mount -t nfs mu01:/home /home $ mount -t nfs mu01:/opt /opt
NISDOMAIN=TS10K
。 随后启动主服务其并对NIS映射表进行初始化 $ /usr/lib64/yp/ypinit -m ...... gmake[1]: Leaving directory `/var/yp/master.example.com' master has been set up as a NIS master server. Now you can run ypinit -s master on all slave server.
输入完成后启动 ypserv 和 yppasswdd 服务 $ systemctl start ypserv $ systemctl start yppasswdd
随后在客户端,在 /etc/yp.conf 文件中添加如下命令 $ echo "domain TS10K server mu01" >> /etc/yp.conf
最终使用 systemctl 命令启动 ypbind 服务即可。 $ ssh-keygen -t rsa
使用 ssh-copy-id 将生成的公钥上传至计算节点 $ ssh-copy-id cu01
输入账号密码,下次登录cu01节点时即可实现无密码访问。 $ yum install gcc gcc-c++ gcc-gfortran openmpi-devel
安装好后,还需要安装 enviroment-modules 软件,以便于加载 openmpi 模块 $ yum install openmpi-x86_64 $ source /etc/profile.d/modules.sh # 加载 module 环境 $ module load mpi/openmpi-x86_64 # 加载 openmpi 模块
此时输入 which mpicc
等即可查看 openmpi 编译器路径。 $ cat hello_mpi.c #include <stdio.h> #include <mpi.h> int main(int argc, char *argv[]) { int myrank, nprocs; char name[10]; int name_len; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Get_processor_name(name, &name_len); printf("core[%3d] of [%3d] in {%s} says hello./n", myrank, nprocs, name); MPI_Finalize(); return 0; }
使用 mpicc 编译器对其进行编译,并增加 housts 文件指定 MPI 程序运行时节点和进程数 $ mpicc hello_mpi.c -o main $ cat hosts mu01 slots=1 cu01 slots=1
使用两个进程运行编译好的程序进行测试,得到如下结果说明测试成功 $ mpirun -n 2 -machinefile hosts ./main core [ 0] of [ 2] in {mu01} says hello. core [ 1] of [ 2] in {mu01} says hello.
关键词:虚拟,通过