[oracle@dbserver data]$ mkdir oracle
mkdir: cannot create directory ‘oracle’: Permission denied
[oracle@dbserver data]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.7G 0 4.7G 0% /dev
tmpfs 4.7G 0 4.7G 0% /dev/shm
tmpfs 4.7G 13M 4.7G 1% /run
tmpfs 4.7G 0 4.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 89G 9.2G 80G 11% /
/dev/sda1 1014M 185M 830M 19% /boot
192.168.133.195:/data 20G 32M 20G 1% /nfs/data
tmpfs 959M 12K 959M 1% /run/user/42
tmpfs 959M 0 959M 0% /run/user/0
[oracle@dbserver data]$ pwd
/nfs/data
如上所示:oracle用户在共享目录下无法写,以下实现客户端NFS挂载的目录非root用户也能读写.
1.2、所有用户如果需要允许所有用户具有读写权限,服务器端修改共享目录的基础权限为777即可.
服务器端
[root@prometheus /]# mkdir /backup/
[root@prometheus /]# chmod 777 /backup/
[root@prometheus backup]# vi /etc/exports
/backup 192.168.133.191/24(rw,sync)
[root@prometheus /]# exportfs -r
客户端
[root@dbserver mnt]# mount 192.168.133.190:/backup /mnt/backup
说明:经测试rman备份可以存放在此目录中.
1.3、唯一用户说明:客户端root挂载,使用user1用户(uid :1000)访问,在NFS服务端识别uid为1000 的用户访问,如果服务器端有对应的uid,则映射为对应用户,即:如果服务端uid 1000对应为testuser1,则最后客户端user1所对应的权限实际为服务端testuser1的权限.
1.3.1、客户端用户客户端创建与服务器端相同UID的用户.
服务器端
[root@prometheus /]# cat /etc/exports
/rmanbak 192.168.133.191/24(rw,sync)
[root@prometheus /]# exportfs -r
[root@prometheus /]# chown -R oracle:oinstall /rmanbak
[root@prometheus /]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba),1003(oper)
客户端
[root@dbserver mnt]# mkdir /mnt/rmanbak
[root@dbserver mnt]# mount 192.168.133.190:/rmanbak /mnt/rmanbak
[root@dbserver mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.7G 0 4.7G 0% /dev
tmpfs 4.7G 0 4.7G 0% /dev/shm
tmpfs 4.7G 13M 4.7G 1% /run
tmpfs 4.7G 0 4.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 89G 30G 60G 33% /
/dev/sda1 1014M 185M 830M 19% /boot
tmpfs 959M 0 959M 0% /run/user/1100
tmpfs 959M 12K 959M 1% /run/user/42
tmpfs 959M 0 959M 0% /run/user/0
tmpfs 959M 0 959M 0% /run/user/1101
192.168.133.190:/rmanbak 119G 24G 96G 20% /mnt/rmanbak
注意:此时在客户端创建一个uid为1001的用户
[root@dbserver home]# useradd -u 1001 -g oinstall -G dba,oper,asmdba leo
[root@dbserver home]# su - leo
[leo@dbserver ~]$ cd /mnt/rmanbak
[leo@dbserver rmanbak]$ touch hello.txt
[leo@dbserver rmanbak]$ ll
total 0
-rw-r--r-- 1 leo oinstall 0 Aug 29 15:11 hello.txt
[leo@dbserver rmanbak]$ id leo
uid=1001(leo) gid=1030(oinstall) groups=1030(oinstall),1031(dba),1032(oper),1021(asmdba)
[grid@dbserver rmanbak]$ touch hello1.txt
touch: cannot touch ‘hello1.txt’: Permission denied
结论:用户leo可以在共享目录写,而grid用户不能.
1.3.2、服务端用户现在实现在服务器端创建与客户端oracle相同uid的用户liujun,到时建立一个目录划分给用户liujun用于客户端的rman备份.
服务器端
[root@prometheus home]# useradd -u 1101 -g oinstall -G dba,oper liujun
[root@prometheus home]# chown -R liujun:oinstall /rmanbak
[root@prometheus home]# vi /etc/exports
[root@prometheus home]# cat /etc/exports
/rmanbak 192.168.133.191/24(rw,sync)
[root@prometheus home]# exportfs -r
客户端
[root@dbserver home]# mkdir -p /mnt/rmanbak
[root@dbserver home]# mount 192.168.133.190:/rmanbak /mnt/rmanbak
[oracle@dbserver rmanbak]$ touch hello.txt
[oracle@dbserver rmanbak]$ ll
total 0
-rw-r--r-- 1 oracle oinstall 0 Aug 29 15:19 hello.txt
现在执行rman备份
RMAN> backup as compressed backupset full database format '/mnt/rmanbak/2dbf_%d_%u_%p_%s' plus archivelog format '/mnt/rmanbak/3arc_%d_%u_%p_%s' delete all input;
结果:rman备份可存放在NFS挂载的共享目录中,也就实现rman远端存储的备份.