在Linux系统中设置Oracle权限涉及多个步骤,包括创建用户、分配权限、修改系统配置等。以下是详细的操作指南:
创建用户组:
groupadd oinstall
groupadd dba
创建用户并加入到相应的组:
useradd -g dba -m oracle
usermod -a -G oinstall oracle
passwd oracle
修改 /etc/sysctl.conf 文件以优化系统性能:
fs.aio-max-nr 1048576
fs.file-max 6815744
kernel.shmmni 4096
kernel.sem 25032000 100 128
kernel.shmall 2097152
kernel.shmmax 2147483648
net.ipv4.ip_local_port_range 9000 65500
net.ipv4.icmp_echo_ignore_broadcasts 1
net.ipv4.conf.all.rp_filter 1
net.core.rmem_default 262144
net.core.rmem_max 4194304
net.core.wmem_default 262144
net.core.wmem_max 1048576
使配置生效:
sysctl -p
修改 /etc/security/limits.conf 文件以设置用户限制:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
修改 /etc/pam.d/login 文件:
vi /etc/pam.d/login
添加以下内容:
session required /lib/security/pam_limits.so
修改 /etc/profile 文件:
vi /etc/profile
添加以下内容:
if [ USER "oracle" ]; then
if [ SHELL "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
使 /etc/profile 更改立即生效:
source /etc/profile
使用 GRANT 语句为用户分配权限,例如:
grant connect, resource to test_user;
使用 REVOKE 语句撤销用户权限,例如:
revoke connect from test_user;
create role myrole;
grant create session to myrole;
grant myrole to zhangsan;