zoukankan      html  css  js  c++  java
  • Samba文件服务器安装配置

    很久都没有更新博客了,人要学好难,跟着学坏容易,这个其实是我一直以来不明白的地方。如果,能反过来,应该是很多人求之不得的美事吧。说远了,我就是这种一放松下来,就容易堕落的一份子。

    最近也是工作的原因,需要在liunx上安装samba文件共享服务器,这样就可以通过samba服务器使liunx与Windows进行文件共享,当然samba文件共享服务器的作用远不止这个,大家有兴趣的话可以自行网上查资料。

    眼高手低是很多人的通病,我是深受其害。很多东西,看起来容易,实操起来到处什么都不会或者都出是问题。作为程序员更是不能有这种态度,一定从小做起,实干记忆才更加深刻。这次安装samba服务器更是让我体会很深,折腾了很久,网上的资料也不是很全面。所以,我应该把它记录下来。

    第一、好记性不如烂笔头,防止以后自己忘记,到时候又是一头凌乱的找资料
    第二、分享自己的经验,或许能帮助一些正处在凌乱的找资料的童鞋

    废话不多上,老板上菜

    在准备安装之前你可以查看下自己的liunx的系统版本以及系统类型,以便准备相应的版本软件

    1.查看内核版本详细信息,包括主机名称

    1 # uname -a 

    安装有两种方式:

    1.rpm命令安装。 rpm -ivh 安装包
    这种方式一般都是通过 mount 挂载安装包镜像

    2.yum命令安装。我这里演示的就是这种方式
    这种方式请确保虚拟机能和本机联网,能相互ping的通就OK。

    一、环境准备:

    • CentOS 6.2版本(32位)
    • IP地址:192.168.153.66(虚拟机);
    • 虚拟机:VMware-workstation-full-8.0.0-471780;
    • samba软件:samba-3.6.23-20.el6.i686;
    • 工作组:WORKGROUP。//定义windows中显示出来的计算机名称

    二、安装软件

    1.执行如下命令安装samba:

    1 # yum install samba samba-client samba-swat

    2.检查samba是否安装成功:

    1 # rpm -qa | grep samba

    samba的安装目录一般在 /etc/samba

    3.启动samba服务及状态检查:

    # /etc/init.d/smb start

    4.设置开机自启动,并查看是否设置成功:

    --设置

    # chkconfig –level 35 smb on
    # chkconfig –level 35 nmb on

    --查看

    # chkconfig –list | grep smb

    三、服务配置

    Samba服务配置主要是指/etc/samba/smb.conf文件的配置。

    我在这里只演示一种最简单的共享方式(不需要用户名、密码即可访问),至于其它的配置可以点击(更多方式)进行参考配置。

    1.把配置文件重定向到一个文件,并且备份smb.conf的源文件

    1 # grep -v "^[#;]" smb.conf | grep -v "^$" >> smb.conf.txt
    2 # cp smb.conf smb.conf.copy
    3 # mv smb.conf.txt smb.conf

    2.修改samba服务器的主配置文件smb.conf

     1 [global]
     2 
     3         workgroup = WORKGROUP
     4         server string = Samba Server Version %v
     5         netbios name = VMQiheng
     6 
     7         # logs split per machine
     8         log file = /var/log/samba/log.%m
     9         # max 50KB per log file, then rotate
    10         max log size = 50
    11 
    12         # max 50KB per log file, then rotate
    13         max log size = 50
    14 
    15         security = share
    16         passdb backend = tdbsam
    17 
    18         # the login script name depends on the machine name
    19         # the login script name depends on the unix user used
    20         # disables profiles support by specifing an empty path
    21 
    22         load printers = yes
    23         cups options = raw
    24         #obtain list of printers automatically on SystemV
    25 
    26 [homes]
    27         comment = Home Directories
    28         browseable = no
    29         writable = yes
    30 
    31 [printers]
    32         comment = All Printers
    33         path = /var/spool/samba
    34         browseable = no
    35         guest ok = no
    36         writable = no
    37         printable = yes
    38 
    39 [beyond]
    40         comment = Public share with beyond file
    41         path = /share
    42         public = yes
    43         writable = yes

    以上是我的samba服务器的conf设置,在配置文件里我添加了 [beyond] 这个节点,分享目录在liunx的根目录下的 share 文件夹

    2.1.创建分享目录

    # mkdir share

    2.2.给分享目录授权为nobody权限

    # chown -R nobody:nobody /share

    3.重启smb服务:

    1 # /etc/init.d/smb restart
    2 # /etc/init.d/nmb restart

    如果配置成功的话,就可以通过 liunx ip 访问到这个共享文件夹

    [beyond] 就是我配置在Windows可以访问的共享目录。

    可能出现的问题。

    1.如果用windows上访问linux的共享目录,如,//192.168.100.88 ,根本找不到。

    关闭linux的防火墙:
    # service iptables stop。

     2.可以看到共享文件夹,却没打不开文件夹(左图)或者在liunx中通过 # smbclient //127.0.0.1/beyond(右图)

    (左图) (右图)

     这种情况,一般都是被SELinux阻挡了,你可以使用getenforce查看状态,如果是Enforcing,就使用setenforce 0关闭。

     

     不过,我的liunx在下次开机的时候,windows上访问 liunx ip,还是需要出现上诉两个问题,我还得重新再设置一遍,好麻烦,不知道其熟悉liunx的朋友知不知道这是什么情况,欢迎留言指教。

    到这里,samba服务器总算是安装成功了。对于我liunx菜鸟真的是一种折腾。希望这对你有帮助,帮助了你的解决问题的请不要吝惜点赞,我才更加有动力整理总结。

     四、参考资料

     http://www.centoscn.com/CentosServer/ftp/2013/1126/2149.html

    http://www.fwqtg.net/centos%E5%AE%89%E8%A3%85samba%E6%96%87%E4%BB%B6%E6%9C%8D%E5%8A%A1%E5%99%A8.html (安装)

    http://blog.csdn.net/fyh2003/article/details/7280119 (访问权限设置)

  • 相关阅读:
    【ST】lab01——Junit and Eclemma
    【SPM】hw1——个人房间装修
    【ST】hw2——find the error in the follow case
    【ST】Describe an error from my past projects
    ST homework4 --- 图覆盖
    ST lab1——Junit和覆盖测试的初探
    ST work12——failure,fault,error
    ST work1——印象最深的一个bug DJI 激活时报 SDK_ACTIVE_SDK_VERSION_ERROR
    C# note 06——delegate 和 event
    C# note 05——异常处理
  • 原文地址:https://www.cnblogs.com/qiheng/p/samba.html
Copyright © 2011-2022 走看看