织梦CMS - 轻松建站从此开始!

罗索

Bf561与dm365比较学习(4):服务配置

jackyhwei 发布于 2011-07-18 15:51 点击:次 
网络服务相关的配置,包括:localhost、共享主机、NFS、Samba、tftp、ftp等等。
TAG:

localhost的问题
在coLinux下ping localhost,无法连接:
-bash-3.2# ping localhost
ping: unknown host localhost
解决方法:
创建/etc/hosts文件,内容为:
127.0.0.1 fc10 localhost.localdomain localhost
共享主机上的目录
coLinux提供了cofs文件系统,可以方便地访问windows的文件。
在使用的embed.conf中加上一行:
cofs0="f:/soft"
这里指定f:/soft目录与coLinux共享。
进入coLinux后修改fstab,加上这样一行:
cofs0:/                 /mnt/share              cofs    user,noexec,dmask=0777,fmask=0666       0 0
这样可以在启动coLinux时自动将WINDOWNS主机上的共享目录挂载到/mnt/share下了。
 
NFS配置
在根文件系统中使用的NFS服务是无法直接启动的:
-bash-3.2# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS daemon: [FAILED]
查看/var/log/messages,有这样一句话:
rpcbind: cannot get uid of 'rpc': Success
错误的原因在于没有创建rpc这个用户。
查看rpcbind的安装脚本:
-bash-3.2# rpm -q --scripts rpcbind
preinstall scriptlet (using /bin/sh):
# if the rpc uid and gid is left over from the portmapper
# remove both of them.
/usr/sbin/userdel rpc 2> /dev/null || :
/usr/sbin/groupdel rpc 2> /dev/null || :
 
# Now re-add the rpc uid/gid
/usr/sbin/groupadd -o -g 32 rpc > /dev/null 2>&1
/usr/sbin/useradd -o -l -c "Rpcbind Daemon" -d /var/lib/rpcbind -g 32 /
    -M -s /sbin/nologin -u 32 rpc > /dev/null 2>&1
postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add rpcbind
preuninstall scriptlet (using /bin/sh):
if [ $1 -eq 0 ]; then
    service rpcbind stop > /dev/null 2>&1
    /sbin/chkconfig --del rpcbind
        /usr/sbin/userdel rpc 2>/dev/null || :
        /usr/sbin/groupdel rpc 2>/dev/null || :
        rm -rf /var/lib/rpcbind
fi
postuninstall scriptlet (using /bin/sh):
if [ "$1" -ge "1" ]; then
    service rpcbind condrestart > /dev/null 2>&1
fi
从这段脚本可以确认rpc这个用户将在安装rpcbind时创建。
 
先删除rpcbind
rpm –e –nodeps rpcbind
再重新安装一次
yum install rpcbind
 
经过这样处理就可以了。
-bash-3.2# service nfs start
Starting NFS services:                                     [ OK ]
Starting NFS quotas:                                       [ OK ]
Starting NFS daemon:                                       [ OK ]
Starting NFS mountd:                                       [ OK ]
 
接着我们配置要导出的目录,修改/etc/exports文件:
 
这个文件的内容非常简单,每一行由抛出路径,客户名列表以及每个客户名后紧跟的访问选项构成:
 
        [共享的目录] [主机名或IP(参数,参数)]
 
其中参数是可选的,当不指定参数时,nfs将使用默认选项。默认的共享选项是 sync,ro,root_squash,no_delay。
 
当主机名或IP地址为空时,则代表共享给任意客户机提供服务。
 
当将同一目录共享给多个客户机,但对每个客户机提供的权限不同时,可以这样:
 
        [共享的目录] [主机名1或IP1(参数1,参数2)] [主机名2或IP2(参数3,参数4)]
 
下面是一些NFS共享的常用参数:
        ro                      只读访问
        rw                      读写访问
        sync                    所有数据在请求时写入共享
        async                   NFS在写入数据前可以相应请求
        secure                  NFS通过1024以下的安全TCP/IP端口发送
        insecure                NFS通过1024以上的端口发送
        wdelay                  如果多个用户要写入NFS目录,则归组写入(默认)
        no_wdelay               如果多个用户要写入NFS目录,则立即写入,当使用async时,无需此设置。
        hide                    在NFS共享目录中不共享其子目录
        no_hide                 共享NFS目录的子目录
        subtree_check           如果共享/usr/bin之类的子目录时,强制NFS检查父目录的权限(默认)
        no_subtree_check        和上面相对,不检查父目录权限
        all_squash              共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
        no_all_squash           保留共享文件的UID和GID(默认)
        root_squash             root用户的所有请求映射成如anonymous用户一样的权限(默认)
        no_root_squash           root用户具有根目录的完全管理访问权限
        anonuid=xxx             指定NFS服务器/etc/passwd文件中匿名用户的UID
        anongid=xxx             指定NFS服务器/etc/passwd文件中匿名用户的GID
 
由于我们的NFS仅仅用于嵌入式系统的开发,因而配置为:
/work/nfs       *(rw,sync,no_root_squash)
 
这样在启动nfs服务后就可以看到nfs的目录了:
-bash-3.2# showmount -e localhost
Export list for localhost:
/work/nfs *
 
Samba服务
我们虽然可以通过cofs服务在coLinux中访问win7下的文件,但WIN7的文件系统毕竟是不分大小写的,为此希望将代码存放在coLinux的磁盘上,再通过colinux上的samba服务让WIN7对这些文件进行访问。
在下载的根文件系统中默认没有samba,因而首先需要
yum install samba
进行安装。
接着修改/etc/samba/smb.conf,将/work目录共享给WIN7。
Tftp服务
当调试uC/linux内核时,通常通过TFTP下载,因而我们还需要安装xinetd和tftp-server:
yum install xinetd
yum install tftp-server
接着修改/etc/xinetd.d/tftp,启动tftp服务:
# default: off
# description: The tftp server serves files using the trivial file transfer /
#       protocol. The tftp protocol is often used to boot diskless /
#       workstations, download configuration files to network-aware printers, /
#       and to start the installation process for some operating systems.
service tftp                                                                                       
{
socket_type     = dgram
protocol            = udp
wait                   = yes
user                  = root
server               = /usr/sbin/in.tftpd
server_args     = -s /var/lib/tftpboot
disable             = no
per_source     = 11
cps                   = 100 2
flags                 = IPv4
}                                                                                                   
 
ftp服务
FTP服务并不是特别必要,因为通常在调试用户程序时会使用nfs挂接到Linux主机上,直接在NFS系统上运行用户程序。但是对于一些内存受限的系统,比如32M,可能根本无法使用NFS服务,这时就只能借助FTP服务下载程序并执行。
yum install vsftpd
接着根据需要修改/etc/vsftpd/vsftpd.conf。
 
服务配置至此完成。

 

(快乐虾)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201107/14722.html]
本文出处:CSDN博客 作者:快乐虾
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容