1 安装虚拟机
设置4G内存,硬盘40G
2 配置网络环境
2.1配置主机名
# vi /etc/hostname
修改为
oracle
2.2 配置IP地址
# vi /etc/sysconfig/network-scripts/ifcfg-ens33
修改
BOOTPROTO="static"
ONBOOT="yes"
IPADDR=192.168.109.110
NETMASK=255.255.255.0
GATEWAY=192.168.109.2
DNS1=192.168.109.2
2.3 修改映射文件
# vi /etc/hosts
添加
192.168.109.110 oracle
2.4 关闭防火墙
[root@oracle ~]# systemctl stop firewalld
[root@oracle ~]# systemctl disable firewalld
重启
# reboot
3 安装依赖包
安装oracle依赖
[root@oracle ~]# yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
下载命令wget
[root@oracle ~]# yum -y install wget
压缩解压包
[root@oracle ~]# yum install -y unzip zip
[root@oracle ~]# wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
[root@oracle ~]# rpm -ivh /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
校验
[root@oracle ~]# rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"
4 添加用户和用户组
[root@oracle ~]# groupadd oinstall
[root@oracle ~]# groupadd dba
[root@oracle ~]# useradd -g oinstall -G dba oracle -d /home/oracle
[root@oracle ~]# passwd oracle
查看
[root@oracle ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
5 检查网络
5.1 检查主机名
[root@oracle ~]# hostname
oracle
5.2 检查映射
[root@oracle ~]# cat /etc/hosts
192.168.109.110 oracle
# ping oracle
6 优化OS内核参数
[root@oracle ~]# vi /etc/sysctl.conf
# 编辑状态输入如下内容/或修改对应的值
net.ipv4.ip_local_port_range=9000 65500
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 4294967295
kernel.sem=250 32000 100 128
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
7 创建oracle安装目录
[root@oracle ~]# mkdir -p /data/oracle/oracle/product/11.2.0
[root@oracle ~]# mkdir /data/oracle/oracle/oradata
[root@oracle ~]# mkdir /data/oracle/oracle/inventory
[root@oracle ~]# mkdir /data/oracle/oracle/fast_recovery_area
# 修改文件夹所属
[root@oracle ~]# chown -R oracle:oinstall /data/oracle/oracle/
# 修改权限
[root@oracle ~]# chmod -R 775 /data/oracle/oracle/
8 配置oracle用户环境变量
8.1配置oracle用户环境变量
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ vi .bash_profile
# 进入编辑状态后添加如下代码
umask 022
export ORACLE_HOSTNAME=oracle
export ORACLE_BASE=/data/oracle/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
8.2 刷新
[oracle@oracle ~]$ source .bash_profile
8.3 重启服务器
[oracle@oracle ~]$ exit
logout
[root@oracle ~]# reboot
9 解压oracle文件,并配置
9.1上传oracle数据库安装包到root家目录下
注册账号从 oracle官网下载
选择需要的版本,本文以11g为例
下载需要安装的oracle版本
9.2解压
[root@oracle ~]# unzip linux.x64_11gR2_database_1of2.zip -d /data/oracle/
[root@oracle ~]# unzip linux.x64_11gR2_database_2of2.zip -d /data/oracle/
# 解压完成后进行安装前的配置
[root@oracle ~]# mkdir /data/oracle/etc
[root@oracle ~]# cp /data/oracle/database/response/* /data/oracle/etc/
[root@oracle ~]# vi /data/oracle/etc/db_install.rsp
# 进入编辑状态修改如下项的值
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=oracle
ORACLE_HOME=/data/oracle/oracle/product/11.2.0
ORACLE_BASE=/data/oracle/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
10 安装
10.1安装
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ cd /data/oracle/database
# 可以看见database文件夹下有三个模板其中dbca.rsp是用来创建数据库的。db_install.rsp是用来安装Oracle软件的。netca.rsp是用来创建监听器的
[oracle@oracle database]$ ./runInstaller -silent -ignorePrereq -responseFile /data/oracle/etc/db_install.rsp
可查看日志
通过tail命令查看安装日志
tail -f /data/oracle/oracle/inventory/logs/installActions2019-12-13_01-56-19PM.log
安装成功如下
The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root scripts to run/data/oracle/oracle/inventory/orainstRoot.sh
/data/oracle/oracle/product/11.2.0/root.sh
To execute the configuration scripts:1. Open a terminal window 2. Log in as "root" 3. Run the scripts 4. Return to this window and hit "Enter" key to continue Successfully Setup Software.
10.2 按照安装成功提示信息操作:
[root@oracle ~]# sh /data/oracle/oracle/inventory/orainstRoot.sh
# 提示信息
Changing permissions of /data/oracle/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /data/oracle/oracle/inventory to oinstall.
The execution of the script is complete.[root@oracle ~]# sh /data/oracle/oracle/product/11.2.0/root.sh
提示信息
Check /data/oracle/oracle/product/11.2.0/install/root_oracle_2019-12-13_15-15-28.log for the output of root script
10.3 使用oracle重新连接
关闭窗口,重新连接
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ netca /silent /responsefile /data/oracle/etc/netca.rsp
提示信息
Parsing command line arguments:Parameter "silent" = trueParameter "responsefile" = /data/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:Running Listener Control: /data/oracle/oracle/product/11.2.0/bin/lsnrctl start LISTENERListener Control complete.Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
10.4 静默创建数据库
10.4.1配置
[oracle@oracle ~]$ exit
[root@oracle ~]# vi /data/oracle/etc/dbca.rsp
# 修改如下配置
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "123456"
SYSTEMPASSWORD = "123456"
SYSMANPASSWORD = "123456"
DBSNMPPASSWORD = "123456"
DATAFILEDESTINATION =/data/oracle/oracle/oradata
RECOVERYAREADESTINATION=/data/oracle/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
10.4.2 创建
[root@oracle ~]# su - oracle[oracle@oracle ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName ORCL -sysPassword 123456 -systemPassword 123456 [oracle@oracle ~]$ exit
[root@oracle ~]# reboot
11 查看监听器状态
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ lsnrctl start
12 启动数据库
以管理身份登录
[oracle@oracle ~]$ sqlplus / as sysdba
启动数据库实例
SQL> startup
查看系统的所有表
SQL> select * from tab;
13 解锁普通用户
SQL> alter user scott account unlock; # 解锁scott用户
SQL> alter user scott identified by 123456; # 设置scott用户密码
SQL> quit
[oracle@oracle ~]$ sqlplus scott
SQL> select *from tab
可以使用 数据库连接工具,如plsql plsql下载地址