由于学习安装DB2软件(由于软件包存放在WINDOWS系统中),需要将DB2软件包拷贝到LINUX系统中,这时就需要建立LINUX与WINDOWS系统文件共享,在这里采用SAMBA服务或MOUNT挂载的方式进行文件共享(当然也可以采用FTP或其他方式)。
SAMBA配置
在该部分中主要是配置smb.conf文件内容以及添加smb用户。smb.conf位于LINUX文件目录/etc/samba中。
首先我们添加SMB用户,SMB用户首先必须是系统用户:
######################################################################
[root@localhost samba]# useradd db2inst1 #增加系统用户
[root@localhost samba]# passwd db2inst1 #修改密码
Changing password for user db2inst1.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost samba]# smbpasswd -a db2inst1 #增加SMB用户
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user db2inst1.
####################################################################
第二、创建需要共享的文件夹
####################################################################
[root@localhost mnt]#mkdir samba_share
[root@localhost samba]# ls /mnt
samba_share
[root@localhost samba]# chown nobody.nobody /mnt/samba_share #设置权限
####################################################################
第三、设置smb.conf
####################################################################
[root@localhost samba]# vi smb.conf
[global]
# workgroup = NT-Domain-Name or Workgroup-Name
workgroup = MYGROUP #定义工作组
# server string is the equivalent of the NT Description field
server string = Samba Server #服务器名
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
#; hosts allow = 192.168.1. 192.168.2. 127.
hosts allow = 172.20.50. 172.20.30.
#设置允许访问的网络段,这里是允许30和50段的IP访问
……………………….(其他省略)
[samba_share] #共享文件
comment = liutao's and db2inst1's
path = /mnt/samba_share #路径
valid users = liutao db2inst1 #用户
public = no
writable = yes #是否可写
printable = no
#######################################################################
第四、Samba测试
[root@localhost mnt]#testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[samba_share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
workgroup = MYGROUP
server string = Samba Server
log file = /var/log/samba/%m.log
max log size = 50
socket ptions = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printcap name = /etc/printcap
dns proxy = No
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
hosts allow = 172.20.50., 172.20.30.
cups ptions = raw
[homes]
comment = Home Directories
read nly = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No
[samba_share]
comment = liutao's and db2inst1's
path = /mnt/samba_share
valid users = liutao, db2inst1
read nly = No
guest k = Yes
重新启动SMB服务:
[root@localhost samba]#service smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
在WINDOWS系统共享进行访问共享目录://172.20.50.133
LINUX系统文件共享(访问主机也需要安装有SAMBA):
#####################################################################
[root@localhost mnt]# smbclient //172.20.50.79/myshare -U db2inst1
Password:
Domain=[D0736] S=[Unix] Server=[Samba 3.0.10-1.4E.6]
smb: \> pwd
Current directory is \\172.20.50.79\myshare\
smb: \> ls
. D 0 Mon Apr 26 15:42:53 2010
smb: \>
smb:\>get file #get可以将服务器共享目录中的指定文件下载
smb:\>put file #将文件上传到samba服务器中
[root@root/]#smbstatus #显示当前主机中的samba服务器的连接状态信息
[root@root/]#smbmount//172.20.50.79/myshare /mnt #将172.20.50.79/中myshare目录挂载到本地目录/mnt中
[root@root/]#umount/mnt #卸载共享目录
#####################################################################