linux如何挂载samba目录

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux如何挂载samba目录相关的知识,希望对你有一定的参考价值。

linux下挂载samba目录时提示:mounting //192.168.×××.×××/XXXX on /mnt/ failed: Can not access a needed shared library.其中XXXX已经设置为共享,允许用户读写。
mount -t cifs //192.168.***.***/XXXX /mnt/ -o username=***,password=******,iocharset=utf-8

1、utf-8替换成utf8试试
2、其他方法
i)如果已经安装samba,可用smbmount
例:smbmount //192.168.1.1/share /mnt
-o username=user,password=pw,iocharset=utf8,codepage=cp936
ii)mount.cifs等效于mount -t cifs,mount.cifs需要内核支持,使用时比较方便。
例:mount.cifs //192.168.1.1/somedir dir -o username=xx,password=xxxx
iii)mount.smbfs需要注意中文目录,需要加上 参数 codepage=cp936,iocharset=utf8,而且有的系统下挂载速度迟钝。等效于smbmount或 mount -t smbfs
例:mount.smbfs //192.168.1.1/somedir dir -o username=xx,password=xxxx
iv)smbclient登录后操作类似于ftp登录
例:smbclient //192.168.1.1/d -U username%password
参考技术A 环境:
Windows 2008 R2+RHEL6U2

说明:
在配置oracle
expdp备份策略时,发现服务器上的空间有限,公司也不想增加这方面的开支,因此想到了将windows应用服务器上富裕的空间拿来做为oracle的
备份磁盘,在备份时将备份文件保存到服务器和windows共享目录里面,而服务器空间有限只保留近半个月的备份,windows磁盘则保留更长的时间。

操作步骤:1,在windows 2008上共享一个目录,并对这个目录设置相应的用户访问权限,在这里共享目录为“share”,windows用户为test,口令为test ,权限为读写。
2,远程登录rhel终端,备份好/etc/fstab后,在/etc/fstab文件后面加上这行:
################
//192.168.2.173/share /mnt/share cifs defaults,uid=1000,gid=1000,credentials=/etc/samba/x1 0 0

#//192.168.2.173/share 这段为windows的IP和共享目录,/mnt/share为rhel的挂载点,
cifs为文件系统类型,uid、gid为rhel的用户和组id,这里设置了oracle和oinstall,它们的id都是
1000,credentials=/etc/samba/x1 credentials参数对应windows的用户名和口令文件x1,其它为默认值。

3,windows的用户名和口令保存文件
[root@dba ~]# cat /etc/samba/x1
username=test
password=test

[oracle@dba1 ~]# ls -dl /mnt/share
drwxr-xr-x 1 oracle oinstall 4096 Dec 30 15:29 /mnt/share

Linux系统Centos7系统下挂载samba共享

【Linux系统】Centos7系统下挂载samba共享

一、Samba服务介绍

Samba是一套使用SMB(Server Message Block)协议的应用程序, 通过支持这个协议, Samba允许Linux服务器与Windows系统之间进行通信,使跨平台的互访成为可能。Samba采用C/S模式, 其工作机制是让NetBIOS( Windows 网上邻居的通信协议)和SMB两个协议运行于TCP/IP通信协议之上,并且用NetBEUI协议让Windows在“网上邻居”中能浏览Linux服务器。

二、配置yum仓库

1.配置阿里云的yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2.检查yum仓库状态

[root@server ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                                                   repo name                                                                                      status
C7.0.1406-base/x86_64                                                     CentOS-7.0.1406 - Base                                                                         disabled
C7.0.1406-centosplus/x86_64                                               CentOS-7.0.1406 - CentOSPlus                                                                   disabled
C7.0.1406-extras/x86_64                                                   CentOS-7.0.1406 - Extras                                                                       disabled
C7.0.1406-fasttrack/x86_64                                                CentOS-7.0.1406 - Fasttrack                                                                    disabled
C7.0.1406-updates/x86_64                                                  CentOS-7.0.1406 - Updates                                                                      disabled
C7.1.1503-base/x86_64                                                     CentOS-7.1.1503 - Base                                                                         disabled
C7.1.1503-centosplus/x86_64                                               CentOS-7.1.1503 - CentOSPlus                                                                   disabled
C7.1.1503-extras/x86_64                                                   CentOS-7.1.1503 - Extras                                                                       disabled
C7.1.1503-fasttrack/x86_64                                                CentOS-7.1.1503 - Fasttrack                                                                    disabled
C7.1.1503-updates/x86_64                                                  CentOS-7.1.1503 - Updates                                                                      disabled
C7.2.1511-base/x86_64                                                     CentOS-7.2.1511 - Base                                                                         disabled
C7.2.1511-centosplus/x86_64                                               CentOS-7.2.1511 - CentOSPlus                                                                   disabled
C7.2.1511-extras/x86_64                                                   CentOS-7.2.1511 - Extras                                                                       disabled
C7.2.1511-fasttrack/x86_64                                                CentOS-7.2.1511 - Fasttrack                                                                    disabled
C7.2.1511-updates/x86_64                                                  CentOS-7.2.1511 - Updates                                                                      disabled
C7.3.1611-base/x86_64                                                     CentOS-7.3.1611 - Base                                                                         disabled
C7.3.1611-centosplus/x86_64                                               CentOS-7.3.1611 - CentOSPlus                                                                   disabled
C7.3.1611-extras/x86_64                                                   CentOS-7.3.1611 - Extras                                                                       disabled
C7.3.1611-fasttrack/x86_64                                                CentOS-7.3.1611 - Fasttrack                                                                    disabled
C7.3.1611-updates/x86_64                                                  CentOS-7.3.1611 - Updates                                                                      disabled
C7.4.1708-base/x86_64                                                     CentOS-7.4.1708 - Base                                                                         disabled
C7.4.1708-centosplus/x86_64                                               CentOS-7.4.1708 - CentOSPlus                                                                   disabled
C7.4.1708-extras/x86_64                                                   CentOS-7.4.1708 - Extras                                                                       disabled
C7.4.1708-fasttrack/x86_64                                                CentOS-7.4.1708 - Fasttrack                                                                    disabled
C7.4.1708-updates/x86_64                                                  CentOS-7.4.1708 - Updates                                                                      disabled
C7.5.1804-base/x86_64                                                     CentOS-7.5.1804 - Base                                                                         disabled
C7.5.1804-centosplus/x86_64                                               CentOS-7.5.1804 - CentOSPlus                                                                   disabled
C7.5.1804-extras/x86_64                                                   CentOS-7.5.1804 - Extras                                                                       disabled
C7.5.1804-fasttrack/x86_64                                                CentOS-7.5.1804 - Fasttrack                                                                    disabled
C7.5.1804-updates/x86_64                                                  CentOS-7.5.1804 - Updates                                                                      disabled
!appnode/x86_64                                                           AppNode's RPM repository for Enterprise Linux 7 - x86_64                                       enabled:  4,266
!appnode-agent/x86_64                                                     AppNode Agent Repository - x86_64                                                              enabled:    332
appnode-agent-archive/x86_64                                              AppNode Agent Repository - x86_64                                                              disabled
appnode-agent-development/x86_64                                          AppNode Agent Repository - x86_64                                                              disabled
appnode-archive/x86_64                                                    AppNode's RPM repository for Enterprise Linux 7 - x86_64                                       disabled
!appnode-ccenter/x86_64                                                   AppNode CCenter Repository - x86_64                                                            enabled:     71
appnode-ccenter-archive/x86_64                                            AppNode CCenter Repository - x86_64                                                            disabled
appnode-ccenter-development/x86_64                                        AppNode CCenter Repository - x86_64                                                            disabled
appnode-development/x86_64                                                AppNode's RPM repository for Enterprise Linux 7 - x86_64                                       disabled
!appnode-extras/x86_64                                                    AppNode Extras Repository - x86_64                                                             enabled:     88
appnode-extras-archive/x86_64                                             AppNode Extras Repository - x86_64                                                             disabled
appnode-extras-development/x86_64                                         AppNode Extras Repository - x86_64                                                             disabled
!base/7/x86_64                                                            CentOS-7 - Base - mirrors.aliyun.com                                                           enabled: 10,072
base-debuginfo/x86_64                                                     CentOS-7 - Debuginfo                                                                           disabled
base-source/7                                                             CentOS-7 - Base Sources                                                                        disabled
c7-media                                                                  CentOS-7 - Media                                                                               disabled
centosplus/7/x86_64                                                       CentOS-7 - Plus - mirrors.aliyun.com                                                           disabled
centosplus-source/7                                                       CentOS-7 - Plus Sources                                                                        disabled
contrib/7/x86_64                                                          CentOS-7 - Contrib - mirrors.aliyun.com                                                        disabled
cr/7/x86_64                                                               CentOS-7 - cr                                                                                  disabled
docker-ce-nightly/7/x86_64                                                Docker CE Nightly - x86_64                                                                     disabled
docker-ce-nightly-debuginfo/7/x86_64                                      Docker CE Nightly - Debuginfo x86_64                                                           disabled
docker-ce-nightly-source/7                                                Docker CE Nightly - Sources                                                                    disabled
!docker-ce-stable/7/x86_64                                                Docker CE Stable - x86_64                                                                      enabled:    163
docker-ce-stable-debuginfo/7/x86_64                                       Docker CE Stable - Debuginfo x86_64                                                            disabled
docker-ce-stable-source/7                                                 Docker CE Stable - Sources                                                                     disabled
docker-ce-test/7/x86_64                                                   Docker CE Test - x86_64                                                                        disabled
docker-ce-test-debuginfo/7/x86_64                                         Docker CE Test - Debuginfo x86_64                                                              disabled
docker-ce-test-source/7                                                   Docker CE Test - Sources                                                                       disabled
!epel/x86_64                                                              Extra Packages for Enterprise Linux 7 - x86_64                                                 enabled: 13,757
epel-debuginfo/x86_64                                                     Extra Packages for Enterprise Linux 7 - x86_64 - Debug                                         disabled
epel-source                                                               Extra Packages for Enterprise Linux 7 - x86_64 - Source                                        disabled
!extras/7/x86_64                                                          CentOS-7 - Extras - mirrors.aliyun.com                                                         enabled:    512
extras-source/7                                                           CentOS-7 - Extras Sources                                                                      disabled
fasttrack/7/x86_64                                                        CentOS-7 - fasttrack                                                                           disabled
!updates/7/x86_64                                                         CentOS-7 - Updates - mirrors.aliyun.com                                                        enabled:  4,050
updates-source/7                                                          CentOS-7 - Updates Sources                                                                     disabled

三、安装samba客户端

1.安装samba-client

yum install -y samba-client

2.查看共享状态

[root@server ~]# smbclient -L 192.168.3.100
Enter SAMBA\\root's password: 
Anonymous login successful

	Sharename       Type      Comment
	---------       ----      -------
	share           Disk      
	IPC$            IPC       IPC Service (Samba 4.5.16-Debian)
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful

	Server               Comment
	---------            -------

	Workgroup            Master
	---------            -------

四、Linux配置samba服务器

Linux下的samba服务配置详解

家庭NAS搭建实战之samba共享

五、Linux挂载Samba

1.安装相关软件包

yum install  -y nfs-utils  cifs-utils 

2.创建挂载目录

mkdir -p /samba/data

3.挂载samba

mount -t cifs //192.168.3.100/data/NAS/nas /samba/data  -o username=admin,password=123123

3.查看挂载状态

[root@servert ~]# df -h |grep samba
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root     17G  1.2G   16G   7% /
 //192.168.3.100/data/NAS/nas  17G  1.2G   16G   7%  /samba/data

以上是关于linux如何挂载samba目录的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统Centos7系统下挂载samba共享

linux下实现文件共享:搭建samba服务器

Linux使用mount挂载samba共享文件夹

samba共享目录多台主机挂载,搭建WordPress

如何配置/etc/fstab或autofs让系统去自动挂载Samba共

linux搭建smb挂载smbWindows共享