Monday, 18 December 2017

Configure samba to share oracle files with Windows server

Environment: CentOS/Windows Machine

Configure following on linux server with Oracle database.


Add os group for samba
groupadd smbgrp

Create Linux OS user with useradd command. In my case I am adding user ajay and setting password using command passwd.
useradd ajay -G smbgrp
passwd ajay


Create directory that will be shared with Windows server.  I am using this directory to store my oracle dump files which will be shared with my Windows Server. Owner and group of this folder have permission of read, write and execute. If you do not need write permission to group then you may use chmod 750 instead of 770.
mkdir /u01/app/oracle/dumpdir
chmod 770 /home/oracle/dumpdir
chown oracle:smbgrp /u01/app/oracle/dumpdir



Create oracle directory with SQL command below. Oracle directory object need to be created which will point to OS directory. We will use this directory object name while using expdp.
create directory dir_dump as '/u01/app/oracle/dumpdir';



If samba linux package is not installed then install samba package and its dependency with yum command.
yum install samba -y



Use smbpasswd command to configure username and password that will be used to access the share directory. Note you can use different password from the password used for OS user ajay. 
smbpasswd -a ajay


Open samba configuration file with editor to configure samba.
vi /etc/samba/smb.conf


Change workgroup to your existing workgroup 
workgroup = WORKGROUP


Add following samba configuration parameters at the end of the configuration files.
[Share]
path=/u01/app/oracle/dumpdir
valid users=ajay
read only=yes
public=no
writable=no
valid host=192.168.100.44



Explanation:
[Share] Share directory name that will be visible to the user
path OS location of the directory we are sharing
valid users list of the trusted users. The user need to supply password to authenticate 
read only defines the shared directory is read only or read write.
public defines this shared directory is publicly available or not. If the value is set to yet then username/password will not be prompted while accessing shared directory.
writable defines the share directory is writeable or not 
valid host list of the trusted hosts that have access on share directory.

Restart samba service to reflect the configuration added.
/etc/init.d/smb restart



Now export dump from the database server, make sure that shared directory is used
expdp system directory=dir_dump dumpfile=system.dmp logfile=system.log schemas=system

    .....................

Windows host

Now open Windows server with the IP address specified above. If my case my windows machine's IP address is 192.168.100.44. Only this machine has access to this share directory.

Type \\192.168.100.101  on run or \\hostname of linux. You may also click on network which will list the name of the linux server.



Since public=no is set on configuration, you will be prompt for the password. Please provide the samba user and the password for samba server. In my case I am using ajay as the user and the passwod that I have provided with smbpasswd.


Now we can easily access the dump files created on the shared directory of Linux server.





Harry

Author & Editor

A technology enthusiast and addictive blogger who likes to hacking tricks and wish to be the best White Hacket Hacker of the World.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.