-
从oracle官网下载oracle 12c的内容,本次部署使用的是orace 12c 的12.1.0 的Enterprise Edition版本
1 2
linuxamd64_12102_database_1of2.zip linuxamd64_12102_database_2of2.zip
-
创建用户和组 ,用于安装oracle
1 2 3 4
groupadd oinstall groupadd dba useradd -g oinstall -G dba -m oracle passwd oracle
用户密码更改为oracle
-
创建数据库软件目录和数据文件存放目录
1 2 3 4 5 6
mkdir /home/oracle/app mkdir /home/oracle/app/oracle mkdir /home/oracle/app/oradata mkdir /home/oracle/app/oraInventory mkdir /home/oracle/app/fast_recovery_area mkdir /home/oracle/app/oracle/product
-
复制linuxamd64_12102_database_1of2.zip与linuxamd64_12102_database_2of2.zip到/home/oracle/app/oracle,并解压
-
设置 /home/oracle目录权限
1
chown -R oracle:oinstall /home/oracle
-
创建/etc/oraInst.loc
1 2
inventory_loc=/home/oracle/app/oraInventory inst_group=oinstall
-
yum相关第三方库
1
yum -y install binutils compat-libstdc++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devel libstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat* unixODBC* wget unzip
-
使用
su - oracle
切换到oracle用户,执行安装脚本 -
安装数据库主程序
-
修改database/response/db_install.rsp
1 2 3 4 5 6 7 8
oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/home/oracle/app/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/home/oracle/app/oracle/product/12.1.0/dbhome_1 ORACLE_BASE=/home/oracle/app oracle.install.db.InstallEdition=EE DECLINE_SECURITY_UPDATES=yes
oracle.install.option
设置为只安装数据库,监听器及实例配置在后面手动创建。另一个遇到的问题是直接使用INSTALL_DB_AND_CONFIG
时出现acfsutil
工具找不到,网上也没有什么解决方案,因此选择INSTALL_DB_SWONLY
-
执行下面的命令安装oralce
1
/home/oracle/app/oracle/database/runInstaller -ignoreSysPrereqs -waitforcompletion -silent -responseFile /home/oracle/app/oracle/database/response/db_install.rsp SECURITY_UPDATES_VIA_MYORACLESUPPORT=false DECLINE_SECURITY_UPDATES=true
如果出现可以查看对应的日志文件,另外可以使用
-debug
输出更详细的安装步骤 - 执行成功后按提示使用root执行指定的脚本
1 2 3 4 5
Oracle Database 12c 的 安装 已成功。 请查看 '/home/oracle/app/oraInventory/logs/silentInstall2018-09-08_07-48-40PM.log' 以获取详细资料。 以 root 用户的身份执行以下脚本: 1. /home/oracle/app/oracle/product/12.1.0/dbhome_1/root.sh
-
-
配置监听器
-
在~/.bashrc配置好环境变量
1 2 3 4 5
export ORACLE_BASE=/home/oracle/app export ORACLE_HOME=$ORACLE_BASE/oracle/product/12.1.0/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
执行
source ~/.bashrc
-
编辑database/response/netca.rsp内容,但其实基本不用更改即可安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
grep -Ev "^$|^#" netca.rsp [GENERAL] RESPONSEFILE_VERSION="12.1" CREATE_TYPE="CUSTOM" [oracle.net.ca] INSTALLED_COMPONENTS={"server","net8","javavm"} INSTALL_TYPE=""typical"" LISTENER_NUMBER=1 LISTENER_NAMES={"LISTENER"} LISTENER_PROTOCOLS={"TCP;1521"} LISTENER_START=""LISTENER"" NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"} NSN_NUMBER=1 NSN_NAMES={"EXTPROC_CONNECTION_DATA"} NSN_SERVICE={"PLSExtProc"} NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
-
静默安装监听器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
netca -silent -responsefile /home/oracle/app/oracle/database/response/netca.rsp 正在对命令行参数进行语法分析: 参数"silent" = true 参数"responsefile" = /home/oracle/app/oracle/database/response/netca.rsp 完成对命令行参数进行语法分析。 Oracle Net Services 配置: 完成概要文件配置。 Oracle Net 监听程序启动: 正在运行监听程序控制: /home/oracle/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start LISTENER 监听程序控制完成。 监听程序已成功启动。 监听程序配置完成。 成功完成 Oracle Net Services 配置。退出代码是0
-
确认监听器状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
[oracle@bogon oracle]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 08-SEP-2018 21:11:10 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 08-SEP-2018 21:10:32 Uptime 0 days 0 hr. 0 min. 38 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora Listener Log File /home/oracle/app/diag/tnslsnr/bogon/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bogon)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully
-
-
创建数据库实例
-
执行下面的命令创建数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
dbca -silent \ > -createDatabase \ > -templateName General_Purpose.dbc \ > -gdbName orcl.example.com \ > -sid orcl \ > -createAsContainerDatabase true \ > -numberOfPdbs 1 \ > -pdbName pdb \ > -pdbadminUsername pdba \ > -pdbadminPassword oracle \ > -SysPassword oracle \ > -SystemPassword oracle \ > -emConfiguration NONE \ > -recoveryAreaDestination $ORACLE_BASE/recovery_area \ > -characterSet "AL32UTF8" \ > -nationalCharacterSet "UTF8" \ > -redoLogFileSize 100 复制数据库文件 1% 已完成 2% 已完成 8% 已完成 13% 已完成 19% 已完成 27% 已完成 正在创建并启动 Oracle 实例 29% 已完成 32% 已完成 33% 已完成 34% 已完成 38% 已完成 42% 已完成 43% 已完成 45% 已完成 正在进行数据库创建 48% 已完成 51% 已完成 53% 已完成 62% 已完成 70% 已完成 72% 已完成 正在创建插接式数据库 78% 已完成 100% 已完成 有关详细信息, 请参阅日志文件 "/home/oracle/app/cfgtoollogs/dbca/orcl/orcl.log"。
-
测试实例是否注册成功
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
[oracle@bogon response]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 08-SEP-2018 21:33:29 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 08-SEP-2018 21:10:32 Uptime 0 days 0 hr. 22 min. 56 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora Listener Log File /home/oracle/app/diag/tnslsnr/bogon/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bogon)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "orcl.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "pdb.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
-
登录到数据库,查看实例状态
1 2 3 4 5 6 7 8 9 10 11
sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Thu Sep 21 13:35:34 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> select instance_name, status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ orcl OPEN
-
-
创建用户并设置权限
-
使用dba登录
1
sqlplus / as sysdba
-
由于oracle 12c 有CBD(数据库容器)与PDB(可插拔数据库)之分,一般我们只用PDB来创建数据库,因此切换到PDB,查看数据目录,方便下一步创建表空间时指定路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB READ WRITE NO SQL> alter session set container=PDB; SQL> select name from v$datafile; NAME ---------------------------------------------------------------- /home/oracle/app/oradata/orcl/undotbs01.dbf /home/oracle/app/oradata/orcl/pdb/system01.dbf /home/oracle/app/oradata/orcl/pdb/sysaux01.dbf /home/oracle/app/oradata/orcl/pdb/pdb_users01.dbf
-
创建用户表空间及用户,设置用户权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
SQL> CREATE TABLESPACE test_tbs datafile '/home/oracle/app/oradata/orcl/pdb/test_tbs.dbf' size 50M autoextend on next 50m maxsize unlimited; Tablespace created. # 创建用户(test01),设置密码(test),并分配表空间(test_tbs) SQL> create user test01 identified by test default tablespace test_tbs account unlock; User created. # 由于表空间为无上限,因此需要再分配权限 SQL> ALTER USER test01 QUOTA UNLIMITED ON test_tbs; User altered. # 用户授权 SQL> grant connect, resource to test01; Grant succeeded. SQL> commit; Commit complete.
-
查看CBD中可以用的服务,会发现通过
pdb.example.com
这个service_name是可以远程连接到PDB的。1 2 3 4 5 6
SQL> col name for a30 SQL> select name,pdb from v$services; NAME PDB ------------------------------ ------------------------------ pdb.example.com PDB
-
-
开放端口
1 2
firewall-cmd --permanent --add-port=1521/tcp firewall-cmd --reload
-
测试连接
-
可以使用以下两种方式进行连接
使用EZCONNECT方式进行连接1 2 3 4 5 6 7 8 9 10 11 12
[oracle@bogon ~]$ sqlplus test01/[email protected]:1521/pdb.example.com SQL*Plus: Release 12.1.0.2.0 Production on Sun Sep 9 17:58:25 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL>
使用TNSNAMES方式进行连接
-
为了能通过TNSNAMES访问到数据库,需要在$ORACLE_HOME/network/admin/tnsnames.ora
文件中加入如下内容:1 2 3 4 5 6 7 8
TEST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb.example.com) ) )
-
使用以下命令访问
1 2 3 4 5 6 7 8 9 10 11 12 13
[oracle@bogon ~]$ sqlplus test01/test@TEST SQL*Plus: Release 12.1.0.2.0 Production on Sun Sep 9 18:02:07 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Last Successful login time: Sun Sep 09 2018 18:00:55 +08:00 Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL>
-
-
创建表测试
1 2 3 4 5 6 7 8 9 10 11 12 13
SQL> create table tbl(name varchar(20),info varchar(20)); Table created. SQL> insert into tbl values('abc','bbb'); 1 row created. SQL> select * from tbl; NAME INFO -------------------- -------------------- abc bbb
-
centos 安装oracle12c
猜你喜欢
转载自blog.csdn.net/wyk9916/article/details/82710867
今日推荐
周排行