CentOS7安装Oracle

环境:CentOS7

1、官网获取安装包

oracle-database-ee-19c-1.0-1.x86_64.rpm
oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

2、安装软件

yum -y install ./oracle*

3、配置数据库

vim /etc/init.d/oracledb_ORCLCDB-19c

更改内容如下

1
2
3
4
5
6
7
8
export ORACLE_VERSION=19c
export ORACLE_SID=ORA19C
export TEMPLATE_NAME=General_Purpose.dbc
export CHARSET=ZHS16GBK
export PDB_NAME=ORA19CPDB
export LISTENER_NAME=LISTENER
export NUMBER_OF_PDBS=1
export CREATE_AS_CDB=true

4、复制配置文件

1
2
cd /etc/sysconfig/
cp oracledb_ORCLCDB-19c.conf oracledb_ORA19C-19c.conf

5、初始化数据库

/etc/init.d/oracledb_ORCLCDB-19c configure

6、配置环境变量

vim /etc/profile

添加环境变量

1
2
3
export  ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export PATH=$PATH:/opt/oracle/product/19c/dbhome_1/bin
export ORACLE_SID=ORA19C

生效

source /etc/profile

7、切换用户,进入数据库创建用户及授权

su - oracle

1
2
3
4
5
6
7
8
sqlplus / as sysdba
SQL> show pdbs (查询pdbs,非必要)

# 创建用户
SQL> create user c##yunyao identified by xZkVNXLkwpgvlMF6;

# 授权
SQL> grant connect,resource,dba to c##yunyao;

8、配置监听

vim /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora

修改如下,主要将localhost改为本机IP

1
2
3
4
5
6
7
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.3)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

同上

vim /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora

1
2
3
4
5
6
7
8
9
10
11
ORA19C =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.3)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORA19C)
)
)

LISTENER_ORA19C =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.3)(PORT = 1521))

9、重启服务

/etc/init.d/oracledb_ORCLCDB-19c restart

备注:使用netstat -lntp 查看是否有监听1521端口,没有则停止Oracle服务后再重新启动

10、其他

查看状态

lsnrctl status

启动

lsnrctl start

停止

lsnrctl stop