在ubuntu上尝试配置了一下open-mpi,在虚拟机上完成。从安装ubuntu到配置完成mpi的过程。整理一下。

1. 安装ubuntu
先下载iso文件,ubuntu-12.04.1-server-i386.iso,这个ubuntu不会启动ui界面,适合在虚拟机上安装,安装比较简单,按照提示即可。

2. 配置网络
我使用的是NAT方式固定IP。
1) 在vmware界面上依次打开Edit -> Virtual Network Editor,选中VMnet8,将选项Use local DHCP service to distribute IP address to VMs 取消选中。,打开NAT Settings记住Subnet IP, Subnet Mask, Gateway IP。
2) 打开虚拟机,后面的操作都需要root权限,先用sudo su命令切换到root下,然后使用vim打开/etc/network/interfaces,将网卡配置成如下方式,其中195要根据自己的子网修改,gateway, netmask根据之前记下的值进行设置,dns服务器用了google的服务器。


auto eth0 
  
 iface eth0 inet static 
  
 address 192.168.195.100 
  
 netmask 255.255.255.0 
  
 broadcast 192.168.195.255 
  
 gateway 192.168.195.2 
  
 dns-nameservers 8.8.8.8

保存以后执行下面的命令使网络配置生效


/etc/init.d/networking restart


3) 如果重启自己的机器以后无法连接到虚拟机上,打开本机的网络和共享中心,找到VMnet8对应的本地连接,和ubuntu一样,修改成静态的ip。

3. 配置telnet服务
使用虚拟机的时候主要还是要在自己的机器上操作比较方便,所以telnet服务是一定要打开的,后面也会配置ssh,可以不配置。
执行


apt-get install xinetd
apt-get install telnetd


修改/etc/inetd.conf(如果没有的话创建一个),加入以下内容


telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd


修改/etc/xinetd.conf文件


defaults 

instances = 60 
log_type = SYSLOG authpriv 
log_on_success = HOST PID 
log_on_failure = HOST 
cps = 25 30 

includedir /etc/xinetd.d


修改/etc/xinetd.d/telnet文件


service telnet  
  
 {  
  
 disable = no  
  
 flags = REUSE  
  
 socket_type = stream  
  
 wait = no  
  
 user = root  
  
 server = /usr/sbin/in.telnetd  
  
 log_on_failure  = USERID  
  
 }


配置完成以后重启服务,切换到自己的机器,使用telnet登录进行验证


service xinetd restart


4. 配置nfs
安装server,并创建目录


apt-get install nfs-kernel-server
mkdir /export
mkdir /export/home


用mount命令将home目录绑定到/export/home


mount --bind /home /export/home


这样绑定好立即生效,但是重启以后还需要手动绑定,所以需要修改/etc/fstab文件,在最后加入一行


/home /export/home none bind 0 0


修改 /etc/default/nfs-kernel-server,将 NEED_SVCGSSD 设为 no:
修改 /etc/default/nfs-common,将 NEED_IDMAPD 设为 yes,NEED_GSSD 设为 no:
修改/etc/exports文件,这个文件用于指定多少目录共享出去


/export *(rw,fsid=0,no_subtree_check,sync)
/export/home *(rw,nohide,insecure,no_subtree_check,sync)


第一行是设定 /export 为根录目(fsid=0 即是设定为根目录的意思)

重启服务


/etc/init.d/nfs-kernel-server restart
service idmapd restart


在第二台服务器上配置nfs client
apt-get install nfs-common
修改 /etc/default/nfs-common,将 NEED_IDMAPD 设为 yes:
重启服务


sudo service idmapd restart


可以先将第一台服务器上的文件mount上去


mount s001:/home /home


成功以后在 /etc/fstab,加入一行,以后重启的时候可以自动mount上去


master:/home /home nfs4 _netdev,auto 0 0


5. 配置ssh
安装ssh


apt-get install openssh-server


生成密钥,因为之前已经配置好nfs了,所以,文件就不需要传到其他机器上了


ssh-keygen 
  
 Generating public/private rsa key pair. 
  
 Enter file in which to save the key (/home/xxx/.ssh/id_rsa): 
  
 Created directory '/home/xxx/.ssh'. 
  
 Enter passphrase (empty for no passphrase): 
  
 Enter same passphrase again: 
  
 Your identification has been saved in /home/xxx/.ssh/id_rsa. 
  
 Your public key has been saved in /home/xxx/.ssh/id_rsa.pub. 
  
 The key fingerprint is: 
  
 5c:83:ed:dc:dd:a6:3f:33:cd:9c:64:09:e6:f5:4b:27 xxx@ubuntu 
  
 The key's randomart image is: 
  
 +--[ RSA 2048]----+ 
  
 |                 | 
  
 |         o       | 
  
 |        . +      | 
  
 |       . + o + o | 
  
 |        S o + + =| 
  
 |             .EBo| 
  
 |              =+=| 
  
 |               B+| 
  
 |                =| 
  
 +-----------------+ 
  
 cd ~/.ssh 
  
 cat id_rsa.pub >> authorized_keys


6. 安装openmpi
apt-get install libopenmpi-dev openmpi-bin openmpi-doc