samba,nfs安裝使用

urgel_babay發表於2016-03-01
<p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#FFCC00;">3、安裝Samba&nbsp;</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">用以下命令安裝:</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">rpm -ivh samba-3.0.33-3.29.el5_6.2.i386.rpm -f --nodeps</span> </p> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <div style="margin:0px;padding:0px;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">rpm -ivh samba-client-3.0.33-3.29.el5_6.2.i386.rpm &nbsp;-f --nodeps</span> </div> <div style="margin:0px;padding:0px;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">rpm -ivh samba-common-3.0.33-3.29.el5_6.2.i386.rpm -f --nodeps</span> </div> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">安裝完成後,使用命令</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">rpm -qa | grep samba</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';">進行查詢,發現搭建samba伺服器所依賴的所有伺服器都已經安裝好了即可。</span> </p> <p style="margin:10px auto;"> &nbsp; </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#FFCC00;">4、配置smb.conf檔案</span> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">Samba的配置檔案一般就放在</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#33CCCC;">/etc/samba</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';">目錄中,主配置檔名為</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#33CCCC;">smb.conf</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';">,檔案中記錄著大量的規則和共享資訊,所以是samba服務非常重要的核心配置檔案,完成samba伺服器搭建的大部分主要配置都在該檔案中進行。</span> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">Samba伺服器的工作原理是:客戶端向Samba伺服器發起請求,請求訪問共享目錄,Samba伺服器接收請求,查詢smb.conf檔案,檢視共享目錄是否存在,以及來訪者的訪問許可權,如果來訪者具有相應的許可權,則允許客戶端訪問,最後將訪問過程中系統的資訊以及採集的使用者訪問行為資訊存放在日誌檔案中。</span>&nbsp; </p> </div> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <strong style="margin:0px;padding:0px;">第一步:修改配置檔案</strong> </div> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">&nbsp; &nbsp; &nbsp;首先備份一下samba的配置檔案</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">cd /etc/samba</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">mv</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">&nbsp;smb.conf smb.conf</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">bak</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">然後重新建立一個smb.conf檔案</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#99CC00;">touch smb.conf</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';">然後我們把這段寫入smb.conf中</span>&nbsp; </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-size:8pt;"> </span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">[global]</span> </p> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-size:8pt;"> &nbsp; &nbsp; &nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">workgroup = LinuxSir</span> </div> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;"> &nbsp; &nbsp;&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">netbios name = LinuxSir05</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;"> &nbsp; &nbsp;&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">server string = Linux Samba Server TestServer</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;"> &nbsp; &nbsp;&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">security = share</span><br style="margin:0px;padding:0px;" /> <br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;"> &nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">[linuxsir]</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">path = /opt/linuxsir</span><br style="margin:0px;padding:0px;" /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">writeable = yes</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-size:8pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">browseable = yes</span>&nbsp; </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';font-size:8pt;"> &nbsp; &nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">guest ok</span><span style="margin:0px;padding:0px;font-size:8pt;color:#33CCCC;">&nbsp;= yes</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <br /> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> &nbsp; </p> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> </span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#FFCC00;">註解:</span> <p style="margin:10px auto;"> <br /> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> </span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#33CCCC;">[global]</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';">這段是全域性配置,是必段寫的。其中有如下的幾行;</span> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> workgroup 就是Windows中顯示的工作組;在這裡我設定的是LINUXSIR (用大寫);</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> netbios name 就是在Windows中顯示出來的計算機名;</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> server string 就是Samba伺服器說明,可以自己來定義;這個不是什麼重要的;</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> security 這是驗證和登入方式,這裡我們用了share ;驗證方式有好多種,這是其中一種;另外一種常用的是user的驗證方式;如果用share呢,就是不用設定使用者和密碼了;</span> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> </span><span style="margin:0px;padding:0px;font-family:'Lucida Console';color:#33CCCC;">[linuxsir]</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';">&nbsp;這個在Windows中顯示出來是共享的目錄;</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> path = 可以設定要共享的目錄放在哪裡;</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> writeable 是否可寫,這裡我設定為可寫;</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> browseable 是否可以瀏覽,可以;可以瀏覽意味著,我們在工作組下能看到共享資料夾。如果您不想顯示出來,那就設定為 browseable=no</span> </p> <p style="margin:10px auto;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> guest ok 匿名使用者以guest身份是登入;</span> </p> </div> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> <strong style="margin:0px;padding:0px;">第二步:建立相應目錄並授權;</strong></span>&nbsp; </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-size:8pt;"> [root@localhost ~]#&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#99CC00;">mkdir -p /opt/linuxsir</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <br /> </p> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;font-size:8pt;"> [root@localhost ~]#&nbsp;</span><span style="margin:0px;padding:0px;font-size:8pt;color:#99CC00;">id nobody</span><br style="margin:0px;padding:0px;" /> <span style="margin:0px;padding:0px;font-family:'Lucida Console';"> </span><span style="margin:0px;padding:0px;font-size:8pt;">uid=99(nobody) gid=99(nobody) groups=99(nobody)</span> </div> <span style="margin:0px;padding:0px;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;font-family:'Lucida Console';"> </span><span style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;white-space:normal;background-color:#FFFFFF;font-size:8pt;">[root@localhost ~]#&nbsp;</span><span style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;white-space:normal;background-color:#FFFFFF;font-size:8pt;color:#99CC00;">chown -R nobody:nobody /opt/linuxsir</span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;">&nbsp;</span> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <br /> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> &nbsp; &nbsp;&nbsp;<span style="margin:0px;padding:0px;color:#FFCC00;">註釋:</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> 關於授權nobody,我們先用id命令檢視了nobody使用者的資訊,發現他的使用者組也是nobody,我們要以這個為準。有些系統nobody使用者組並非是nobody ;&nbsp; </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> &nbsp; </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <strong style="margin:0px;padding:0px;"> </strong><strong style="margin:0px;padding:0px;">第三步:啟動smbd和nmbd伺服器;</strong> </p> <div style="margin:0px;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> <span style="margin:0px;padding:0px;border-collapse:collapse;font-family:monospace;font-size:12px;line-height:15px;border-spacing:2px;"> &nbsp; &nbsp; &nbsp;</span><span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;">[root@localhost ~]#&nbsp;</span><span style="margin:0px;padding:0px;border-collapse:collapse;line-height:15px;border-spacing:2px;font-family:'Lucida Console';font-size:8pt;color:#99CC00;">smbd</span><span style="margin:0px;padding:0px;border-collapse:collapse;font-family:monospace;font-size:12px;line-height:15px;border-spacing:2px;"><br style="margin:0px;padding:0px;line-height:0.6em;" /> </span> </div> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> &nbsp; &nbsp; &nbsp;<span style="margin:0px;padding:0px;font-family:'Lucida Console';font-size:8pt;">[root@localhost ~]#&nbsp;</span><span style="margin:0px;padding:0px;font-family:'Lucida Console';font-size:8pt;color:#99CC00;">nmbd</span> </p> <p style="margin:10px auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;line-height:20px;white-space:normal;background-color:#FFFFFF;"> &nbsp;<br /> 輸入//地址,然後在windows中就能傳檔案給linux了<br /> <br /> <br /> nfs<br /> <ol> <li> 檢查包,linux6和5不一樣要注意 </li> <li> 啟動服務,注意順序service rpcbind restart &nbsp;service nfs start </li> <li> 編輯檔案,做好備份 /掛載目錄&nbsp;掛載方ip /opt 1.1.1.1(rw,sync,no_root_squash) </li> <li> 重啟服務&nbsp;service nfs restart &nbsp;service rpcbind restart </li> <li> 待傳方,mount IP/掛載目錄/掛載地址 本地地址&nbsp; &nbsp;&nbsp;mount 1.1.1.1:/opt /u03 </li> </ol> <div> [root@hrproddb Packages]# &nbsp;rpm -qa |grep nfs<br /> nfs-utils-lib-1.1.5-6.el6.x86_64<br /> nfs4-acl-tools-0.3.3-6.el6.x86_64<br /> nfs-utils-1.2.3-39.el6.x86_64<br /> [root@hrproddb Packages]# rpm -qa |grep rpcbind<br /> rpcbind-0.2.0-11.el6.x86_64<br /> <br /> </div> </p>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2018572/,如需轉載,請註明出處,否則將追究法律責任。

相關文章