crossz

Archive for the ‘server’ Category

Howto Setup SMB Server using NTFS partitions on Ubuntu

In howto, linux, server on November 15, 2007 at 12:24 pm

In GNOME, there is no configure tools like “kdenetwork-filesharing” in KDE, which will automatically add an option ‘msdfs proxy = no’, this made your folders can not be accessed properly within your workgroup. Maybe this is a bug or a carelessness, but just like KDE, too many bugs, it’s ok, I am used to it. Each time I install Linux distro with KDE, I must install some Gnome programs to make the programs installation job done without keep facing KDE’s crash.
Actually in Gnome such a tool is not necessary, Gnome is simple and seamlessly works together with (almost) all the service. SYSTEM-ADMINISTRATION-SHARED FOLDERS is the right place to configure you samba server simply. Although too few stuff there, but these are the essential part. If you prefer expert mode, why not use vi to modify /etc/samba/smb.conf, gui tools is just for beginners and lazy peoples like me.

Why I select Ubuntu. At beginning, I tried Opensuse, the default setting doesn’t show Chinese characters properly, and the essential problem is that the default setting for mount NTFS partitions is not writeable. So I gave it up. Forgiving me don’t want to spend time on to learn how to change fonts and mount options. I prefer more human being friendly default setting, like Ubuntu.

  1. To share files (here what I want to shared is the folders from NTFS partitions)
    For security reason, I prefer add some password for my server, the samba default setting doesn’t allow guest access as well.
    In this case, you should use ’sudo smbpasswd -a user’ to add user and password. Here the user added must exist in the server system users database, otherwise, error message of “Failed to modify password entry for user” will come out.

    • Folders from NTFS partitions are shared

      1. the partition is automatically mounted from /etc/fstabs
      Although when you shared folders from nautilus, there are some error messages telling you access denied stuff, but it doesn’t matter, the Windows will access it properly. But Linux client can not do this.
      Because the access permission is just for the root, while not you. Linux box do the permission check more than the Windows boxes.
      2. the partition is mounted by you after boot from MY COMPUTER
      In this case, there will not any error messages when you share the folders from Nautilus. And Windows, Linux clients can access it very well. Because this time the access permission is for the current user,you. But this is not suitable for files-sharing server.

      The solution is 1). For Windows clients it works well. For Linux clients this job can be done by ‘mount -t smbfs -o username=yourusername,password=youruserpassword //server/dir /mnt/folder’. Here smbfs is need to be installed.

    • Whole NTFS partition is shared
      Just share it. It works well for Windows and Linux clients. But the flexibility is limited, you can not specify folders to share.

  2. Printer Server

    In Gnome, the samba configure tool is still not necessary. Normally the printers in the SYSTEM-ADMINISTRATION-PRINTING will be added to smb server, except bugs exist.
    my HP LaserJet 2200 with usb cable can be founded by Ubuntu automatically and works locally. But from the client machines, the printer is invisible. While the HP Deskjet 1220C can work well both local and client machines.
    The reason is the Gnome auto founded driver is not so correct, although it’s ok for local. Here I use ‘kcontrol’ to add the printer, in kcontrol this is one driver select option “usb port”, with this option everything works well.

    Maybe this is a bug for Gnome system-config-printer, where is no option for the usb port, just list some printers the ubuntu founded, and some specific port. Just no usb port, but just the auto founded usb printer is not correct.

Fedora 8 vs OpenSuSE 10.3 vs Ubuntu 7.10

In linux, server on November 14, 2007 at 12:55 am

Fedora 8, OpenSuSE 10.3, Ubuntu 7.10 之对比

对于linux的了解和关注一直都是围绕着这三个distro的。这次做了一个print server,也借机做了一番对比。

打印机:HP LaserJet 2200黑白打印机(USB),HP DeskJet 1220C彩色打印机(parallel port)。
电脑:我用了实验室里很烂的一台电脑,本打算扔掉,我就废物利用一下,跑windows慢,那就跑linux的text mode总可以的。这台古董有两块显卡,一个nvida,一个ati的,这两个都不是linux下比较容易驱动上的。256M内存,PII的cpu,16M显存…

1.fedora 8(KDE)。我先用的这个。
安装过程:live CD就不行,说是找不到显卡,于是用fedora设置显卡的命令system-config-display,它自己折腾一会,跳出一个graphyical的窗口,让我选显卡驱动,选了vesa,便进入了live CD的KDE环境,于是正常安装。copy files之类的活过后,本应该重启然后进行一些简单的设置,但是因为显卡的原因,又是重新system-config-display后进入KDE,没有提示进行设置,于是从user到网络,还有hostname之类都是自己一个个设置。以后貌似一切正常。
问题所在:还没来到装打印机的步骤,发现这个f8居然要user登录后才能连接网络和smb,ssh的service启动。这可真是为了desktop准备的,这样的话根本没办法run server啊。调试init.d里的service和rcN.d里的启动选项好久,也无法使其正常工作。害我浪费很多时间,我女朋友陪我在实验室到半夜11点多,为此差点吵架。nnd,以后再也不当red hat的小白鼠了。

2.opensuse 10.3
安装过程:opensuse 10.3刚刚发布时没有放出liveCD,我第一次安装它的时候用的就是Gnome的安装CD,显卡可以自己驱上,但是没有自带repositories,要去其wiki自己找,一个个加上,否则装个gcc都不行。后来又装了一次Opensuse 10.3的KDE liveCD版的,因为之前那个Gnome被我做过其他测试,更改过一些系统设置,liveCD时可以进入桌面环境,但是基本的安装过程过后,该重启进行一些设置的时候,无法找到显卡设置,只能在text mode下;Opensuse比Fedora好在其强大的yast系统可以在text mode下工作,于是系统设置还是会自动显示出来,设置过后samba server没有问题,可以正常工作,但是作为打印机server仍燃有问题。
问题所在:在这个Gnome的的samba打印机server上的USB打印机2200可以正常工作,但是parallel的1220C只能打测试页,而且这两个打印机在其他linux上搜索不到。
在Opensuse 10.3的KDE liveCD版上,结果问题依旧,这次在windows端连parallel的1220C打印机都找不到了。

3.Ubuntu 7.10(Gnome)
安装过程:Ubuntu不愧为最人性话和对硬件兼容性最好的distro,对于user来说不存在找不到显卡设置的问题,安装到使用没有任何问题。samba server也没有问题(文件共享功能只是针对linux的分区,对于windows分区,请参见Howto Setup SMB Server using NTFS partitions on Ubuntu(http://crossonline.blogspot.com/2007/11/howto-setup-smb-server-on-ubuntu.html)。但是打印机server的设置上还是有些问题。
问题所在:传统意义上说,Ubuntu的SYSTEM-ADMINISTRATION-PRINTING只是为cups的打印机使用的,但是不知从哪个版本开始,Gnome已经把它和samba server整合到一起了,这么说来,就应该这里出现的打印机就该被samba server找到并且默认被设置为共享。但是这次parallel的1220C没有问题,无论是在windows客户端还是linux端,但是USB打印机2200却在无论在什么系统上都不能被搜索到,只能在server上使用。后来经过一番尝试,发现原来是SYSTEM-ADMINISTRATION-PRINTING搜索到的这个usb打印机驱动不正确,如果利用Kcontrol(KDE下的Control Centre)printing就会多出一个选项让你选连接在usb端口上的打印机,这样找到的打印机就没问题了。

总结:1)无论是哪个发行版的linux还是多少存在着一定的问题,其实都应该可以解决,但是就要花一些时间去解决,本人习惯了Ubuntu,所以虽然Ubunt也存在问题,但是很快就能找出问题所在,对于Fedora和Opensuse,没有做太多研究。而且综合以上default setting的对比,可以看出Ubuntu还是更人性话一些。无怪Dell会选择他们,对于一般的用户,麻烦会少些。
2)对于各个发行版,Gnome和KDE的选择就要看这个厂家喜欢哪个版本了。要想用Fedora就要用Gnome版的,毕竟Gnome开发初期,Redhat大力支持,并且派出专门的程序员参与这个项目,Suse呢,自始至终(当然还没终呢)则一直是KDE的大力支持者,毕竟都是欧洲领国的产品。Ubuntu则倾向于Gnome,否则也不会把KDE的版本另起一个名字叫Kubuntu了。开发力度决定了其产品品质。
3)针对SuSE和Ubuntu,如果你会德语,那自然SuSE会好一些,毕竟其发源地是德国,至今大多数开发者和资深使用者都是来自德国,很多相关的wili和论坛都是德语的,这对非德国用户是一个很大弊端。而且SuSE把其产品做的太过于自我了,很多功能都是自己开发,虽然系统的核心是linux,可是使用上像是另外一个操作系统,偏离Gnome和KDE的默认环境很多,还有那庞大的yast,用惯了SuSE恐怕很难再转到其他linux的发行版上了,如果是想学linux最好不用这个,但是对于企业,习惯傻瓜式的操作,SuSE应该是最好的发行版本了。

以上所有内容都是本人的一点意见,由于本人能力有限,没有做更多的研究,只是用了默认设置,还是在很烂的机器上,很烂的打印机,不能完全代表各个发行版本的真正表现。

#####################
打印机的驱动如果选postscript,打印文字没问题,但是打印图片或者图片为主的pdf,其缓存不够.这个时候试试其他驱动例如footmatic.

SMB:Configuring your computer as a server

In howto, linux, server on November 11, 2007 at 4:09 pm

A fairly comprehensive graphical Samba configuration tool is available for KDE, by installing the “kdenetwork-filesharing” package. Once install, you can find it by launching the KDE Control Center. (Alt-F2 and then type kcontrol). Browse to Internet & Network > Samba. It is fairly easy to use.

A less friendly but also graphical tool is Swat, a web-based interface.

The following tips show how to do some basic things without installing additional software, using the command line. It is not difficult, just be careful with typos.

First open a terminal: Applications > System Tools > Terminal and open the file smb.conf

sudo nano -w /etc/samba/smb.conf

How to Save: To save in nano use “ctrl/o” than “ctrl/x”.

Tip: Replacing nano with gedit gives you a nice graphical editor.

The file *smb.conf* is divided in several sections:

Global SettingsDebugging/AccountingAuthenticationPrintingFile sharingMiscShare Definitions

Let’s start with Global Settings. Here you will see several lines, which you can also see in the graphical networktool like workgroup and wins server. If you changed everything to your liking already then you can skip this section, if not change to what you need. If you do not know what items mean, leave them be and read the [WWW] relevant part in the real Samba-howto instead of randomly changing them. It will save you trouble-shooting later.

The important part for us is File sharing. We need to change:

[homes]comment = Home Directoriesbrowseable = no

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = no

This describes your /home folder. Usually you want to share this folder in a home-environment, because these are the files you want to share. To do so, make the following changes:

[homes]comment = Home Directoriesbrowseable = yes

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = yes

This finishes sharing your /home folder. The last thing we need to do is fixing a user.

Add users who can access your shares with the ’smbpasswd’ command.

sudo  smbpasswd -a username

New SMB password:Retype new SMB password:Added user username.

NOTE: the username used here should be a real user setup on your PC/Server. Reload Samba for every change to users/passwords or ’smb.conf’

sudo /etc/init.d/samba reload

That’s the basis of Samba file-sharing. Please leave your comments about what else is needed here.

Back to top

Complicating things a little

We started with the base of Samba file-sharing. The above-mentioned items should be enough to get you started. Next we will add details that you might or might not need.

Back to top

If you have more the one networkcard

If you have more the one networkcard (or interface) then you have to define where you want Samba to run. In smb.conf under the [global] section, add:

"interfaces = 127.0.0.1, 192.168.0.31/24""bind interfaces only = yes"

The first address (127.0.0.1), is a loopback network connection (it’s your own machine). The second address (192.168.0.31), is the address of the card you want Samba to run on, the second number (24) is the subnet default for a CLASS-C network. It may vary depending on your network.

With “bind interfaces only” you limit which interfaces on a machine will serve SMB requests.

You can limit which IP address can connect to your Samba server adding these lines:

"hosts allow = 127.0.0.1, 192.168.0.31, 192.168.0.32""hosts deny = 0.0.0.0/0"

The loopback address must be present in the first line. The second line deny access from all IP address not in the first line.

Back to top

Sharing CUPS Printers

If You would like to share Your printers make the following changes to Samba:

If not already done create the Samba-user You want the share to be used by.

In smb.conf uncomment and change the lines ending up with the following configuration:

########## Printing ##########

# If you want to automatically load your printer list rather# than setting them up individually then you'll need this  load printers = yes

# [...] // Some BSD printing stuff, do not edit if You do not need to

# CUPS printing.  See also the cupsaddsmb(8) manpage in the# cupsys-client package.  printing = cups  printcap name = cups

and in the Share Definitions section append and/or modify the [printers] part ending up like this:

# ======================= Share Definitions =======================# [...] // File and Folder sharing, do not edit if You do not need to

[printers]  comment = All Printers  browseable = no  path = /tmp  printable = yes  public = yes  writable = no  create mode = 0700  printcap name = /etc/printcap  print command = /usr/bin/lpr -P%p -r %s  printing = cups

Some explanation what is done:

the [printers] part defines the default-behavior for all the printers that are mentioned in “printcap name”. A sort of template how to create shares for these printers. This template is applied if “load printers” is set to true. For more detailed explanation refer to the Samba documentation.

And do not forget to reload Samba:

sudo /etc/init.d/samba reload

Back to top

SMB:Configuring your computer as a server

In howto, linux, server on November 11, 2007 at 4:09 pm

A fairly comprehensive graphical Samba configuration tool is available for KDE, by installing the “kdenetwork-filesharing” package. Once install, you can find it by launching the KDE Control Center. (Alt-F2 and then type kcontrol). Browse to Internet & Network > Samba. It is fairly easy to use.

A less friendly but also graphical tool is Swat, a web-based interface.

The following tips show how to do some basic things without installing additional software, using the command line. It is not difficult, just be careful with typos.

First open a terminal: Applications > System Tools > Terminal and open the file smb.conf

sudo nano -w /etc/samba/smb.conf

How to Save: To save in nano use “ctrl/o” than “ctrl/x”.

Tip: Replacing nano with gedit gives you a nice graphical editor.

The file *smb.conf* is divided in several sections:

Global SettingsDebugging/AccountingAuthenticationPrintingFile sharingMiscShare Definitions

Let’s start with Global Settings. Here you will see several lines, which you can also see in the graphical networktool like workgroup and wins server. If you changed everything to your liking already then you can skip this section, if not change to what you need. If you do not know what items mean, leave them be and read the [WWW] relevant part in the real Samba-howto instead of randomly changing them. It will save you trouble-shooting later.

The important part for us is File sharing. We need to change:

[homes]comment = Home Directoriesbrowseable = no

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = no

This describes your /home folder. Usually you want to share this folder in a home-environment, because these are the files you want to share. To do so, make the following changes:

[homes]comment = Home Directoriesbrowseable = yes

# By default, the home directories are exported read-only. Change next# parameter to 'yes' if you want to be able to write to them. writable = yes

This finishes sharing your /home folder. The last thing we need to do is fixing a user.

Add users who can access your shares with the ’smbpasswd’ command.

sudo  smbpasswd -a username

New SMB password:Retype new SMB password:Added user username.

NOTE: the username used here should be a real user setup on your PC/Server. Reload Samba for every change to users/passwords or ’smb.conf’

sudo /etc/init.d/samba reload

That’s the basis of Samba file-sharing. Please leave your comments about what else is needed here.

Back to top

Complicating things a little

We started with the base of Samba file-sharing. The above-mentioned items should be enough to get you started. Next we will add details that you might or might not need.

Back to top

If you have more the one networkcard

If you have more the one networkcard (or interface) then you have to define where you want Samba to run. In smb.conf under the [global] section, add:

"interfaces = 127.0.0.1, 192.168.0.31/24""bind interfaces only = yes"

The first address (127.0.0.1), is a loopback network connection (it’s your own machine). The second address (192.168.0.31), is the address of the card you want Samba to run on, the second number (24) is the subnet default for a CLASS-C network. It may vary depending on your network.

With “bind interfaces only” you limit which interfaces on a machine will serve SMB requests.

You can limit which IP address can connect to your Samba server adding these lines:

"hosts allow = 127.0.0.1, 192.168.0.31, 192.168.0.32""hosts deny = 0.0.0.0/0"

The loopback address must be present in the first line. The second line deny access from all IP address not in the first line.

Back to top

Sharing CUPS Printers

If You would like to share Your printers make the following changes to Samba:

If not already done create the Samba-user You want the share to be used by.

In smb.conf uncomment and change the lines ending up with the following configuration:

########## Printing ##########

# If you want to automatically load your printer list rather# than setting them up individually then you'll need this  load printers = yes

# [...] // Some BSD printing stuff, do not edit if You do not need to

# CUPS printing.  See also the cupsaddsmb(8) manpage in the# cupsys-client package.  printing = cups  printcap name = cups

and in the Share Definitions section append and/or modify the [printers] part ending up like this:

# ======================= Share Definitions =======================# [...] // File and Folder sharing, do not edit if You do not need to

[printers]  comment = All Printers  browseable = no  path = /tmp  printable = yes  public = yes  writable = no  create mode = 0700  printcap name = /etc/printcap  print command = /usr/bin/lpr -P%p -r %s  printing = cups

Some explanation what is done:

the [printers] part defines the default-behavior for all the printers that are mentioned in “printcap name”. A sort of template how to create shares for these printers. This template is applied if “load printers” is set to true. For more detailed explanation refer to the Samba documentation.

And do not forget to reload Samba:

sudo /etc/init.d/samba reload

Back to top

SMB vs NFS

In howto, linux, server on November 11, 2007 at 1:41 am

SMB是Server Messege Block的缩写,其实就是实现Windows文件和打印共享的基础协议,后来在*nix下通过samba实现了smb协议,所以可以达成不同系统之间的文件和打印共享互通。
而NFS是在内核级别实现的Network File System。通过NFS协议import的分区,可以当成本机的磁盘来使用。所有读写都是内核负责,所以效率上比SMB要好,但是仅仅能实现文件读写,没有打印服务。

smb service

In howto, linux, server on November 11, 2007 at 1:35 am
为了实现windows 和 Linux以及其他操作系统之间的资源共享,软件商推出nfs
和samba两种解决方式。由于市场上缺乏象pc-nfs那样的客户端工具,使得Linux和windows的资源共享变得复杂。Samba的出现解决了
这一问题,它以其简洁、实用、灵活配置的特点受到越来越多人们的广泛关注。

  Windows利用SMB协议来实现操作系统间文件和打印机共享,而Samba本身具备SMB协议,它实现局域网内和Windows系列计算机的资源共享。

  本文就Samba在Linux系统下的配置为重点,讨论局域网内windows 与 Linux 的资源共享。

  一、Samba 介绍

  1、SMB协议

 
 SMB (Server Message Block,服务信息块)
协议,是局域网上的共享文件/打印机的一种协议,它可以为网络内部的其他windows和linux
机器提供文件系统、打印服务。SMB的工作原理是让NetBIOS和SMB运行在TCP/IP之上,且使用NetBIOS的nameserver让
linux机器可以在windows 网络邻居里被浏览。

  2、Samba

  Samba是用来实现SMB的一种软件,由澳大利亚的Andew Tridgell开发,是一种在Linux 环境里运行的自由软件。它可以完成如下功能:

  文件服务和打印服务,实现Windows和Linux的资源共享。

  登录服务器,可以作为局域网的服务器。

  作为主域控制器。

  WINS服务器。

  支持SSL。

  支持SWAT。

  二、 Samba服务

  1、 核心进程

  Samba 有两个守护进程:smbd 和nmbd,它们是Samba的核心进程。nmbd进程使其他计算机浏览Linux服务器,Smbd进程在SMB服务请求到达时对它们进行处理,并且为使用或共享的资源进行协调。

smbd 是提供数据传输服务,也就是我们说的Samba服务的主要功能
nmbd 是提供名称解析服务的,就是说开启此服务我们可以通过主机名来访问共享目录

  2、 启动服务

  Samba 有两种启动方式:Daemon形式和Inetd形式。

  (1)Daemon形式 建立启动脚本:rc.samba

  smbd -D -d1

  nmbd -D -d1

  -D 表示以Daemon形式执行;-d1 表示除错记录级别

  执行脚本文件rc.samba

  (2)Inetd形式

  设置文件:/etc/services

  netbios -ssn 139/ tcp

  netbios -ns 137/ udp

  设置文件:/etc/inetd.conf

  netbios -ssn stream tcp nowait root /usr/sbin/smbd smbd

  netbios -ns dgram udp wait root /usr/sbin/nmbd nmbd

  重启动Inetd daemon

  # kill -HUP 1

  3、 客户工具 smbclient

  Smbclient命令用来存取远程Samba服务器上的资源。其命令形式与ftp相似。

  命令语法是:#smbclient [password] [option]

  (1) 解释:servicename是要连接的资源名称,资源名称的形式如下:

  //server/service server 是远程服务器的NetBIOS名字,对于windows服务器而言,就是出现在网上邻居中的名字。

  Service是各server所提供的资源的名字。

  pssword 是存取该资源所需的口令

  option 各种命令选项,其中 -L 用于列出远程服务器提供的所有资源

  -I 指定远程服务器的IP地址。此时,servicesname 中的NetBIOS名部分将被忽略。

  (2)多种smbclient命令:

  执行smbclient命令成功后,进入smbclient环境,出现提示符: smb:\>

  这里有许多命令和ftp命令相似,如cd 、lcd、get、megt、put、mput等。通过这些命令,我们可以访问远程主机的共享资源。

  4、 Samba系统装载与卸载

  (1) 装载其他主机的资源

  我们可以利用Samba提供的smbmount命令,装载其他主机的共享资源。

  Smbmount的命令语法:# smbmount

  其中 servicename 是资源名,mount-point是安装点。

  例如: # smbmount “\\server\tmp” -c ‘ mount /mnt’

  表示:把名字为“server”的计算机上的共享资源“tmp”的内容装载到本地的 /mnt

  目录下。

  (2) 卸载资源

  卸载一个已经装载的SMB文件系统,使用smbunmount命令,同时指定要卸载的装载点。 例如: # smbunmount / mnt

  三、Samba配置

  Samba组件的配置文件是 /etc/smb.conf ,该文件几乎包含了Samba系统程序运行时所需的所有配置信息。

  1、 配置选项

  配置文件中有比较重要的几个节:[gloabal]、[homes]、[printers],下面分别给与说明。

  (1)[gloabal]节 在全局参数中,参数的设置直接影响samba系统。

  NetBIOS name:设置主机名称

  Workgroup:用来指定主机所在网络上所属的NT域名或者工作组名称。格式是

  Workgroup= Nt Domain-Name or workgroup-name

  Server string:用来设置本机描述,缺省是 Samba Server

  Host Allow:它允许设置哪些领域的机器可以访问它的Samba服务器

  Load printers:允许自动加载打印机列表,而不需要单独设置每一台打印机。

  Interface:配置Samba使用多个网络界面。

  Domain controller: 仅当网络中有一台在安装时设置为主域控制器时使用此选项。

  Security: 设置安全参数,定义安全模式。Samba 的安全模式有四种

  Share、 user、 server 、domain

  encrypt passwords 、smb passwd file:用于适用加密口令。

  下面是一段参数配置例子:

  [global]

  smb passwd file = /etc/smbpasswd

  remote announce = 172.18.158.234 172.18.153.55 172.18.153.255

  dns proxy = no

  security = user

  encrypt passwords = yes

  server string = Ftp Server

  workgroup = turing

  socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  log file = /var/log/samba/log.%m

  load printers = yes

  guest account = dscan

  remote browse sync = 172.18.158.234 172.18.153.55 172.18.153.255

  printcap name = /etc/printcap

  max log size = 50

  hosts allow = 172.18.158. 172.18.153. 127.

  … …

  (2)[homes]节 所有使用者的home目录

  当任何一个客户访问Samba服务器时,在网络资源中都能出现自己的home目录共享。其配置如下:

  [homes]

  comment = Hnnw Directories

  browseable = no

  writable = yes

  (3)用户共享目录

  用来指定某一特定用户组或者用户拥有访问权限的目录配置,下列参数配置仅有hnnw组的用户有权访问目录/home/samba。

  [public]

  comment = Public Hnnw

  path = /home/samba

  public = yes

  writable = yes

  printable = no

  write list = @hnnw

  2、 用户映射

  全局参数“username map”用来控制用户映射,它允许管理员指定一个映射文件,该文件包含了在客户机和服务器之间进行用户映射的信息。

  如:username map= /etc/smbuser

  用户映射经常在windows 和linux 主机间进行。 两个系统拥有不同的用户账号,用户映射的目的是将不同的用户映射成为一个用户,便于共享文件。

  下面是一个映射文件的例子:

  # Map Windows admin to root

  root=admin administrator

  ;Map the member of developer to studio

  studio = @developer

  等号左边是单独的Linux账号,等号右边是要映射的账号列表。

  服务器逐行分析映射文件,如果提供的账号和某行有右侧列表中的账号匹配,就把它

  替换为等号左边的账号。

  3、 使用加密口令

 
 新版本的windows
95以及windows98、winnt(sp3以上版本),在网络传输中仅传递加密口令作为用户认证的信息。这类客户机和不支持加密口令并且以user
安全级运行的Samba服务器通讯时,会出现故障。为了正常的通讯,samba服务器使用加密口令。下面讨论如何在samba中使用加密口令。

  (1) 口令文件 /etc/smbpasswd

  为了使用加密口令,samba 需要一份口令文件(/etc/smbpasswd),并且该文件应该和Linux的口令文件(/etc/passwd)保持同步。下面是生成文件命令:

  # cat /etc/password | mksmbpasswd >/etc/smbpasswd

  smbpasswd 是需要的口令文件,其权限是0600,所有者是root

  smbpasswd和passwd文件的记录对应,密码部分不同。密码有两部分组成,每部分

  是32个”X”,前部分用于和Lanman通讯,后部分和Windows NT通讯。

  Root用户可以使用smbpasswd命令为每个用户设定samba口令。

  (2) 修改配置文件 /etc/smb.conf

  要使Samba使用加密口令,需要在配置文件smb.conf中加入如下参数。

  Encrypt passwords=yes

  Smb passwd file= /etc/smbpasswd

  第一行通知samba使用加密口令,第二行给出口令文件的位置。

  (3) 重启动samba 服务。

  修改完配置文件后,需要重新启动samba服务,可用如下命令:

  # /usr/sbin/samba restart

  4、windows系统中的明码口令使用

 
 Samba系统中使用明码口令作为连接SMB的默认设置。当SMB服务器对协商协议做出响应时,响应信息包含了一位,以说明服务器是否支持询问或者响应

密。随着win95的网络重定向更新程序的发布,Microsoft修改了默认值,这样,windows客户就不会向不支持加密的服务器发送明码口令了。

  在这种情况下,有两种解决办法:

  (1)设置Samba服务器使用加密口令

  (2)让windows客户使用明码口令

  这里选用第2种解决办法,通过修改注册表来实现。下面对win95/win98、winnt用户分别给与说明。

  (1)win98/win95系统用户

  在注册表中加入下列注册字,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\VxD\VNETSUP]

  “EnablePlainTextPAssword”= dword:00000001

  (2)Winnt系统用户

  修改注册表,加入下列注册表项,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\Rdr\Parameters]

  “EnablePlainTextPAssword”= dword:00000001

  四、Samba应用

  1、 windows资源共享与使用

  (1)windows资源共享

  a. 使用TCP/IP协议作为网络默认通讯协议

  b. 修改网络配置,设置文件和打印机共享。

  c. 设置好计算机名和所属工作组

  d.共享系统资源

  (2)在windows系统中使用Linux共享资源

  a. 登录进入windows网络

  b. 通过网上邻居查看、使用共享资源。

  c. 命令行下工具使用共享资源

  使用命令行下的net.txt工具来查看、使用共享资源:

  net use 命令的语法: c:>net use X:\\servername\sharename

  在这里,X:是共享的驱动器盘符,\\servername\sharename是到共享的UNC的网络路径。

  例如: c:\>net use h:\\hey\myfile

  表示:将hey机器上的myfile共享资源映射为本地的h盘

  2、Linux资源共享与使用

  (1)将Linux 的资源共享

  通过编辑Samba配置文件,添加需要共享的Linux资源。同时可以设定访问此资源的用户群及其访问权限。下面是一段例子,将本机的 /public/data 目录共享,所有人都有读写权限。

  [data]

  comment = Public Data

  path = /public/data

  public = yes

  writable = yes

  printable = no

  (2)在Linux中使用共享资源

  可以使用smbclient命令,访问所有的Samba资源。具体使用方法见前述。

  五、Samba应用程序

  smbclient :访问所有共享资源

  smbstatus: 列出当前所有的samba连接状态

  smbpasswd:修改samba用户口令、增加samba用户。

  Nmblookup:用于查询主机的NetBIOS名,并将其映射为IP地址

  Testparam: 用于检查配置文件中的参数设置是否正确

  Linux 系统中的Samba配置

Powered by ScribeFire.

smb service

In howto, linux, server on November 11, 2007 at 1:35 am
为了实现windows 和 Linux以及其他操作系统之间的资源共享,软件商推出nfs
和samba两种解决方式。由于市场上缺乏象pc-nfs那样的客户端工具,使得Linux和windows的资源共享变得复杂。Samba的出现解决了
这一问题,它以其简洁、实用、灵活配置的特点受到越来越多人们的广泛关注。

  Windows利用SMB协议来实现操作系统间文件和打印机共享,而Samba本身具备SMB协议,它实现局域网内和Windows系列计算机的资源共享。

  本文就Samba在Linux系统下的配置为重点,讨论局域网内windows 与 Linux 的资源共享。

  一、Samba 介绍

  1、SMB协议

 
 SMB (Server Message Block,服务信息块)
协议,是局域网上的共享文件/打印机的一种协议,它可以为网络内部的其他windows和linux
机器提供文件系统、打印服务。SMB的工作原理是让NetBIOS和SMB运行在TCP/IP之上,且使用NetBIOS的nameserver让
linux机器可以在windows 网络邻居里被浏览。

  2、Samba

  Samba是用来实现SMB的一种软件,由澳大利亚的Andew Tridgell开发,是一种在Linux 环境里运行的自由软件。它可以完成如下功能:

  文件服务和打印服务,实现Windows和Linux的资源共享。

  登录服务器,可以作为局域网的服务器。

  作为主域控制器。

  WINS服务器。

  支持SSL。

  支持SWAT。

  二、 Samba服务

  1、 核心进程

  Samba 有两个守护进程:smbd 和nmbd,它们是Samba的核心进程。nmbd进程使其他计算机浏览Linux服务器,Smbd进程在SMB服务请求到达时对它们进行处理,并且为使用或共享的资源进行协调。

smbd 是提供数据传输服务,也就是我们说的Samba服务的主要功能
nmbd 是提供名称解析服务的,就是说开启此服务我们可以通过主机名来访问共享目录

  2、 启动服务

  Samba 有两种启动方式:Daemon形式和Inetd形式。

  (1)Daemon形式 建立启动脚本:rc.samba

  smbd -D -d1

  nmbd -D -d1

  -D 表示以Daemon形式执行;-d1 表示除错记录级别

  执行脚本文件rc.samba

  (2)Inetd形式

  设置文件:/etc/services

  netbios -ssn 139/ tcp

  netbios -ns 137/ udp

  设置文件:/etc/inetd.conf

  netbios -ssn stream tcp nowait root /usr/sbin/smbd smbd

  netbios -ns dgram udp wait root /usr/sbin/nmbd nmbd

  重启动Inetd daemon

  # kill -HUP 1

  3、 客户工具 smbclient

  Smbclient命令用来存取远程Samba服务器上的资源。其命令形式与ftp相似。

  命令语法是:#smbclient [password] [option]

  (1) 解释:servicename是要连接的资源名称,资源名称的形式如下:

  //server/service server 是远程服务器的NetBIOS名字,对于windows服务器而言,就是出现在网上邻居中的名字。

  Service是各server所提供的资源的名字。

  pssword 是存取该资源所需的口令

  option 各种命令选项,其中 -L 用于列出远程服务器提供的所有资源

  -I 指定远程服务器的IP地址。此时,servicesname 中的NetBIOS名部分将被忽略。

  (2)多种smbclient命令:

  执行smbclient命令成功后,进入smbclient环境,出现提示符: smb:\>

  这里有许多命令和ftp命令相似,如cd 、lcd、get、megt、put、mput等。通过这些命令,我们可以访问远程主机的共享资源。

  4、 Samba系统装载与卸载

  (1) 装载其他主机的资源

  我们可以利用Samba提供的smbmount命令,装载其他主机的共享资源。

  Smbmount的命令语法:# smbmount

  其中 servicename 是资源名,mount-point是安装点。

  例如: # smbmount “\\server\tmp” -c ‘ mount /mnt’

  表示:把名字为“server”的计算机上的共享资源“tmp”的内容装载到本地的 /mnt

  目录下。

  (2) 卸载资源

  卸载一个已经装载的SMB文件系统,使用smbunmount命令,同时指定要卸载的装载点。 例如: # smbunmount / mnt

  三、Samba配置

  Samba组件的配置文件是 /etc/smb.conf ,该文件几乎包含了Samba系统程序运行时所需的所有配置信息。

  1、 配置选项

  配置文件中有比较重要的几个节:[gloabal]、[homes]、[printers],下面分别给与说明。

  (1)[gloabal]节 在全局参数中,参数的设置直接影响samba系统。

  NetBIOS name:设置主机名称

  Workgroup:用来指定主机所在网络上所属的NT域名或者工作组名称。格式是

  Workgroup= Nt Domain-Name or workgroup-name

  Server string:用来设置本机描述,缺省是 Samba Server

  Host Allow:它允许设置哪些领域的机器可以访问它的Samba服务器

  Load printers:允许自动加载打印机列表,而不需要单独设置每一台打印机。

  Interface:配置Samba使用多个网络界面。

  Domain controller: 仅当网络中有一台在安装时设置为主域控制器时使用此选项。

  Security: 设置安全参数,定义安全模式。Samba 的安全模式有四种

  Share、 user、 server 、domain

  encrypt passwords 、smb passwd file:用于适用加密口令。

  下面是一段参数配置例子:

  [global]

  smb passwd file = /etc/smbpasswd

  remote announce = 172.18.158.234 172.18.153.55 172.18.153.255

  dns proxy = no

  security = user

  encrypt passwords = yes

  server string = Ftp Server

  workgroup = turing

  socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  log file = /var/log/samba/log.%m

  load printers = yes

  guest account = dscan

  remote browse sync = 172.18.158.234 172.18.153.55 172.18.153.255

  printcap name = /etc/printcap

  max log size = 50

  hosts allow = 172.18.158. 172.18.153. 127.

  … …

  (2)[homes]节 所有使用者的home目录

  当任何一个客户访问Samba服务器时,在网络资源中都能出现自己的home目录共享。其配置如下:

  [homes]

  comment = Hnnw Directories

  browseable = no

  writable = yes

  (3)用户共享目录

  用来指定某一特定用户组或者用户拥有访问权限的目录配置,下列参数配置仅有hnnw组的用户有权访问目录/home/samba。

  [public]

  comment = Public Hnnw

  path = /home/samba

  public = yes

  writable = yes

  printable = no

  write list = @hnnw

  2、 用户映射

  全局参数“username map”用来控制用户映射,它允许管理员指定一个映射文件,该文件包含了在客户机和服务器之间进行用户映射的信息。

  如:username map= /etc/smbuser

  用户映射经常在windows 和linux 主机间进行。 两个系统拥有不同的用户账号,用户映射的目的是将不同的用户映射成为一个用户,便于共享文件。

  下面是一个映射文件的例子:

  # Map Windows admin to root

  root=admin administrator

  ;Map the member of developer to studio

  studio = @developer

  等号左边是单独的Linux账号,等号右边是要映射的账号列表。

  服务器逐行分析映射文件,如果提供的账号和某行有右侧列表中的账号匹配,就把它

  替换为等号左边的账号。

  3、 使用加密口令

 
 新版本的windows
95以及windows98、winnt(sp3以上版本),在网络传输中仅传递加密口令作为用户认证的信息。这类客户机和不支持加密口令并且以user
安全级运行的Samba服务器通讯时,会出现故障。为了正常的通讯,samba服务器使用加密口令。下面讨论如何在samba中使用加密口令。

  (1) 口令文件 /etc/smbpasswd

  为了使用加密口令,samba 需要一份口令文件(/etc/smbpasswd),并且该文件应该和Linux的口令文件(/etc/passwd)保持同步。下面是生成文件命令:

  # cat /etc/password | mksmbpasswd >/etc/smbpasswd

  smbpasswd 是需要的口令文件,其权限是0600,所有者是root

  smbpasswd和passwd文件的记录对应,密码部分不同。密码有两部分组成,每部分

  是32个”X”,前部分用于和Lanman通讯,后部分和Windows NT通讯。

  Root用户可以使用smbpasswd命令为每个用户设定samba口令。

  (2) 修改配置文件 /etc/smb.conf

  要使Samba使用加密口令,需要在配置文件smb.conf中加入如下参数。

  Encrypt passwords=yes

  Smb passwd file= /etc/smbpasswd

  第一行通知samba使用加密口令,第二行给出口令文件的位置。

  (3) 重启动samba 服务。

  修改完配置文件后,需要重新启动samba服务,可用如下命令:

  # /usr/sbin/samba restart

  4、windows系统中的明码口令使用

 
 Samba系统中使用明码口令作为连接SMB的默认设置。当SMB服务器对协商协议做出响应时,响应信息包含了一位,以说明服务器是否支持询问或者响应

密。随着win95的网络重定向更新程序的发布,Microsoft修改了默认值,这样,windows客户就不会向不支持加密的服务器发送明码口令了。

  在这种情况下,有两种解决办法:

  (1)设置Samba服务器使用加密口令

  (2)让windows客户使用明码口令

  这里选用第2种解决办法,通过修改注册表来实现。下面对win95/win98、winnt用户分别给与说明。

  (1)win98/win95系统用户

  在注册表中加入下列注册字,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\VxD\VNETSUP]

  “EnablePlainTextPAssword”= dword:00000001

  (2)Winnt系统用户

  修改注册表,加入下列注册表项,并重新启动机器:

  [HKLM\System\CurrentCntrolSet\Services\Rdr\Parameters]

  “EnablePlainTextPAssword”= dword:00000001

  四、Samba应用

  1、 windows资源共享与使用

  (1)windows资源共享

  a. 使用TCP/IP协议作为网络默认通讯协议

  b. 修改网络配置,设置文件和打印机共享。

  c. 设置好计算机名和所属工作组

  d.共享系统资源

  (2)在windows系统中使用Linux共享资源

  a. 登录进入windows网络

  b. 通过网上邻居查看、使用共享资源。

  c. 命令行下工具使用共享资源

  使用命令行下的net.txt工具来查看、使用共享资源:

  net use 命令的语法: c:>net use X:\\servername\sharename

  在这里,X:是共享的驱动器盘符,\\servername\sharename是到共享的UNC的网络路径。

  例如: c:\>net use h:\\hey\myfile

  表示:将hey机器上的myfile共享资源映射为本地的h盘

  2、Linux资源共享与使用

  (1)将Linux 的资源共享

  通过编辑Samba配置文件,添加需要共享的Linux资源。同时可以设定访问此资源的用户群及其访问权限。下面是一段例子,将本机的 /public/data 目录共享,所有人都有读写权限。

  [data]

  comment = Public Data

  path = /public/data

  public = yes

  writable = yes

  printable = no

  (2)在Linux中使用共享资源

  可以使用smbclient命令,访问所有的Samba资源。具体使用方法见前述。

  五、Samba应用程序

  smbclient :访问所有共享资源

  smbstatus: 列出当前所有的samba连接状态

  smbpasswd:修改samba用户口令、增加samba用户。

  Nmblookup:用于查询主机的NetBIOS名,并将其映射为IP地址

  Testparam: 用于检查配置文件中的参数设置是否正确

  Linux 系统中的Samba配置

Powered by ScribeFire.

NFS service

In howto, linux, server on November 11, 2007 at 1:16 am
Linux服务配置文档—NFS – wds

NFS为network file system 的简称,最早由sun公司开发,一般NFS广泛应用在集群服务器上,他的最大特点是可以通过网络让不同的机器,不同的操作系统可以彼此的共享文件,所以它可以看作一个简单的文件服务器。NFS其实可以被视为一个RPC服务程序,在启动RPC程序前我们先要做好端口的映射工作这就是portmap,portmap的意思是当Client要连接服务器时必须知道服务器的一个空闲端口这时Client会向服务器的portmap请求一个端口然,然后Server告诉Client这端口后才可以建立连接,所以在启动NFS前要先启动portmap

[wds@localhost ~]# rpm –qa |grep nfs && rpm –qa | grep portmap #查找这两个是否安装

[wds@localhost ~]# vi /etc/exports # 这文件是NFS的主要配置文件

[wds@localhost ~]# /usr/sbin/exportfs #这个文件是nfs共享资源命令

[wds@localhost ~]# /usr/sbin/showmount #可以查看远程服务器的共享目录

[wds@localhost ~]# /var/lib/nfs/xtab #nfs 的日志文件

[wds@localhost ~]# vi /etc/exports

[你想要的共享的目录] + ip 地址(参数一,参数二) [主机名二](参数三,参数四)

参数列表

rw: 可以写入权限

ro: 只读权限

no_root_squash: 登陆NFS主机共享目录的如果是root用户那么那的权限也为root但是这样并不安全

root_squash: 登陆的用户如果为root它的权限将变成nobody

all_squash: 不论登陆的用户是什么用户都以匿名用户的权限

sync: 数据同步写入硬盘和内存中

async: 数据先暂时存放在内存中,而不写入硬盘

anounid: 这个可以自己设定uid,但是必须与/etc/passwd目录中用户uid一样

anongid: 同anonuid,但是变的是group id

服务器端配置

[wds@localhost ~]# service portmap start #首先打开portmap

[wds@localhost ~]# service nfs start # 在打开 nfs

[wds@localhost ~]#i iptables –F #清空防火墙命令

[wds@localhost ~]#

比如说我要共享/var/www/html 目录 但是只是让和我一个网段的机器访问192.168.0.0/24这个网段读或写,其他的就只能读,然后在发布一个私人目录/home/wds/只开放给192.168.0.8

这个IP

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

现在想要*.chinaunix.com网段的机器登陆我的NFS,并且访问我的/home/wds/ 但是它们存储时我希望它们的uid和gid都变成40这个用户身份

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

/home/wds *.chinaunix.com(rw,all)squash,anounid=40,anongid=40)

如果我们修改/etc/exports这个文件后,是否要从新启动nfs呢?答案是不不需要,只要使用exportfs来从新扫描一次/etc/exports文件,并且从新设置文件加载即可

语法为:

[wds@localhost ~]# exportfs [-aruv]

参数说明:

-a: 全部挂载(或者卸载)/etc/exports 文件的设置

-r: 从新挂载/etc/exports 里设置,此外,同步更新/etc/exports 及/var/lib/nfs/xtab的内容

-u: 卸载某一目录

-v: 在导出时,将共享目录显示在屏幕上

例如:

[wds@localhost ~]# exportfs –rv 全部从新导出一次

[wds@localhost ~]# exportfs –au 全部卸载掉

Showmount 的是显示是否有挂载

语法为:

[wds@localhost ~]# showmount [-ae] hostname

参数说明:

-a: 在屏幕上显示与当前的client连接后使用目录的状态

-e: 显示Hostname这台机器的/etc/exports中的共享信息

[wds@localhost log]# showmount -e localhost

Export list for localhost:

/var/www/html (everyone)

Rpcinfo [-p]hostname[or ip]

-p 显示端口与程序的信息

[wds@localhost log]# rpcinfo -p localhost

program vers proto port

100000 2 tcp 111 portmapper

100000 2 udp 111 portmapper

100024 1 udp 1024 status

100024 1 tcp 1024 status

100011 1 udp 837 rquotad

100011 2 udp 837 rquotad

100011 1 tcp 840 rquotad

100011 2 tcp 840 rquotad

100003 2 udp 2049 nfs

100003 3 udp 2049 nfs

100003 4 udp 2049 nfs

100003 2 tcp 2049 nfs

100003 3 tcp 2049 nfs

100003 4 tcp 2049 nfs

100021 1 udp 1026 nlockmgr

100021 3 udp 1026 nlockmgr

100021 4 udp 1026 nlockmgr

100021 1 tcp 1026 nlockmgr

100021 3 tcp 1026 nlockmgr

100021 4 tcp 1026 nlockmgr

100005 1 udp 858 mountd

100005 1 tcp 861 mountd

100005 2 udp 858 mountd

100005 2 tcp 861 mountd

100005 3 udp 858 mountd

100005 3 tcp 861 mountd

Client端的设置

Server端设置完毕,接下来就是让client端连接上server!连接server步骤如下:

1. 扫描可以使用的server目录:

2. 在client端建立装载点

3. 使用mount 命令远程挂载远程共享目录

4. 解决可能发生的问题(被防火墙过滤掉了)

Showmount是显示远程主机共享资源

[wds@localhost ~]# showmount -e 192.168.0.8

Export list for 192.168.0.8:

/var/www/html (everyone)

/home/wds *.chinaunix.com,192.168.0.6

[wds@localhost ~]# mount -t nfs 192.168.0.8:/var/www/html /mnt 把远程的/var/www/html 挂载到本地

[wds@localhost ~]# umount /mnt 卸载远程目录

如果你想要开机启动时自动加载NFS服务器导出目录,我们在NFS端/etc/fstab文件中加入以下一行

192.168.0.8:/var/www/html /mnt nfs rsize=8192,wsize=8192,timeo=14,intr

Powered by ScribeFire.

NFS service

In howto, linux, server on November 11, 2007 at 1:16 am
Linux服务配置文档—NFS – wds

NFS为network file system 的简称,最早由sun公司开发,一般NFS广泛应用在集群服务器上,他的最大特点是可以通过网络让不同的机器,不同的操作系统可以彼此的共享文件,所以它可以看作一个简单的文件服务器。NFS其实可以被视为一个RPC服务程序,在启动RPC程序前我们先要做好端口的映射工作这就是portmap,portmap的意思是当Client要连接服务器时必须知道服务器的一个空闲端口这时Client会向服务器的portmap请求一个端口然,然后Server告诉Client这端口后才可以建立连接,所以在启动NFS前要先启动portmap

[wds@localhost ~]# rpm –qa |grep nfs && rpm –qa | grep portmap #查找这两个是否安装

[wds@localhost ~]# vi /etc/exports # 这文件是NFS的主要配置文件

[wds@localhost ~]# /usr/sbin/exportfs #这个文件是nfs共享资源命令

[wds@localhost ~]# /usr/sbin/showmount #可以查看远程服务器的共享目录

[wds@localhost ~]# /var/lib/nfs/xtab #nfs 的日志文件

[wds@localhost ~]# vi /etc/exports

[你想要的共享的目录] + ip 地址(参数一,参数二) [主机名二](参数三,参数四)

参数列表

rw: 可以写入权限

ro: 只读权限

no_root_squash: 登陆NFS主机共享目录的如果是root用户那么那的权限也为root但是这样并不安全

root_squash: 登陆的用户如果为root它的权限将变成nobody

all_squash: 不论登陆的用户是什么用户都以匿名用户的权限

sync: 数据同步写入硬盘和内存中

async: 数据先暂时存放在内存中,而不写入硬盘

anounid: 这个可以自己设定uid,但是必须与/etc/passwd目录中用户uid一样

anongid: 同anonuid,但是变的是group id

服务器端配置

[wds@localhost ~]# service portmap start #首先打开portmap

[wds@localhost ~]# service nfs start # 在打开 nfs

[wds@localhost ~]#i iptables –F #清空防火墙命令

[wds@localhost ~]#

比如说我要共享/var/www/html 目录 但是只是让和我一个网段的机器访问192.168.0.0/24这个网段读或写,其他的就只能读,然后在发布一个私人目录/home/wds/只开放给192.168.0.8

这个IP

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

现在想要*.chinaunix.com网段的机器登陆我的NFS,并且访问我的/home/wds/ 但是它们存储时我希望它们的uid和gid都变成40这个用户身份

[wds@localhost ~]# vi /etc/exports

/var/www/html 192.168.0.0/24 (rw) *(ro)

/home/wds 192.168.0.8(rw)

/home/wds *.chinaunix.com(rw,all)squash,anounid=40,anongid=40)

如果我们修改/etc/exports这个文件后,是否要从新启动nfs呢?答案是不不需要,只要使用exportfs来从新扫描一次/etc/exports文件,并且从新设置文件加载即可

语法为:

[wds@localhost ~]# exportfs [-aruv]

参数说明:

-a: 全部挂载(或者卸载)/etc/exports 文件的设置

-r: 从新挂载/etc/exports 里设置,此外,同步更新/etc/exports 及/var/lib/nfs/xtab的内容

-u: 卸载某一目录

-v: 在导出时,将共享目录显示在屏幕上

例如:

[wds@localhost ~]# exportfs –rv 全部从新导出一次

[wds@localhost ~]# exportfs –au 全部卸载掉

Showmount 的是显示是否有挂载

语法为:

[wds@localhost ~]# showmount [-ae] hostname

参数说明:

-a: 在屏幕上显示与当前的client连接后使用目录的状态

-e: 显示Hostname这台机器的/etc/exports中的共享信息

[wds@localhost log]# showmount -e localhost

Export list for localhost:

/var/www/html (everyone)

Rpcinfo [-p]hostname[or ip]

-p 显示端口与程序的信息

[wds@localhost log]# rpcinfo -p localhost

program vers proto port

100000 2 tcp 111 portmapper

100000 2 udp 111 portmapper

100024 1 udp 1024 status

100024 1 tcp 1024 status

100011 1 udp 837 rquotad

100011 2 udp 837 rquotad

100011 1 tcp 840 rquotad

100011 2 tcp 840 rquotad

100003 2 udp 2049 nfs

100003 3 udp 2049 nfs

100003 4 udp 2049 nfs

100003 2 tcp 2049 nfs

100003 3 tcp 2049 nfs

100003 4 tcp 2049 nfs

100021 1 udp 1026 nlockmgr

100021 3 udp 1026 nlockmgr

100021 4 udp 1026 nlockmgr

100021 1 tcp 1026 nlockmgr

100021 3 tcp 1026 nlockmgr

100021 4 tcp 1026 nlockmgr

100005 1 udp 858 mountd

100005 1 tcp 861 mountd

100005 2 udp 858 mountd

100005 2 tcp 861 mountd

100005 3 udp 858 mountd

100005 3 tcp 861 mountd

Client端的设置

Server端设置完毕,接下来就是让client端连接上server!连接server步骤如下:

1. 扫描可以使用的server目录:

2. 在client端建立装载点

3. 使用mount 命令远程挂载远程共享目录

4. 解决可能发生的问题(被防火墙过滤掉了)

Showmount是显示远程主机共享资源

[wds@localhost ~]# showmount -e 192.168.0.8

Export list for 192.168.0.8:

/var/www/html (everyone)

/home/wds *.chinaunix.com,192.168.0.6

[wds@localhost ~]# mount -t nfs 192.168.0.8:/var/www/html /mnt 把远程的/var/www/html 挂载到本地

[wds@localhost ~]# umount /mnt 卸载远程目录

如果你想要开机启动时自动加载NFS服务器导出目录,我们在NFS端/etc/fstab文件中加入以下一行

192.168.0.8:/var/www/html /mnt nfs rsize=8192,wsize=8192,timeo=14,intr

Powered by ScribeFire.

Feisty + Tomcat5.5 HowTo

In howto, linux, server on July 4, 2007 at 7:07 pm
Argh. So, if you tried installing tomcat5.5 from the repositories, you may have noticed that it’s broken. You get a configuration error about JAVA_HOME not being set. Actually, there are three problems!

All looks well when you run the startup script…

					$ export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.11/					$ sudo /usr/share/tomcat5.5/bin/startup.sh					Using CATALINA_BASE:   /usr/share/tomcat5.5					Using CATALINA_HOME:   /usr/share/tomcat5.5					Using CATALINA_TMPDIR: /usr/share/tomcat5.5/temp					Using JRE_HOME:       /usr/lib/jvm/java-1.5.0-sun-1.5.0.11/				

but netstat tells you nothing is actually going on…

					sudo netstat -plut					Active Internet connections (only servers)					Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   					tcp        0      0 *:www                   *:*                     LISTEN     3679/apache         					tcp6       0      0 *:ssh                   *:*                     LISTEN     3602/sshd				

The problem arises from a fifo at /usr/share/tomcat5.5/logs/catalina.out which is the target for
normal console output from the catalina (tomcat launch) script. This fifo doesn’t flow at all.
Replacing it with a regular file fixes the problem and tomcat launches OK.

###############################################

Here’s what you can do to get it to work:

1) Install

Code:

sudo aptitude install sun-java6-jdk tomcat5.5

(Note that you absolutely need the JDK, not just the JRE.)

2) Set Tomcat’s default JAVA_HOME

Code:

sudo gedit /etc/default/tomcat5.5

Uncomment the JAVA_HOME line and set it to your JDK path. For Java 6 installed from the repositories, it’s as so:

Code:

JAVA_HOME=/usr/lib/jvm/java-6-sun

3) Fix catalina.out

Unfortunately, it seems that Tomcat’s log file is set to be a pipe, but Tomcat can’t seem to start with it. We’ll recreate it as a regular file with the same security settings:

Code:

cd /var/log/tomcat5.5/
sudo rm catalina.out
sudo touch catalina.out
sudo chown tomcat55:nogroup catalina.out
sudo chmod uo-wrx catalina.out

Tomcat should work now as a daemon. Start it like this:

Code:

sudo /etc/init.d/tomcat5.5 start

And point your browser at http://localhost:8180/

Hooray!

This may be good enough for you. However, if you want to try to run Tomcat not as a daemon, but from a development tool (in my case I was using Sysdeo’s Tomcat plugin for Eclipse), you will find Tomcat announcing rather bizarre errors. So:

4) Change permissions on Tomcat’s work directory

Code:

cd /var/cache
sudo chmod go+rwx tomcat5.5

(This is probably not the most secure solution, but it should be OK for development environments. For production environments, you really don’t want anything to have access to Tomcat’s work directory! Another solution may be to change the link to this directory from /usr/share/tomcat5.5/work, which is what Tomcat actually uses.)

Thanks to the many folk on Ubuntu Forums who struggled to make this work. I merely put their advice together into a howto. Good luck, and let’s hope the tomcat5.5 package manager fixes these bugs!

Powered by ScribeFire.

Feisty + Tomcat5.5 HowTo

In howto, linux, server on July 4, 2007 at 7:07 pm
Argh. So, if you tried installing tomcat5.5 from the repositories, you may have noticed that it’s broken. You get a configuration error about JAVA_HOME not being set. Actually, there are three problems!

All looks well when you run the startup script…

					$ export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.11/					$ sudo /usr/share/tomcat5.5/bin/startup.sh					Using CATALINA_BASE:   /usr/share/tomcat5.5					Using CATALINA_HOME:   /usr/share/tomcat5.5					Using CATALINA_TMPDIR: /usr/share/tomcat5.5/temp					Using JRE_HOME:       /usr/lib/jvm/java-1.5.0-sun-1.5.0.11/				

but netstat tells you nothing is actually going on…

					sudo netstat -plut					Active Internet connections (only servers)					Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   					tcp        0      0 *:www                   *:*                     LISTEN     3679/apache         					tcp6       0      0 *:ssh                   *:*                     LISTEN     3602/sshd				

The problem arises from a fifo at /usr/share/tomcat5.5/logs/catalina.out which is the target for
normal console output from the catalina (tomcat launch) script. This fifo doesn’t flow at all.
Replacing it with a regular file fixes the problem and tomcat launches OK.

###############################################

Here’s what you can do to get it to work:

1) Install

Code:

sudo aptitude install sun-java6-jdk tomcat5.5

(Note that you absolutely need the JDK, not just the JRE.)

2) Set Tomcat’s default JAVA_HOME

Code:

sudo gedit /etc/default/tomcat5.5

Uncomment the JAVA_HOME line and set it to your JDK path. For Java 6 installed from the repositories, it’s as so:

Code:

JAVA_HOME=/usr/lib/jvm/java-6-sun

3) Fix catalina.out

Unfortunately, it seems that Tomcat’s log file is set to be a pipe, but Tomcat can’t seem to start with it. We’ll recreate it as a regular file with the same security settings:

Code:

cd /var/log/tomcat5.5/
sudo rm catalina.out
sudo touch catalina.out
sudo chown tomcat55:nogroup catalina.out
sudo chmod uo-wrx catalina.out

Tomcat should work now as a daemon. Start it like this:

Code:

sudo /etc/init.d/tomcat5.5 start

And point your browser at http://localhost:8180/

Hooray!

This may be good enough for you. However, if you want to try to run Tomcat not as a daemon, but from a development tool (in my case I was using Sysdeo’s Tomcat plugin for Eclipse), you will find Tomcat announcing rather bizarre errors. So:

4) Change permissions on Tomcat’s work directory

Code:

cd /var/cache
sudo chmod go+rwx tomcat5.5

(This is probably not the most secure solution, but it should be OK for development environments. For production environments, you really don’t want anything to have access to Tomcat’s work directory! Another solution may be to change the link to this directory from /usr/share/tomcat5.5/work, which is what Tomcat actually uses.)

Thanks to the many folk on Ubuntu Forums who struggled to make this work. I merely put their advice together into a howto. Good luck, and let’s hope the tomcat5.5 package manager fixes these bugs!

Powered by ScribeFire.