服务器运维
Linux
Oracle
2025-04-03 15:04
阅读:144
评论:0
CentOS 7 安装oracle19
vmw虚拟机 CentOS 7 安装oracle 参考:<http://blog.itpub.net/69975956/viewspace-2706044/> wget <https://yum.oracle.com/repo/OracleLinux/OL7/latest/x8664/getPack
vmw虚拟机 CentOS 7 安装oracle
- wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
- wget https://download.oracle.com/otn/linux/oracle19c/190000/oracle-database-ee-19c-1.0-1.x86_64.rpm?AuthParam=1618661520_b733840488b27a21d9d23454d0c20a20
关闭selinux:
-
编辑/etc/selinux/config 文件 [root@byh ~]# vi /etc/selinux/config
SELINUX=disabled
配置系统参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 编辑/etc/pam.d/login 添加如下内容: vi /etc/pam.d/login session required pam_limits.so # 编辑vi /etc/profile添加如下内容: #系统环境变量if [ /$USER = "oracle" ] ; then if [ /$SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536else ulimit -u 16384 -n 65536fi umask 022fi # 编辑/etc/security/limits.conf 添加如下内容:vi /etc/security/limits.conf oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536- yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
- yum -y localinstall oracle-database-ee-19c-1.0-1.x86_64.rpm
配置oracle环境
- 配置文件
vim /etc/init.d/oracledb_ORCLCDB-19c
1
2
3
4
5
6
7
8
9
10
11
export ORACLE\_VERSION=19c export ORACLE\_SID=ORCLCDB export TEMPLATE\_NAME=General\_Purpose.dbc export CHARSET=AL32UTF8 export PDB\_NAME=ORCLPDB1 export LISTENER\_NAME=LISTENER export NUMBER\_OF\_PDBS=1 # true 表示创建容器数据库,若果是容器数据库,创建用户的时候普通用户要使用 c## 作为前缀 export CREATE\_AS\_CDB=true # 改为 export CREATE\_AS\_CDB=false- root 用户执行命令:
- /etc/init.d/oracledb_ORCLCDB-19c configure # 执行后先玩一盘王者等待
1
2
# 执行完显示如下Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.- 配置oracle 环境
1
2
3
4
export ORACLE\_BASE=/opt/oracle export ORACLE\_HOME=/opt/oracle/product/19c/dbhome\_1 export PATH=`$ORACLE_HOME/bin:$`PATH export ORACLE\_SID=ORCLCDB- vim ~/.bash_profile
- source ~/.bash_profile
安装错误
1
2
3
4
5
6
7
8
The install cannot proceed because ORACLE_BASE directory (/opt/oracle) is not owned by "oracle" user. You must change the ownership of ORACLE_BASE directory to "oracle" user and retry the installation. The install cannot proceed because ORACLE_BASE directory (/opt/oracle) is not owned by "oinstall" group. You must change the ownership of ORACLE_BASE directory to "oinstall" group and retry the installation.- 这两个错误意思是oracle用户没有操作
/opt/oracle目前权限,且不属于oinstall组
目录授权
- chown -R oracle:oinstall ./oracle
在oracle用户下查看监听器是否启动
- lsnrctl status (查看监听器状态)
- lsnrctl start (启动监听器)
Linux下安装Oracle后重启无法登录数据库ORA-01034:ORACLE not available
- 执行
sqlplus / as sysdba命令 - 然后输入
startup启动oracle
启动oracle 报错
1
could not open parameter file '/opt/oracle/product/10.2/db_1/dbs/initorcl.ora- 将 /opt/oracle/product/10.2/db_1/dbs/目录下的
init.ora更改为initorcl.ora
链接错误
1
状态: 失败 -测试失败: IO 错误: The Network Adapter could not establish the connection (CONNECTION_ID=4sqFYx9UTb6zL1+u056jGg==)- 可能是防火墙拦截端口导致无法链接
- 尝试关闭防火墙
1
2
3
4
5
6
# 临时关闭防火墙systemctl stop firewalld# 查看防火墙状态systemctl status firewalld# 永久关闭防火墙(先关闭防火墙在执行命令禁用防火墙)systemctl disable firewalld- 如果还是这个错误,oracle用户下查看监听器是否启动
重置system密码
- 执行
sqlplus / as sysdba;命令 - 然后执行
alter user system identified by 123456;重置system用户密码为123456
修改Oracle用户的密码:
1
passwd oracle创建数据库用户
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 创建表空间CREATE TABLESPACE bdc_yc datafile '/u01/app/oracle/my_db/DDATA.dbf' size 500M autoextend on next 5M maxsize unlimited; # 创建临时表空间CREATE temporary TABLESPACE bdc_yc_tmp tempfile '/opt/oracle/my_db/DDATA_TMP.dbf' size 300M autoextend on next 5M maxsize unlimited; # 创建用户并指定表空间以及临时表空间create user bdc_yc identified by "123456" default tablespace bdc_yc temporary tablespace bdc_yc_tmp; # 授予用户使用表空间的权限alter user bdc_yc quota unlimited on bdc_yc; # 授权(如果不是授权,则账号无法链接数据库)grant create session to bdc_yc;grant create table to bdc_yc;grant create tablespace to bdc_yc;grant create view to bdc_yc;