Linux叢集的安裝與並行計算__Linux

來源:互聯網
上載者:User

1.linux安裝
       需要注意的是安裝時,出於安全需要應把ssh選為可信賴的服務。安裝以後,一個伺服器即是為一個節點,應該保證各節點之間能夠用ssh相互登入。每個節點的sshd都應該能正常提供服務。

2.建立NFS服務

       在伺服器節點public目錄下建立mpi目錄,並將其配置成NFS伺服器,在/etc/exports檔案中加入一行:

                 /public/mpi  node1(rw)  node2(rw)

       在用戶端節點的/etc/fstab檔案中增加一行:

                sever :/pubilc/mpi  nfs  rw , bg , soft  0 0

將/public/mpi這個目錄從伺服器節點輸出,並裝載在各用戶端,從而便於在各節點間分發任務。

3.修改/etc/hosts檔案,將所有節點名稱極其ip地址填入。例如:
         127.0.0.1 localhost.localdomain localhost
         192.168.1.1 node1
         192.168.1.2 node2

           …………………….
每個節點都進行類似的配置。這樣做的目的是使節點之間能夠通過node1 ... noden的名稱相互訪問。你可以通過ping noden 或 ssh noden進行測試。

4.修改(或建立)/etc/hosts.equiv檔案
        將所有你允許訪問本機進行mpi計算的機器名填入,一行一個機器名。這一步是為了使節點對其它的節點放權。
       例如,node1是用於啟動mpi叢集計算的機器,其他的節點是參與計算者,在node1的/etc/hosts.equiv檔案是這樣的:

                node1 #給自己放權,這樣在只有一台機器時也可以類比並行計算環境

                node2

                 .....
                noden
        在node2...noden的/etc/hosts.equiv檔案:
               node1 #對node1放權
               node2
               ......
              noden

5.修改~/.bash_profile檔案
         首先決定一個用於啟動叢集計算的使用者名稱,不提倡使用root進行叢集計算。這裡在每個節點上建立新使用者chief,他們的主目錄都是/home/chief,必須採用同樣的密碼,將來的計算程式必須放在相同的路徑上。譬如你的程式為:fpi.f和a.out,則必須把a.out放在同樣的路境內,比如~/mpirun/a.out,每個節點都是如此。 修改~/.bash_profile檔案,主要是加入下列幾行指令碼:

          export PATH=$PATH:/usr/local/mpich/bin

          export MPI_USEP4SSPORT=yes

          export MPI_P4SSPORT=22

          export P4_RSHCOMMAND=rsh 或ssh

       這裡我們預定了將來mpich的運行環境安裝在目錄/usr/local/mpich下面。其餘的三個變數是用來通知mpi運行環境採用rsh(或ssh)來作為遠程shell。linux的運行環境到此就配
置完畢了。

6.配置ssh

        採用ssh作為遠程shell則按如下配置:以你設定的用於啟動mpi計算的使用者登入,運行ssh-keygen,這將產生一個私人/公開金鑰組,分別存放在~/.ssh/identity和~/.ssh/i
dentity.pub檔案內。然後進行訪問授權,運行:

         cp ~/.ssh/identity.pub ~/.ssh/authorized_keys

         chmod go-rwx ~/.ssh/authorized_keys

         ssh-agent $SHELL

         ssh-add
在每個節點重複一遍。試著在某一節點上登入其它節點,ssh noden,則在.ssh/下產生一個known_hosts2檔案,裡面放著訪問該主機的密鑰,把所有密鑰收集起來,在各個節
點上作同樣的拷貝。這樣做的目的是使各節點相互之間訪問無需輸入密碼。

7.開啟各項必需的服務

        如果是以根使用者root 登陸系統的則可以用ntsysv命令啟動ntsysv公用程式。ntsysv 公用程式允許使用簡單的菜單介面啟動或關閉各種運行等級的服務。在其中我們選擇開啟
rsh ,rlogin,telnet等。也可以關閉一些服務以加快啟動速度如sendmail。

        如果是使用su命令轉為root使用者的則很可能運行ntsysv並不出現ntsysvs公用程式。此時可以直接去修改/etc/xinetd.d下的rlogin, ssh ,telenet的設定。

        用vi編輯器開啟xinetd.d:

           vi /etc/xinetd.d

       則可看到如下所示的設定檔:
關於rsh的設定如下
# default: off
# description: The rshd server is the server for the rcmd(3) routine and, \
#       consequently, for the rsh(1) program.  The server provides \
#       remote execution facilities with authentication based on \
#       privileged port numbers from trusted hosts.
service shell
{
       disable = yes
       socket_type             = stream
       wait                    = no
       user                    = root
       log_on_success          += USERID
       log_on_failure          += USERID
       server                  = /usr/sbin/in.rshd
}
關於rlogin的設定如下
# default: off
# description: rlogind is the server for the rlogin(1) program.  The server
\
#       provides a remote login facility with authentication based on \
#       privileged port numbers from trusted hosts.
service login
{
       disable = yes
       socket_type             = stream
       wait                    = no
       user                    = root
       log_on_success          += USERID
       log_on_failure          += USERID
       server                  = /usr/sbin/in.rlogind
}
關於telnet的設定如下
# default: off
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
       disable = yes
       flags = REUSE
       socket_type = stream
       wait = no
       user = root
       server = /usr/sbin/in.telnetd
       log_on_failure += USERID
}
所有這些服務在安裝完系統之後都是預設為禁用的,要進行修改來開啟這些服務。如要
通過修改啟動telenet則就需要改disable = yes為disable = no。對於其他的服務的啟
動的修改與之相同。若啟動這些服務則只需要簡單執行:
#/etc/rc.d/init.d/xinetd restart
或重啟伺服器。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.