linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
[root@localhost ~]$ su root #切换到root [root@localhost ~]# groupadd oinstall #创建用户组oinstall [root@localhost ~]# groupadd dba #创建用户组dba [root@localhost ~]# useradd -g oinstall -g dba -m oracle
#创建oracle用户,并加入到oinstall和dba用户组 [root@localhost ~]# passwd oracle
#设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆 Changing password for user oracle. New password: # 密码 BAD PASSWORD: The password is shorter than 8 characters Retype new password: # 确认密码 passwd: all authentication tokens updated successfully. [root@localhost ~]# id oracle # 查看新建的oracle用户 uid=1001(oracle) gid=1002(dba) groups=1002(dba)
为什么要创建oinstall和dba用户组?
参考:http://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-2-092412-zhs.html#13
a.oracle 清单组(一般为oinstall): OINSTALL 组的成员被视为 Oracle 软件的“所有者”,拥有对 Oracle 中央清单 (oraInventory) 的写入权限。在一个 Linux 系统上首次安装 Oracle 软件时, OUI 会创建 /etc/oraInst.loc 文件。该文件指定 Oracle 清单组的名称(默认为 oinstall)以及 Oracle 中央清单目录的路径。 b.数据库管理员(OSDBA,一般为 dba): OSDBA 组的成员可通过操作系统身份验证使用 SQL 以 SYSDBA 身份连接到一个 Oracle 实例。该组的成员可执行关键的数据库管理任务,如创建数据库、启动和关 闭实例。该组的默认名称为dba。SYSDBA 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。不要混淆 SYSDBA 系统权限与数据库角色 DBA。DBA 角色不包括 SYSDBA 或 SYSOPER 系统权限。 c.数据库操作员组(OSOPER,一般为 oper): OSOPER 组的成员可通过操作系统身份验证使用 SQL 以 SYSOPER 身份连接到一个 Oracle 实例。这个可选组的成员拥有一组有限的数据库管理权限,如管理和运行备份。 该组的默认名称为oper。SYSOPER 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。要使用该组,选择 Advanced 安装类型来安装 Oracle 数据库软件。
[root@localhost ~]# mkdir -p /oracle/data/oracle #oracle数据库安装目录 [root@localhost ~]# mkdir -p /oracle/data/oraInventory #oracle数据库配置文件目录 [root@localhost ~]# mkdir -p /oracle/data/database #oracle数据库软件包解压目录 [root@localhost ~]# chown -R oracle:oinstall /oracle/data/oracle
#设置目录所有者为oinstall用户组的oracle用户 [root@localhost ~]# chown -R oracle:oinstall /oracle/data/oraInventory [root@localhost ~]# chown -R oracle:oinstall /oracle/data/database
oracle默认不支持CentOS系统安装,Oracle Database 11g Release 2 的 OS要求参考:
https://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#LADBI1106
我安装是64位数据库,On Linux x86-64:Red Hat Enterprise linux 7 (RHEL 7)
另外,CentOS7.0.1511 基于 RHEL7.2 参考:http://www.linuxidc.com/Linux/2015-12/126283.htm
修改文件 /etc/RedHat-release
[root@localhost data]# cat /proc/version Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015 [root@localhost data]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@localhost data]# vi /etc/redhat-release [root@localhost data]# cat /etc/redhat-release redhat-7
yum install -y binutils* yum install -y compat-libstdc* yum install -y elfutils-libelf* yum install -y gcc* yum install -y glibc* yum install -y ksh* yum install -y libaio* yum install -y libgcc* yum install -y libstdc* yum install -y make* yum install -y sysstat* yum install libXp* -y yum install -y glibc-kernheaders
[root@localhost /]# systemctl status firewalld.service #查看防火墙状态,运行中 [root@localhost /]# systemctl stop firewalld.service #关闭防火墙 [root@localhost /]# systemctl disable firewalld.service #禁止使用防火墙(重启也是禁止的)
[root@localhost /]# vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled #此处修改为disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
使配置参数生效
[root@localhost /]# sysctl -p9.配置用户的环境变量(红色部分为添加代码)
[root@localhost /]# vi /home/oracle/.bash_profile [root@localhost /]# cat /home/oracle/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH export ORACLE_BASE=/data/oracle #oracle数据库安装目录 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle数据库路径 export ORACLE_SID=orcl #oracle启动数据库实例名 export ORACLE_TERM=xterm #xterm窗口模式安装 export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量 export LANG=C #防止安装过程出现乱码 export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致,如:ZHS16GBK,否则出现数据导入导出中文乱码问题 [root@localhost /]#[oracle@localhost ~]$ unzip linux.x64_11gR2_database_1of2.zip -d /oracle/data/database/ #解压 [oracle@localhost ~]$ unzip linux.x64_11gR2_database_2of2.zip -d /oracle/data/database/ #解压 [root@localhost ~]# chown -R oracle:oinstall /oracle/data/database/database/