Share files between servers when user “oracle” has different UIDs

If you need to read and write files between servers where the UID of the oracle user is different, the easiest, working solution is with Samba. First, I have tried with NFSv4. After wasting a day with that, I found out it actually doesn’t work because of a lower layer, the RPC mapping. It still sends numeric UIDs instead of strings.

Samba can be configured easily to overcome this, so you will be able to read and write files as user “oracle”, even with different UIDs, on both server and client. I tested this on SUSE Enterprise Server 11, but the method is generic, for any Linux distribution. The configuration tokens that must be identical have the same colors in the next paragraphs.

Server

  • install samba, if you don’t already have it. As root:
    zypper install samba
  • edit /etc/samba/smb.conf
    [global]
            workgroup = WORKGROUP
            passdb backend = tdbsam
            printing = cups
            printcap name = cups
            printcap cache time = 750
            cups options = raw
            map to guest = Bad User
            include = /etc/samba/dhcp.conf
            logon path = \\%L\profiles\.msprofile
            logon home = \\%L\%U\.9xprofile
            logon drive = P:
            usershare allow guests = Yes
    [oracle_share]
            comment = Oracle Share
            path = /opt/oracle/some/directoryname
            valid users = oracle
            hosts allow = clientIP1, clientIP2
            read only = no
    
  • add oracle user to Samba, note the password
    smbpasswd -a oracle
  • start the service and enable it
    /etc/init.d/smb start
    chkconfig --add smb
  • verify that it works
    smbclient -L //servername -W workgroup -U oracle%password

    Should display something like this:

    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-0.58.1-3399-SUSE-CODE11-x86_64]
    
    Sharename Type Comment
    --------- ---- -------
    IPC$ IPC IPC Service (Samba 3.6.3-0.58.1-3399-SUSE-CODE11-x86_64)
    oracle_share Disk Oracle share
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-0.58.1-3399-SUSE-CODE11-x86_64]
    
    Server Comment
    --------- -------
    
    Workgroup Master
    --------- -------

Client

The nicest way is to configure it with automount.

  • make a directory
    mkdir -p /mnt/automount/servername
  • edit /etc/auto.master
    /mnt/automount/servername /etc/auto.servername
  • edit /etc/auto.servername
    oracle_share -fstype=cifs,username=oracle,password=password,uid=oracle,gid=oinstall ://servername/oracle_share
  • start the service and enable it
    /etc/init.d/autofs start
    chkconfig --add autofs
  • verify that it works. As user oracle:
    ls /mnt/automount/servername/oracle_share
    touch /mnt/automount/servername/oracle_share/testfile
    
  • make a symlink where you actually need the directory
    cd /opt/oracle/need/it/here
    ln -s /mnt/automount/servername/oracle_share/somename
    
Advertisements