最近正好安装数据库就记录下,怕自己忘。

1. 系统环境介绍

CentOS 7

2. 需要的安装文件

需要以下2个文件

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
oracle-database-xe-18c-1.0-1.x86_64.rpm
oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm oracle-database-xe-18c-1.0-1.x86_64.rpm
oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
oracle-database-xe-18c-1.0-1.x86_64.rpm

从官网获取的地址

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm

3. 开始安装

全程使用root账户

3.1 将2个安装文件上传到服务器目录

这里我直接使用SecureFX上传oracle-database-xe-18c-1.0-1.x86_64.rpm

然后直接使用Curl获取oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# curl -o oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
# yum -y localinstall oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
# curl -o oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm # yum -y localinstall oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
# curl -o oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm
# yum -y localinstall oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm

首先安装preinstall的rpm,一般没什么问题。

3.2安装oracle-database-preinstall-18c-1.0-1.el6.x86_64.rpm

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm
yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm
yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm

这里一般也没什么问题

3.3设置sga_target大小(这里非常重要不然100%失败)

使用命令设置为推荐大小1968M

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sed -i 's/$MEMORY_CONSTRUCT/-initParams sga_target=1968M,pga_aggregate_target=80M/' /etc/init.d/oracle-xe-18c
sed -i 's/$MEMORY_CONSTRUCT/-initParams sga_target=1968M,pga_aggregate_target=80M/' /etc/init.d/oracle-xe-18c
sed -i 's/$MEMORY_CONSTRUCT/-initParams sga_target=1968M,pga_aggregate_target=80M/' /etc/init.d/oracle-xe-18c

3.4开始初始化Oracle

使用命令后耐心等待

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# /etc/init.d/oracle-xe-18c configure
# /etc/init.d/oracle-xe-18c configure
# /etc/init.d/oracle-xe-18c configure

见到如下界面即代表完成

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@LZ-CentOS-VM liuzheng]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password:
*****************
Enter SYSTEM user password:
****************
Enter PDBADMIN User Password:
****************
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
Connect to Oracle Database using one of the connect strings:
Pluggable database: LZ-CentOS-VM/XEPDB1
Multitenant container database: LZ-CentOS-VM
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
[root@LZ-CentOS-VM liuzheng]#
[root@LZ-CentOS-VM liuzheng]# /etc/init.d/oracle-xe-18c configure Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts: Confirm the password: Configuring Oracle Listener. Listener configuration succeeded. Configuring Oracle Database XE. Enter SYS user password: ***************** Enter SYSTEM user password: **************** Enter PDBADMIN User Password: **************** Prepare for db operation 7% complete Copying database files 29% complete Creating and starting Oracle instance 30% complete 31% complete 34% complete 38% complete 41% complete 43% complete Completing Database Creation 47% complete 50% complete Creating Pluggable Databases 54% complete 71% complete Executing Post Configuration Actions 93% complete Running Custom Scripts 100% complete Database creation complete. For details check the logfiles at: /opt/oracle/cfgtoollogs/dbca/XE. Database Information: Global Database Name:XE System Identifier(SID):XE Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details. Connect to Oracle Database using one of the connect strings: Pluggable database: LZ-CentOS-VM/XEPDB1 Multitenant container database: LZ-CentOS-VM Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE [root@LZ-CentOS-VM liuzheng]#
[root@LZ-CentOS-VM liuzheng]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password: 
*****************
Enter SYSTEM user password: 
****************
Enter PDBADMIN User Password: 
****************
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

Connect to Oracle Database using one of the connect strings:
     Pluggable database: LZ-CentOS-VM/XEPDB1
     Multitenant container database: LZ-CentOS-VM
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
[root@LZ-CentOS-VM liuzheng]#

4 完成