[TOC]
0x00 Linux中Oracle11g安装
CentOS 安装
环境准备:
[TOC]
环境准备:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23VM12 + centos7 x86_64_minimal.iso #最小化安装的Centos7
Oracle Version: Oracle Database 11g Release 2 (11.2.0.1.0)
#要求:
RAW Swap
1G至2G 1.5倍
2G至16G 同RAW相等
16G以上 16G
#虚拟机配置:
- 60G 硬盘
- 4G ram + 2G swap
#项目实施:
IP:192.168.136.128
hostname: oracle11
账号密码:root/oracel
sySTEM@2019!
SID: orcl
服务名称:orcl.db1
密码:sySTEM@2019!
安装流程与步骤:1
2
3
4
5
6
7#Step1.建立虚拟机导入centos7,minimal镜像并启动
关键点1:系统语言选择要将English勾选上
关键点2:磁盘分区进行手动分区,将交换分区进行调整;
$lsb_release -a #查看版本信息
CentOS Linux release 7.6.1810 (Core)
3.10.0-957.el7.x86_64
1 | #Step2.系统环境调整 |
配置用户环境: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步骤8.配置用户环境shell
$su - oracle #使用Oracle用户登陆:
$vi .bash_profile
umask 022
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export LANG=en_US
# +--------------------------+
# | SETUP ORACLE ENVIRONMENT |
# +--------------------------+
export TMP=/opt/oracle/tmp
export TMPDIR=$TMP
ORACLE_HOSTNAME=oracle11
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.1/db1
ORACLE_SID=orcl
ORACLE_TERM=xterm;
PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#THREADS_FLAG=native; export THREADS_FLAG
export ORACLE_HOSTNAME ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_TERM PATH NLS_DATE_FORMAT NLS_LANG
$source .bash_profile #执行生效
#配置环境变量shell(Root权限下执行)
$vi /etc/profile #增加下面行:
if [ $USER = "oracle" ] || [ $USER = "grid" ] ; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
$source /etc/profile
下载Oracle的Linux版本(并进行解压):
下载地址:https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html1
2
3
4
5
6
7
8#采用迅雷下载也可以
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip
#建VM立共享然后解压oracle安装程序到自定目录
chown -R oracle:oinstall /home/oracle/ #防止权限问题
unzip linux.x64_11gR2_database_1of2.zip -q -d /home/oracle/
unzip linux.x64_11gR2_database_2of2.zip -q -d /home/oracle/
配置db_install.rsp(自动安装应答文件)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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61#将解压目录中的reponse进行备份
cp -r /home/oracle/database/response/ /home/oracle
mkdir -pv /opt/oracle/product/11.2.0.1/db1 /var/oracle /opt/oracle/oraInventor /opt/oracle/oradata /opt/oracle/tmp
#配置安装响应文件db_install.rsp文件 这里配置参数先下载到本地 用记事本根据自己情况修改 在上传过去
$cat /home/oracle/response/db_install.rsp | grep -E -v "^#" | tr -s '\n'
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
#机器名称和组
ORACLE_HOSTNAME=oracle11
UNIX_GROUP_NAME=oinstall
#前面设置的目录
INVENTORY_LOCATION=/opt/oracle/oraInventor
SELECTED_LANGUAGES=zh_CN,en
#oracle环境基础设置
ORACLE_HOME=/opt/oracle/product/11.2.0.1/db1
ORACLE_BASE=/opt/oracle/product/
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
#服务名
oracle.install.db.config.starterdb.globalDBName=orcl.db1
#实例名称
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
#根据系统实际情况设置我这里分2G给他
oracle.install.db.config.starterdb.memoryLimit=1880
oracle.install.db.config.starterdb.installExampleSchemas=true
oracle.install.db.config.starterdb.enableSecuritySettings=true
#密码默认设置不设置安装时会提示
oracle.install.db.config.starterdb.password.ALL=Oracle@123
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/opt/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
静默安装数据库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#安装 Oracle11g
/home/oracle/database/runInstaller -silent -ignorePrereq -responseFile /home/oracle/db_install.rsp
# Starting Oracle Universal Installer...
# Checking Temp space: must be greater than 120 MB. Actual 53477 MB Passed
# Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
# Preparing to launch Oracle Universal Installer from /opt/oracle/tmp/OraInstall2019-06-21_01-28-41AM.
# Preparing to launch Oracle Universal Installer from /opt/oracle/tmp/OraInstall2019-06-21_01-37-00AM. Please wait ...[oracle@oracle11:/home/oracle]$You can find the log of this install session at:
/opt/oracle/oraInventor/logs/installActions2019-06-21_01-37-00AM.log
#新建立一个终端查看安装信息:
$tail -f /opt/oracle/oraInventor/logs/installActions2019-06-21_01-37-00AM.log
# INFO: Installation in progress
# INFO: Extracting files to '/opt/oracle/product/11.2.0.1/db1'.
# INFO: Extracting files to '/opt/oracle/product/11.2.0.1/db1'.
# INFO: Performing fastcopy operations based on the information in the file 'oracle.server_EE_exp_1.xml'.
# INFO: Performing fastcopy operations based on the information in the file 'racfiles.jar'.
# INFO: Performing fastcopy operations based on the information in the file 'oracle.server_EE_dirs.lst'.
# INFO: Performing fastcopy operations based on the information in the file 'oracle.server_EE_filemap.jar'.
# INFO: Performing fastcopy operations based on the information in the file 'oracle.server_EE_1.xml'.
# INFO: Performing fastcopy operations based on the information in the file 'setperms1.sh'.
# INFO: Number of threads for fast copy :1
# INFO: Validating state <finish>
# WARNING: Validation disabled for the state finish
# INFO: Completed validating state <finish>
# INFO: Terminating all background operations
# INFO: Terminated all background operations
# INFO: Successfully executed the flow in SILENT mode
# INFO: Finding the most appropriate exit status for the current application
# INFO: Exit Status is 3
# INFO: Shutdown Oracle Database 11g Release 2 Installer #代表安装成功
# INFO: Unloading Setup Driver
1 | #安装完成后切换到root账号 |
数据库的启动&关闭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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79[root] #修改oracle服务启动配置
vi /etc/oratab
orcl:/opt/oracle/product/11.2.0.1/db1:Y # //把“N”改成“Y”
[oracle] #切换用户
#启动oracle
#因为修改了/etc/oratab N->y 所以启动服务也会同时启动实例的情况不,会同时启动实例
#sqlplus sqlplus登录会提示 an idle instance --> startup启动实
#(1)启动/停止监听
$lsnrctl start
$lsnrctl stop #停止监听x
#(2)通过dbstart 启动此实例,监听器
# dbstart $ORACLE_HOME
# #关闭( oracle的进程关闭,监听器也停止)
# dbshut $ORACLE_HOME
#(3)切换用户[#oracle]
#启动oracle
#因为修改了/etc/oratab N->y 所以启动服务也会同时启动实例的情况不,会同时启动实例
#sqlplus sqlplus登录会提示 an idle instance --> startup启动实
$lsnrctl status #查看oracle状态
# LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-JUN-2019 19:49:15
# Copyright (c) 1991, 2009, Oracle. All rights reserved.
# Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
# STATUS of the LISTENER
# ------------------------
# Alias LISTENER
# Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
# Start Date 21-JUN-2019 19:24:44
# Uptime 0 days 0 hr. 24 min. 30 sec
# Trace Level off
# Security ON: Local OS Authentication
# SNMP OFF
# Listener Parameter File /opt/oracle/product/11.2.0.1/db1/network/admin/listener.ora
# Listener Log File /opt/oracle/diag/tnslsnr/oracle11/listener/alert/log.xml
# Listening Endpoints Summary...
# (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
# (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11)(PORT=1521)))
# Services Summary...
# Service "orcl.db1" has 1 instance(s).
# Instance "orcl", status READY(这才是正常状态), has 1 handler(s) for this service...
# Service "orclXDB.db1" has 1 instance(s).
# Instance "orcl", status READY, has 1 handler(s) for this service...
# The command completed successfully
#初次登录配置
$ sqlplus /nolog
$ sqlplus / as sysdba #是系统用户登录的方式
# 进入系统管理用户
SQL> conn / as sysdba
Connected to an idle instance.
# 启动oracle实例
SQL> startup;
#用户查看
SQL> show user
# 实例状态查看
SQL> select HOST_NAME,INSTANCE_NAME,DATABASE_STATUS,STATUS from v$instance;
#服务名称查看
SQL> show parameter service_names
# 停止oracle实例
SQL> shutdown immediate
#远程连接oracle
$sqlplus sys/passoracle@192.168.138.136:1521/orcl.db1 as sysdba #orcl.db1是服务名,而orcl是SID
$sqlplus sys/passoracle#123@127.0.0.1:1521/orcl.db1 as sysdba
$sqlplus sys/passoracle#123@oracle:1521/orcl.db1 as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 21 21:04:53 2019
> conn sys/passoracle@192.168.100.131:1521/ORCL.LAN as sysdba #登录后才能使用
show parameter service_names
采用Navicat进行登录:
建库实例:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#静默dbca建库编辑应答文件(与上面的db_install对应):
[oracle@oracle ~]$ vi /etc/dbca.rsp
GDBNAME="orcl.oracle"
SID="orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
CHARACTERSET="AL32UTF8"
NATIONALCHARACTERSET="UTF8"
# 执行至此完成数据库实例的创建。
[oracle@oracle ~]$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
#删除实例:
[oracle@oracle ~]$ dbca -silent -deleteDatabase -sourcedb orcl
#配置监听程序:
# [oracle@oracle bin]$ /opt/oracle/product/11.2.0.1/db1/bin/netca /silent /responseFile /home/oracle/etc/netca.rsp
防火墙调整1
2
3
4
5#防火墙 放行1521端口
firewall-cmd --zone=public --add-port=1521/tcp --permanent
#重新加载防火墙规则
firewall-cmd --reload
开机自启
描述:默认以安装ORACLE环境作为演示CentOS71
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#Step1.查看ORACLE_HOME是否设置并且编辑/etc/oratab文件设置服务自动启动
echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
#dbca建库时都会自动创建/etc/oratab文件
#将orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N #将N转换成为Y
#Step2.编辑dbstart 数据库自带启动脚本
vim +80 /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
#编辑 dbstart 将 ORACLE_HOME_LISTNER=$1 修改成 ORACLE_HOME_LISTNER=$ORACLE_HOME 前提是$ORACLE_HOME环境设置正确
#Step3.将下数据库自启动命令放入/etc/rc.d/rc.local中
$vim /etc/rc.d/rc.local
su oracle -lc "/opt/oracle/product/11.2.0.1/db1/bin/lsnrctl start"
su oracle -lc /opt/oracle/product/11.2.0.1/db1/bin/dbstart
#Step4.查看数据库是否处于open状态
select status from v$instance
–
https://hub.docker.com/r/jaspeen/oracle-11g
1 | sudo apt-get update |
1 | # Download Oracle installation files https://www.oracle.com/database/technologies/112010-linx8664soft.html |
1 | # 搜索符合条件的镜像 |
1 | # 注意:如果日志长时间没有更新检查docker是否已经死掉, 只有日志里有 100% complete 打印,则代表oracle安装成功 |
1 | sudo docker ps -a Get container [YOUR_CONTAINER_ID] |
1 | # Database located in `/opt/oracle` folder Port: 1521 SID: orcl |
1 | # 创建于授权 |
1 | # 提交镜像 |
1) 进入容器shell使用内置sqlplus进行连接,并解锁用户外部客户端连接测试
Tips: 可以采用sqlplus或者使用dataGrip连接oracle数据库1
2
3
4
5
6
7
8
9
10
11
12
13
14
15docker exec -it oracle11g /bin/bash
su - oracle
sqlplus / as sysdba
SQL> alter user scott account unlock;
User altered.
SQL> commit;
Commit complete.
SQL> conn scott/tiger # 首次连接需更改密码
ERROR:
ORA-28001: the password has expired
Changing password for scott
New password:
Retype new password:
Password changed
Connected.
1) 为什么要解压成上面的目录结构我们先来看看jaspeen/oracle-11g
镜像提供的安装脚本
描述: 从脚本里可以看到它会读取/install/database
目录,如果不存在会给出提示Installation files not found. Unzip installation files into mounted(/install) folder
;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#!/usr/bin/env bash
set -e
source /assets/colorecho
trap "echo_red '******* ERROR: Something went wrong.'; exit 1" SIGTERM
trap "echo_red '******* Caught SIGINT signal. Stopping...'; exit 2" SIGINT
if [ ! -d "/install/database" ]; then
echo_red "Installation files not found. Unzip installation files into mounted(/install) folder"
exit 1
fi
echo_yellow "Installing Oracle Database 11g"
su oracle -c "/install/database/runInstaller -silent -ignorePrereq -waitforcompletion -responseFile /assets/db_install.rsp"
/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/app/product/11.2.0/dbhome_1/root.sh
例如: 挂在文件到容器指定目录 (d:/oracleinstall/database 对应容器 /install/database)1
docker run --privileged --name oracle11g -p 1521:1521 -v d:/oracleinstall:/install jaspeen/oracle-11g
下面罗列出新手安装Oracle数据库时候最需要注意的几个文件可以帮助您排查错误:1
2
3
4#dbstart日志
/opt/oracle/product/11.2.0.1/db1/startup.log
#监听器日志
/opt/oracle/diag/tnslsnr/oracle11/listener/alert/log.xml
问题1:libnjni11.so包导致java.lang.UnsatisfiedLinkError1
2
3
4#netca配置静默监听出错
java.lang.UnsatisfiedLinkError: /db/app/oracle/product/11.2.0/lib/libnjni11.so: libclntsh.so.11.1
#解决方法:
cp $ORACLE_HOME/inventory/Scripts/ext/lib/libclntsh.so.11.1 $ORACLE_HOME/lib/
_问题2:安装oracle11g时候错误信息INFO: Oracle Net Services configuration failed. The exit code is 1 _1
2
3
4
5INFO: Oracle Net Configuration Assistant failed.
INFO: Oracle Net Configuration Assistant failed.
#解决方法:
查看/etc/hosts中是否添加该主机的机器名和回环地址
问题3:错误信息:ORA-12162: TNS:net service name is incorrectly specified1
2
3
4
5
6
7
8
9[oracle@oracle bin]$ ./sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:20:45 2019
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
# 解决方式:
1、系统当前的ORACLE_HOME和ORACLE_SID环境变量
2、给出ORACLE_SID,重新尝试登录:
问题4.ERROR:ORA-12514: TNS:listener does not currently know of service requested in connect
报错信息:oracle 11g ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务
解决方法1:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21vim /opt/oracle/product/11.2.0.1/db1/network/admin/listener.ora
#添加SID名称
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.db1)
(ORACLE_HOME = /opt/oracle/product/11.2.0.1/db1/)
(SID_NAME = orcl)
)
)
#HOST指定后需要查看对应的/etc/hosts中IP是否正确
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle11)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
解决方法二:1
2
3
4
5
6
7
8登录数据库:
$sqlplus / as sysdba
显示服务名:
SQL>show parameter service_names
强制注册服务:
SQL>alter system register;
查看监听状态:
$lsnrctl status
解决方法三:排查客户端连接的服务名称是否正确1
2
3
4
5
6
7
8TestOracle =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST=WeiyiGeek-Oracle)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.db1) #关键点
)
)
解决方法四:查看oracle11是否与主机IP绑定正确查看/etc/hosts
1
2
3
4[oracle@WeiyiGeek-oracle ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.172.240 WeiyiGeek-Oracle
问题5.Instance “orcl”, status UNKNOWN, has 1 handler(s) for this service.
解决办法: 实例化status UNKNOWN 没有正常的启动成功,需要dbstart后才分配内存1
/opt/oracle/product/11.2.0.1/db1/bin/dbstart $ORACLE_HOME
你好看友,欢迎关注博主微信公众号哟! ❤
这将是我持续更新文章的动力源泉,谢谢支持!(๑′ᴗ‵๑)
温馨提示: 未解锁的用户不能粘贴复制文章内容哟!
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主,
将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!
@WeiyiGeek - 为了能到远方,脚下的每一步都不能少
欢迎各位志同道合的朋友一起学习交流,如文章有误请在下方留下您宝贵的经验知识,个人邮箱地址【master#weiyigeek.top】
或者个人公众号【WeiyiGeek】
联系我。
更多文章来源于【WeiyiGeek Blog - 为了能到远方,脚下的每一步都不能少】, 个人首页地址( https://weiyigeek.top )
专栏书写不易,如果您觉得这个专栏还不错的,请给这篇专栏 【点个赞、投个币、收个藏、关个注、转个发、赞个助】,这将对我的肯定,我将持续整理发布更多优质原创文章!。
最后更新时间:
文章原始路径:_posts/数据存储/Oracle/Linux下安装Oracle11gR2.md
转载注明出处,原文地址:https://blog.weiyigeek.top/2019/6-18-93.html
本站文章内容遵循 知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议