Linux Centos 环境安装oracle

2024年 5月 11日 94.4k 0

ORACLE数据库 安装

Oracle Database 11g Release 2 (11.2.0.1.0) for Microsoft Windows (64-bit)
http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_database_1of2.zip
http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_database_2of2.zip
http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_client.zip
http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for Microsoft Windows (32-bit)
http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_database_1of2.zip
http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_database_2of2.zip
http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_client.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86
http://download.oracle.com/otn/linux/oracle11g/R2/linux_11gR2_database_1of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux_11gR2_database_2of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux_11gR2_client.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86-64
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_client.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for Solaris Operating System (SPARC) (64-bit)
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.sparc64_11gR2_database_1of2.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.sparc64_11gR2_database_2of2.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.sparc64_11gR2_client.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.sparc64_11gR2_client32.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.sparc64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for Solaris Operating System (x86-64)
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.x64_11gR2_database_1of2.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.x64_11gR2_database_2of2.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.x64_11gR2_client.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.x86_11gR2_client.zip
http://download.oracle.com/otn/solaris/oracle11g/R2/solaris.x64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for HP-UX Itanium
http://download.oracle.com/otn/hp/oracle11g/R2/hpia64_11gR2_database_1of2.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpia64_11gR2_database_2of2.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpia64_11gR2_client.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpia64_11gR2_client32.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpia64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for HP-UX PA-RISC (64-bit)
http://download.oracle.com/otn/hp/oracle11g/R2/hpux.parisc64_11gR2_database_1of2.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpux.parisc64_11gR2_database_2of2.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpux.parisc64_11gR2_client.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpux.parisc32_11gR2_client.zip
http://download.oracle.com/otn/hp/oracle11g/R2/hpux.parisc64_11gR2_grid.zip

Oracle Database 11g Release 2 (11.2.0.1.0) for AIX (PPC64)
http://download.oracle.com/otn/aix/oracle11g/R2/aix.ppc64_11gR2_database_1of2.zip
http://download.oracle.com/otn/aix/oracle11g/R2/aix.ppc64_11gR2_database_2of2.zip
http://download.oracle.com/otn/aix/oracle11g/R2/aix.ppc64_11gR2_client.zip
http://download.oracle.com/otn/aix/oracle11g/R2/aix.ppc32_11gR2_client.zip
http://download.oracle.com/otn/aix/oracle11g/R2/aix.ppc64_11gR2_grid.zip

1、上传文件到对应的虚拟目录
[root@localhost software]# cd /mnt
2、解压文件
[root@localhost software]# unzip linux.x64_11gR2_database_1of2.zip
[root@localhost software]# unzip linux.x64_11gR2_database_2of2.zip
将解压的结果文件夹拷贝至/software目录下
[root@localhost software]# mv database/ /software/
cd /software
3、关闭selinux
[root@localhost software]# vim /etc/selinux/config
SELINUX=disabled
编辑完成后执行 :setenforce 0
4、关闭防火墙
[root@localhost software]# cat /etc/redhat-release

[root@localhost software]# systemctl restart firewalld.service
[root@localhost software]# systemctl list-unit-files|grep firewalld.service
[root@localhost software]# systemctl disable firewalld.service

5、安装Oracle 11g依赖包
yum install gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y

6、添加安装用户和用户组
[root@localhost software]# groupadd oinstall
[root@localhost software]# groupadd dba
[root@localhost software]# useradd -g oinstall -G dba oracle
[root@localhost software]# passwd oracle
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 software]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

7、修改内核参数配置文件
[root@localhost software]# vim /etc/sysctl.conf
在末尾添加以下内容:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

查看是否成功写进/etc/sysctl.conf文件中:
[root@localhost software]# sysctl -p
其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte。

8、修改用户的限制文件
修改/etc/security/limits.conf文件:
[root@localhost software]# vim /etc/security/limits.conf
在末尾添加以下内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

修改/etc/pam.d/login文件:
[root@localhost software]# vim /etc/pam.d/login
在末尾添加以下内容:
session required /lib64/security/pam_limits.so
session required pam_limits.so

修改/etc/profile文件:
[root@ myYUn software]# vim /etc/profile
在末尾添加以下内容:
#oracle配置
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

9、创建安装目录和设置文件权限
[root@localhost software]# mkdir -p /data/oracle/product/11.2.0
[root@localhost software]# mkdir /data/oracle/oradata
[root@localhost software]# mkdir /data/oracle/inventory
[root@localhost software]# mkdir /data/oracle/fast_recovery_area
[root@localhost software]# chown -R oracle:oinstall /data/oracle
[root@localhost software]# chmod -R 775 /data/oracle

10、设置oracle用户环境变量
首先切换到oracle用户下:
[root@localhost software]# su -l oracle
[oracle@localhost ~]$ vim .bash_profile
在末尾添加如下内容:
ORACLE_BASE=/data/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

注意,ORACLE_SID 与创建的数据库实例名称一致,否则数据库启动后无法访问。第一次配置完记得source一下。
[oracle@localhost ~]$ source .bash_profile

11、编辑静默安装响应文件
复制安装文件夹response到当前oracle用户的家目录下:
[oracle@localhost ~]$ cp -R /software/database/response/ .
[oracle@localhost ~]$ cd response/
[oracle@localhost response]$ vim db_install.rsp
需要设置的选项如下:

oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=CentOS
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0
ORACLE_BASE=/data/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

12、根据响应文件静默安装Oracle11g
[oracle@localhost response]$ cd /software/database/
[oracle@localhost database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现Successfully Setup Software,则安装程序已经停止了。

 

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现Successfully Setup Software,则安装程序已经停止了。

按照要求执行脚本。
打开终端,退出到root身份登录,执行脚本:
[oracle@iZ2f570bi1k56uZ database]$ exit
logout
[root@iZ2f570bi1k56uZ software]# sh /data/oracle/inventory/orainstRoot.sh
Changing permissions of /data/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /data/oracle/inventory to oinstall.
The execution of the script is complete.
[root@iZ2f570bi1k56uZ software]# sh /data/oracle/product/11.2.0/root.sh
Check /data/oracle/product/11.2.0/install/root_iZ2f570bi1k56uZ_2018-05-13_14-25-04.log for the output of root script

13、以静默方式配置监听
重新使用oracle用户登录:
[root@localhost software]# su -l oracle
Last login: Sun May 13 14:09:10 CST 2020 on pts/3
[oracle@localhost ~]$ netca /silent /responseFile /home/oracle/response/netca.rsp

注意此处,必须使用/silent /responseFile格式,而不是-silent -responseFile,因为是静默安装。
成功运行后,在/data/oracle/product/11.2.0/network/admin中生成listener.ora和sqlnet.ora
通过netstat命令可以查看1521端口正在监听。

14、以静默方式建立新库,同时也建立一个对应的实例
[oracle@localhost ~]$ vim /home/oracle/response/dbca.rsp
修改文件中以下参数:

[GENERAL]
# oracle版本,不能更改
RESPONSEFILE_VERSION = "11.2.0"
# Description : Type of operation
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]
# Description : Global database name of the database
# 全局数据库的名字=SID+主机域名# 第三方工具链接数据库的时候使用的service名称
GDBNAME = "orcl"
# Description : System identifier (SID) of the database
# 对应的实例名字
SID = "orcl"
# Description : Name of the template
# 建库用的模板文件
TEMPLATENAME = "General_Purpose.dbc"

# Description : Password for SYS user
# SYS管理员密码
SYSPASSWORD = "123456"

# Description : Password for SYSTEM user
# SYSTEM管理员密码
SYSTEMPASSWORD = "123456"

# Description : Password for SYSMAN user
# SYSMAN管理员密码
SYSMANPASSWORD = "123456"

# Description : Password for DBSNMP user
# DBSNMP管理员密码
DBSNMPPASSWORD = "123456"

# Description : Location of the data file's
# 数据文件存放目录
DATAFILEDESTINATION =/data/oracle/oradata

# Description : Location of the data file's
# 恢复数据存放目录
RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area

# Description : Character set of the database
# 字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。
# (CHARACTERSET = "AL32UTF8" NATIONALCHARACTERSET= "UTF8")
CHARACTERSET = "ZHS16GBK"

# Description : total memory in MB to allocate to Oracle
# oracle内存1638MB,物理内存2G*80%
TOTALMEMORY = "1638"

进行静默配置:
[oracle@localhost ~]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp

建库后进行实例进程检查:
[oracle@localhost ~]$ ps -ef | grep ora_ | grep -v grep

查看监听状态:
[oracle@localhost ~]$ lsnrctl status

数据库创建完成。

有关详细信息, 请查看以下位置的日志文件: /data/oracle/cfgtoollogs/dbca/orcl/orcl.log。
数据库信息:
全局数据库名:orcl.test
系统标识符 (SID):orcl

登录查看实例状态:
[oracle@localhost ~]$ sqlplus / as sysdba
SQL> select status from v$instance;

务器的操作系统后切换到oracle 用户:执行su - oracle ;
用sys 用户登录sqlplus:执行sqlplus "/as sysdba";
启动数据库:执行startup;
退出sqlplus:执行exit;
启动数据库监听器:执行lsnrctl start;
至此oracle数据库启动成功!

用sys 用户登录sqlplus:执行 sqlplus "/as sysdba";
关闭数据库监听器:执行 lsnrctl stop;
用sys 用户登录sqlplus:sqlplus "/as sysdba";
关闭数据库:shutdown immediate
至此oracle数据库已经关闭成功!

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论