阿里云CentOS7 Silent Mode安装Oracle11GR2

来源:互联网 发布:程序员和老师结婚 编辑:程序博客网 时间:2024/06/01 09:50

出处:http://blog.csdn.net/lee353086/article/details/51622309


Title: 阿里云CentOS7 Silent Mode安装Oracle11GR2

Date: 2016-6-9
Author: kagula

Environment:

[1]阿里云CentOS7-64bits 1G RAM  20G Storage
[2]VMWare Workstation 11.x CentOS7-64bits  1G RAM 40G Storage


Introduction

   VMWare workstation CentOS7下Silent mode方式安装Oracle11GR2 64bits.
附带阿里云CentOS7额外要注意的问题。


Content

Step1:安装准备
[1-1]从CentOS和Oracle官网下载
CentOS-7-x86_64-Minimal-1511.iso(阿里云不需要)
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip


[1-2]
如果是阿里云,只有1G RAM,所以需要2G的Swap。
参考《在阿里云CentOS 7创建swap分区的方法》
http://www.111cn.net/sys/CentOS/105946.htm
我们建立2G的Swap partition.
“free -m”命令查看swap.


[1-3]
VMWare中安装CentOS7后“ls /sbin|grep ifconfig”,没有ifconfig命令
“yum install net-tools.x86_64”安装ifconfig.


[1-4]
安装Oracle所需的依赖包
yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel sysstat ksh


[1-5]创建用户和组
groupadd -g 200 oinstall  #添加oinstall组,组的id为200
groupadd -g 201 dba       #添加dba组,组的id为201
useradd -u 440 -g oinstall -G dba oracle #添加用户oracle,并specified它的id为440.
passwd oracle             #输入oracle用户的密码
id oracle                 #查看用户id和所属组
对oracle的操作得使用oracle账号。


[1-6]关闭SELINUX(阿里云缺省关闭)
vim /etc/selinux/config   #编辑配置文件,关闭SELINUX
setenforce 0              #立即关闭SELINUX


[1-7]
使用“su - u oracle”切换到oracle账号下
把下面两个文件上传到CentOS7-64bits服务器的/home/oracle目录下
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
解压缩到oracle目录下
unzip linux.x64_11gR2_database_1of2.zip -d /home/oracle
unzip linux.x64_11gR2_database_2of2.zip -d /home/oracle
在/home/oracle目录下会出现database目录。


[1-8]
“vim /home/oracle/database/response/db_install.rsp”命令配置安装参数
修改后的db_install.rsp文件内容如下:
[html] view plain copy
  1. ####################################################################  
  2. ## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##  
  3. ##                                                                ##  
  4. ## Specify values for the variables listed below to customize     ##  
  5. ## your installation.                                             ##  
  6. ##                                                                ##  
  7. ## Each variable is associated with a comment. The comment        ##  
  8. ## can help to populate the variables with the appropriate        ##  
  9. ## values.                            ##  
  10. ##                                                                ##  
  11. ## IMPORTANT NOTE: This file contains plain text passwords and    ##  
  12. ## should be secured to have read permission only by oracle user  ##  
  13. ## or db administrator who owns this installation.                ##  
  14. ##                                                                ##  
  15. ####################################################################  
  16.   
  17. #------------------------------------------------------------------------------  
  18. # Do not change the following system generated value.   
  19. #------------------------------------------------------------------------------  
  20. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0  
  21.   
  22. #------------------------------------------------------------------------------  
  23. # Specify the installation option.  
  24. # It can be one of the following:  
  25. # 1. INSTALL_DB_SWONLY  
  26. # 2. INSTALL_DB_AND_CONFIG  
  27. # 3. UPGRADE_DB  
  28. #-------------------------------------------------------------------------------  
  29. oracle.install.option=INSTALL_DB_SWONLY  
  30.   
  31. #-------------------------------------------------------------------------------  
  32. # Specify the hostname of the system as set during the install. It can be used  
  33. # to force the installation to use an alternative hostname rather than using the  
  34. # first hostname found on the system. (e.g., for systems with multiple hostnames   
  35. # and network interfaces)  
  36. #-------------------------------------------------------------------------------  
  37. ORACLE_HOSTNAME=192.168.153.133  
  38.   
  39. #-------------------------------------------------------------------------------  
  40. # Specify the Unix group to be set for the inventory directory.    
  41. #-------------------------------------------------------------------------------  
  42. UNIX_GROUP_NAME=oinstall  
  43.   
  44. #-------------------------------------------------------------------------------  
  45. # Specify the location which holds the inventory files.  
  46. #-------------------------------------------------------------------------------  
  47. INVENTORY_LOCATION=/opt/oraInventory  
  48.   
  49. #-------------------------------------------------------------------------------  
  50. # Specify the languages in which the components will be installed.               
  51. #  
  52. # en   : English                  ja   : Japanese                    
  53. # fr   : French                   ko   : Korean                      
  54. # ar   : Arabic                   es   : Latin American Spanish      
  55. # bn   : Bengali                  lv   : Latvian                     
  56. # pt_BR: Brazilian Portuguese     lt   : Lithuanian                  
  57. # bg   : Bulgarian                ms   : Malay                       
  58. # fr_CA: Canadian French          es_MX: Mexican Spanish             
  59. # ca   : Catalan                  no   : Norwegian                   
  60. # hr   : Croatian                 pl   : Polish                      
  61. # cs   : Czech                    pt   : Portuguese                  
  62. # da   : Danish                   ro   : Romanian                    
  63. # nl   : Dutch                    ru   : Russian                     
  64. # ar_EG: Egyptian                 zh_CN: Simplified Chinese          
  65. # en_GB: English (Great Britain)  sk   : Slovak                      
  66. # et   : Estonian                 sl   : Slovenian                   
  67. # fi   : Finnish                  es_ES: Spanish                     
  68. # de   : German                   sv   : Swedish                     
  69. # el   : Greek                    th   : Thai                        
  70. # iw   : Hebrew                   zh_TW: Traditional Chinese         
  71. # hu   : Hungarian                tr   : Turkish                     
  72. # is   : Icelandic                uk   : Ukrainian                   
  73. # in   : Indonesian               vi   : Vietnamese                  
  74. # it   : Italian                                                     
  75. #  
  76. # Example : SELECTED_LANGUAGES=en,fr,ja  
  77. #------------------------------------------------------------------------------  
  78. SELECTED_LANGUAGES=zh_CN,en  
  79.   
  80. #------------------------------------------------------------------------------  
  81. # Specify the complete path of the Oracle Home.  
  82. #------------------------------------------------------------------------------  
  83. ORACLE_HOME=/opt/oracle/product/11.2.0/db_1  
  84.   
  85. #------------------------------------------------------------------------------  
  86. # Specify the complete path of the Oracle Base.   
  87. #------------------------------------------------------------------------------  
  88. ORACLE_BASE=/opt/oracle  
  89.   
  90. #------------------------------------------------------------------------------  
  91. # Specify the installation edition of the component.                          
  92. #                                                               
  93. # The value should contain only one of these choices.          
  94. # EE     : Enterprise Edition                                  
  95. # SE     : Standard Edition                                    
  96. # SEONE  : Standard Edition One  
  97. # PE     : Personal Edition (WINDOWS ONLY)  
  98. #------------------------------------------------------------------------------  
  99. oracle.install.db.InstallEdition=EE  
  100.   
  101. #------------------------------------------------------------------------------  
  102. # This variable is used to enable or disable custom install.  
  103. #  
  104. # true  : Components mentioned as part of 'customComponents' property  
  105. #         are considered for install.  
  106. # false : Value for 'customComponents' is not considered.  
  107. #------------------------------------------------------------------------------  
  108. oracle.install.db.isCustomInstall=false  
  109.   
  110. #------------------------------------------------------------------------------  
  111. # This variable is considered only if 'IsCustomInstall' is set to true.   
  112. #  
  113. # Description: List of Enterprise Edition Options you would like to install.  
  114. #  
  115. #              The following choices are available. You may specify any  
  116. #              combination of these choices.  The components you choose should  
  117. #              be specified in the form "internal-component-name:version"  
  118. #              Below is a list of components you may specify to install.  
  119. #          
  120. #              oracle.rdbms.partitioning:11.2.0.1.0 - Oracle Partitioning  
  121. #              oracle.rdbms.dm:11.2.0.1.0 - Oracle Data Mining  
  122. #              oracle.rdbms.dv:11.2.0.1.0 - Oracle Database Vault   
  123. #              oracle.rdbms.lbac:11.2.0.1.0 - Oracle Label Security  
  124. #              oracle.rdbms.rat:11.2.0.1.0 - Oracle Real Application Testing   
  125. #              oracle.oraolap:11.2.0.1.0 - Oracle OLAP  
  126. #------------------------------------------------------------------------------  
  127. 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  
  128.   
  129. ###############################################################################  
  130. #                                                                             #  
  131. # PRIVILEGED OPERATING SYSTEM GROUPS                                          #  
  132. # ------------------------------------------                                  #  
  133. # Provide values for the OS groups to which OSDBA and OSOPER privileges       #  
  134. # needs to be granted. If the install is being performed as a member of the   #       
  135. # group "dba", then that will be used unless specified otherwise below.       #  
  136. #                                                                             #  
  137. ###############################################################################  
  138.   
  139. #------------------------------------------------------------------------------  
  140. # The DBA_GROUP is the OS group which is to be granted OSDBA privileges.  
  141. #------------------------------------------------------------------------------  
  142. oracle.install.db.DBA_GROUP=dba  
  143.   
  144. #------------------------------------------------------------------------------  
  145. # The OPER_GROUP is the OS group which is to be granted OSOPER privileges.  
  146. #------------------------------------------------------------------------------  
  147. oracle.install.db.OPER_GROUP=oinstall  
  148.   
  149. #------------------------------------------------------------------------------  
  150. # Specify the cluster node names selected during the installation.  
  151. #------------------------------------------------------------------------------  
  152. oracle.install.db.CLUSTER_NODES=  
  153.   
  154. #------------------------------------------------------------------------------  
  155. # Specify the type of database to create.  
  156. # It can be one of the following:  
  157. # - GENERAL_PURPOSE/TRANSACTION_PROCESSING            
  158. # - DATA_WAREHOUSE                                  
  159. #------------------------------------------------------------------------------  
  160. oracle.install.db.config.starterdb.type=GENERAL_PURPOSE  
  161.   
  162. #------------------------------------------------------------------------------  
  163. # Specify the Starter Database Global Database Name.   
  164. #------------------------------------------------------------------------------  
  165. oracle.install.db.config.starterdb.globalDBName=orcl  
  166.   
  167. #------------------------------------------------------------------------------  
  168. # Specify the Starter Database SID.  
  169. #------------------------------------------------------------------------------  
  170. oracle.install.db.config.starterdb.SID=sidOracle11GR2  
  171.   
  172. #------------------------------------------------------------------------------  
  173. # Specify the Starter Database character set.  
  174. #                                                
  175. # It can be one of the following:  
  176. # AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,  
  177. # EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,  
  178. # BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,  
  179. # AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,  
  180. # IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,  
  181. # KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,  
  182. # ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258  
  183. #------------------------------------------------------------------------------  
  184. oracle.install.db.config.starterdb.characterSet=AL32UTF8  
  185.   
  186. #------------------------------------------------------------------------------  
  187. # This variable should be set to true if Automatic Memory Management   
  188. # in Database is desired.  
  189. # If Automatic Memory Management is not desired, and memory allocation  
  190. # is to be done manually, then set it to false.  
  191. #------------------------------------------------------------------------------  
  192. oracle.install.db.config.starterdb.memoryOption=true  
  193.   
  194. #------------------------------------------------------------------------------  
  195. # Specify the total memory allocation for the database. Value(in MB) should be  
  196. # at least 256 MB, and should not exceed the total physical memory available   
  197. # on the system.  
  198. # Example: oracle.install.db.config.starterdb.memoryLimit=512  
  199. #------------------------------------------------------------------------------  
  200. oracle.install.db.config.starterdb.memoryLimit=2048  
  201.   
  202. #------------------------------------------------------------------------------  
  203. # This variable controls whether to load Example Schemas onto the starter  
  204. # database or not.  
  205. #------------------------------------------------------------------------------  
  206. oracle.install.db.config.starterdb.installExampleSchemas=false  
  207.   
  208. #------------------------------------------------------------------------------  
  209. # This variable includes enabling audit settings, configuring password profiles  
  210. # and revoking some grants to public. These settings are provided by default.   
  211. # These settings may also be disabled.      
  212. #------------------------------------------------------------------------------  
  213. oracle.install.db.config.starterdb.enableSecuritySettings=true  
  214.   
  215. ###############################################################################  
  216. #                                                                             #  
  217. # Passwords can be supplied for the following four schemas in the         #  
  218. # starter database:                                   #  
  219. #   SYS                                                                       #  
  220. #   SYSTEM                                                                    #  
  221. #   SYSMAN (used by Enterprise Manager)                                       #  
  222. #   DBSNMP (used by Enterprise Manager)                                       #  
  223. #                                                                             #  
  224. # Same password can be used for all accounts (not recommended)            #  
  225. # or different passwords for each account can be provided (recommended)       #  
  226. #                                                                             #  
  227. ###############################################################################  
  228.   
  229. #------------------------------------------------------------------------------  
  230. # This variable holds the password that is to be used for all schemas in the  
  231. # starter database.  
  232. #-------------------------------------------------------------------------------  
  233. oracle.install.db.config.starterdb.password.ALL=我的密码  
  234.   
  235. #-------------------------------------------------------------------------------  
  236. # Specify the SYS password for the starter database.  
  237. #-------------------------------------------------------------------------------  
  238. oracle.install.db.config.starterdb.password.SYS=  
  239.   
  240. #-------------------------------------------------------------------------------  
  241. # Specify the SYSTEM password for the starter database.  
  242. #-------------------------------------------------------------------------------  
  243. oracle.install.db.config.starterdb.password.SYSTEM=  
  244.   
  245. #-------------------------------------------------------------------------------  
  246. # Specify the SYSMAN password for the starter database.  
  247. #-------------------------------------------------------------------------------  
  248. oracle.install.db.config.starterdb.password.SYSMAN=  
  249.   
  250. #-------------------------------------------------------------------------------  
  251. # Specify the DBSNMP password for the starter database.  
  252. #-------------------------------------------------------------------------------  
  253. oracle.install.db.config.starterdb.password.DBSNMP=  
  254.   
  255. #-------------------------------------------------------------------------------  
  256. # Specify the management option to be selected for the starter database.   
  257. # It can be one of the following:  
  258. # 1. GRID_CONTROL  
  259. # 2. DB_CONTROL  
  260. #-------------------------------------------------------------------------------  
  261. oracle.install.db.config.starterdb.control=DB_CONTROL  
  262.   
  263. #-------------------------------------------------------------------------------  
  264. # Specify the Management Service to use if Grid Control is selected to manage   
  265. # the database.        
  266. #-------------------------------------------------------------------------------  
  267. oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=  
  268.   
  269. #-------------------------------------------------------------------------------  
  270. # This variable indicates whether to receive email notification for critical   
  271. # alerts when using DB control.     
  272. #-------------------------------------------------------------------------------  
  273. oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false  
  274.   
  275. #-------------------------------------------------------------------------------  
  276. # Specify the email address to which the notifications are to be sent.  
  277. #-------------------------------------------------------------------------------  
  278. oracle.install.db.config.starterdb.dbcontrol.emailAddress=  
  279.   
  280. #-------------------------------------------------------------------------------  
  281. # Specify the SMTP server used for email notifications.  
  282. #-------------------------------------------------------------------------------  
  283. oracle.install.db.config.starterdb.dbcontrol.SMTPServer=  
  284.   
  285.   
  286. ###############################################################################  
  287. #                                                                             #  
  288. # SPECIFY BACKUP AND RECOVERY OPTIONS                                         #  
  289. # ------------------------------------                                    #  
  290. # Out-of-box backup and recovery options for the database can be mentioned    #  
  291. # using the entries below.                            #   
  292. #                                                                             #  
  293. ###############################################################################  
  294.   
  295. #------------------------------------------------------------------------------  
  296. # This variable is to be set to false if automated backup is not required. Else   
  297. # this can be set to true.  
  298. #------------------------------------------------------------------------------  
  299. oracle.install.db.config.starterdb.automatedBackup.enable=false  
  300.   
  301. #------------------------------------------------------------------------------  
  302. # Regardless of the type of storage that is chosen for backup and recovery, if   
  303. # automated backups are enabled, a job will be scheduled to run daily at  
  304. # 2:00 AM to backup the database. This job will run as the operating system   
  305. # user that is specified in this variable.  
  306. #------------------------------------------------------------------------------  
  307. oracle.install.db.config.starterdb.automatedBackup.osuid=  
  308.   
  309. #-------------------------------------------------------------------------------  
  310. # Regardless of the type of storage that is chosen for backup and recovery, if   
  311. # automated backups are enabled, a job will be scheduled to run daily at  
  312. # 2:00 AM to backup the database. This job will run as the operating system user  
  313. # specified by the above entry. The following entry stores the password for the  
  314. # above operating system user.  
  315. #-------------------------------------------------------------------------------  
  316. oracle.install.db.config.starterdb.automatedBackup.ospwd=  
  317.   
  318. #-------------------------------------------------------------------------------  
  319. # Specify the type of storage to use for the database.  
  320. # It can be one of the following:  
  321. # - FILE_SYSTEM_STORAGE  
  322. # - ASM_STORAGE  
  323. #------------------------------------------------------------------------------  
  324. oracle.install.db.config.starterdb.storageType=  
  325.   
  326. #-------------------------------------------------------------------------------  
  327. # Specify the database file location which is a directory for datafiles, control  
  328. # files, redo logs.           
  329. #  
  330. # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM   
  331. #-------------------------------------------------------------------------------  
  332. oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=  
  333.   
  334. #-------------------------------------------------------------------------------  
  335. # Specify the backup and recovery location.  
  336. #  
  337. # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM   
  338. #-------------------------------------------------------------------------------  
  339. oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=  
  340.   
  341. #-------------------------------------------------------------------------------  
  342. # Specify the existing ASM disk groups to be used for storage.  
  343. #  
  344. # Applicable only when oracle.install.db.config.starterdb.storage=ASM  
  345. #-------------------------------------------------------------------------------  
  346. oracle.install.db.config.asm.diskGroup=  
  347.   
  348. #-------------------------------------------------------------------------------  
  349. # Specify the password for ASMSNMP user of the ASM instance.                    
  350. #  
  351. # Applicable only when oracle.install.db.config.starterdb.storage=ASM_SYSTEM   
  352. #-------------------------------------------------------------------------------  
  353. oracle.install.db.config.asm.ASMSNMPPassword=  
  354.   
  355. #------------------------------------------------------------------------------  
  356. # Specify the My Oracle Support Account Username.  
  357. #  
  358. #  Example   : MYORACLESUPPORT_USERNAME=metalink  
  359. #------------------------------------------------------------------------------  
  360. MYORACLESUPPORT_USERNAME=  
  361.   
  362. #------------------------------------------------------------------------------  
  363. # Specify the My Oracle Support Account Username password.  
  364. #  
  365. # Example    : MYORACLESUPPORT_PASSWORD=password  
  366. #------------------------------------------------------------------------------  
  367. MYORACLESUPPORT_PASSWORD=  
  368.   
  369. #------------------------------------------------------------------------------  
  370. # Specify whether to enable the user to set the password for  
  371. # My Oracle Support credentials. The value can be either true or false.  
  372. # If left blank it will be assumed to be false.  
  373. #  
  374. # Example    : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true  
  375. #------------------------------------------------------------------------------  
  376. SECURITY_UPDATES_VIA_MYORACLESUPPORT=  
  377.   
  378. #------------------------------------------------------------------------------  
  379. # Specify whether user wants to give any proxy details for connection.   
  380. # The value can be either true or false. If left blank it will be assumed  
  381. # to be false.  
  382. #  
  383. # Example    : DECLINE_SECURITY_UPDATES=false  
  384. #------------------------------------------------------------------------------  
  385. DECLINE_SECURITY_UPDATES=true  
  386.   
  387. #------------------------------------------------------------------------------  
  388. # Specify the Proxy server name. Length should be greater than zero.  
  389. #  
  390. # Example    : PROXY_HOST=proxy.domain.com   
  391. #------------------------------------------------------------------------------  
  392. PROXY_HOST=  
  393.   
  394. #------------------------------------------------------------------------------  
  395. # Specify the proxy port number. Should be Numeric and atleast 2 chars.  
  396. #  
  397. # Example    : PROXY_PORT=25   
  398. #------------------------------------------------------------------------------  
  399. PROXY_PORT=  
  400.   
  401. #------------------------------------------------------------------------------  
  402. # Specify the proxy user name. Leave PROXY_USER and PROXY_PWD   
  403. # blank if your proxy server requires no authentication.  
  404. #  
  405. # Example    : PROXY_USER=username   
  406. #------------------------------------------------------------------------------  
  407. PROXY_USER=  
  408.   
  409. #------------------------------------------------------------------------------  
  410. # Specify the proxy password. Leave PROXY_USER and PROXY_PWD    
  411. # blank if your proxy server requires no authentication.  
  412. #  
  413. # Example    : PROXY_PWD=password   
  414. #------------------------------------------------------------------------------  
  415. PROXY_PWD=  

步骤二:安装Oracle
[2-1]oracle账号登陆
在/home/oracle/database路径下执行
“./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp”开始安装


[2-2]出现[FATAL] [INS-32012] Unable to create directory.错误提示
“chown oracle /opt”命令,修改/opt的所有者为oracle.


[2-3]再运行“./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp”开始安装
出现[FATAL] [INS-13013] Target environment do not meet some mandatory requirements.错误
使用下面的命令重试
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/database/response/db_install.rsp
等待几分钟后出现“Successfully Setup Software.”提示。

安装好后会出现“/opt/Oracle/admin/orcl11g/pfile”文件夹,其中“orcl11g”是你oracle的SID,需要在环境变量中设置

否则启动listener会失败。



[2-4]按照提示以root身份登录CentOS7系统
执行下面两条命令
/opt/oraInventory/orainstRoot.sh
/opt/oracle/product/11.2.0/db_1/root.sh



[2-5]以oracle身份登录CentOS7系统,设置环境变量
vi ~/.bash_profile
追加下面的配置信息
export PATH
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_SID=orcl11g

export TNS_ADMIN=$ORACLE_HOME/network/admin

使用下面命令使环境变量生效
source ~/.bash_profile


为了使sqlplus能够访问远程oracle数据库,不但要配置“TNS_ADMIN”环境变量,还需要

要环境变量指向的地址(我这里是/opt/oracle/product/11.2.0/db_1/network/admin/)中放入tnsnames.ora文件

下面是我tnsnames.ora的内容,其中orcl是数据库名字。

[html] view plain copy
  1. alioracle =  
  2.   (DESCRIPTION =  
  3.     (ADDRESS_LIST =  
  4.       (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))  
  5.     )  
  6.     (CONNECT_DATA =  
  7.       (SERVICE_NAME = orcl)  
  8.     )  
  9.   )  
因为配置好了TNS,以后你也可以参考下面的命令导入数据

imp kagula/123456@alioracle  file=/home/oracle/kagula20160612.dmp full=y
kagula是用户名,123456是用户密码,alioracle是上面指定的连接名。


[2-6]建库
用oracle账号调用下面的命令
“dbca -silent -responseFile /home/oracle/database/response/dbca.rsp”
出现安装进度,需要等待几分钟。


步骤三:验证Oracle安装是否成功
[3-1]
“su - u oracle”转到oracle账户下。
sqlplus "/as sysdba"  进入SQL提示符状态
select * from tabs;
如果成功运行,表示oracle已经启来,否则需要运行“startup”命令启动oracle.


[3-2]
“/opt/oracle/product/11.2.0/db_1/network/admin”路径下新建listener.ora文件
内容如下
[html] view plain copy
  1. # copyright (c) 1997 by the Oracle Corporation  
  2. #   
  3. # NAME  
  4. #   listener.ora  
  5. # FUNCTION  
  6. #   Network Listener startup parameter file example  
  7. # NOTES  
  8. #   This file contains all the parameters for listener.ora,  
  9. #   and could be used to configure the listener by uncommenting  
  10. #   and changing values.  Multiple listeners can be configured  
  11. #   in one listener.ora, so listener.ora parameters take the form  
  12. #   of SID_LIST_<lsnr>, where <lsnr> is the name of the listener  
  13. #   this parameter refers to.  All parameters and values are  
  14. #   case-insensitive.  
  15.   
  16. <lsnr>  
  17. #   This parameter specifies both the name of the listener, and  
  18. #   it listening address(es). Other parameters for this listener  
  19. #   us this name in place of <lsnr>.  When not specified,  
  20. #   the name for <lsnr> defaults to "LISTENER", with the default  
  21. #   address value as shown below.  
  22. #  
  23. LISTENER =  
  24. #  (ADDRESS_LIST=  
  25. #   (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))  
  26. #   (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))     
  27. LISTENER=(DESCRIPTION_LIST=(DESCRIPTION=  
  28.       (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.153.133)(PORT=1521))    
  29.   )  
  30. )  
  31.   
  32. # SID_LIST_<lsnr>  
  33. #   List of services the listener knows about and can connect   
  34. #   clients to.  There is no default.  See the Net8 Administrator's  
  35. #   Guide for more information.  
  36. #  
  37. SID_LIST_LISTENER=  
  38. #   (SID_LIST=  
  39. #   (SID_DESC=  
  40. #           #BEQUEATH CONFIG  
  41. #          (GLOBAL_DBNAME=salesdb.mycompany)  
  42. #          (SID_NAME=sid1)            
  43. #          (ORACLE_HOME=/private/app/oracle/product/8.0.3)  
  44. #           #PRESPAWN CONFIG  
  45. #         (PRESPAWN_MAX=20)  
  46. #     (PRESPAWN_LIST=  
  47. #           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))  
  48. #         )  
  49. #        )  
  50. #       )  
  51.   
  52. SID_LIST_LISTENER=  
  53.   (SID_LIST=  
  54.       (SID_DESC=  
  55.          (GLOBAL_DBNAME=orcl)  
  56.          (SID_NAME=orcl11g)  
  57.          (ORACLE_HOME=/opt/oracle/product/11.2.0/db_1)  
  58.         (PRESPAWN_MAX=20)  
  59.         (PRESPAWN_LIST=  
  60.           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))  
  61.         )  
  62.        )  
  63.       )  
  64.       
  65. # PASSWORDS_<lsnr>  
  66. #   Specifies a password to authenticate stopping the listener.  
  67. #   Both encrypted and plain-text values can be set.  Encrypted passwords  
  68. #   can be set and stored using lsnrctl.    
  69. #     LSNRCTL> change_password  
  70. #       Will prompt for old and new passwords, and use encryption both  
  71. #       to match the old password and to set the new one.  
  72. #     LSNRCTL> set password  
  73. #   Will prompt for the new password, for authentication with   
  74. #       the listener. The password must be set before running the next  
  75. #       command.  
  76. #     LSNRCTL> save_config  
  77. #       Will save the changed password to listener.ora. These last two  
  78. #       steps are not necessary if SAVE_CONFIG_ON_STOP_<lsnr> is ON.  
  79. #       See below.  
  80. #  
  81. # Default: NONE  
  82. #  
  83. PASSWORDS_LISTENER = 20A22647832FB454      # "foobar"  
  84.   
  85. # SAVE_CONFIG_ON_STOP_<lsnr>  
  86. #   Tells the listener to save configuration changes to listener.ora when  
  87. #   it shuts down.  Changed parameter values will be written to the file,  
  88. #   while preserving formatting and comments.  
  89. # Default: OFF  
  90. # Values: ON/OFF  
  91. #  
  92. SAVE_CONFIG_ON_STOP_LISTENER = ON  
  93.   
  94. # USE_PLUG_AND_PLAY_<lsnr>  
  95. #   Tells the listener to contact an Onames server and register itself  
  96. #   and its services with Onames.  
  97. # Values: ON/OFF  
  98. # Default: OFF  
  99. #  
  100. USE_PLUG_AND_PLAY_LISTENER = ON  
  101.   
  102. # LOG_FILE_<lsnr>  
  103. #   Sets the name of the listener's log file.  The .log extension  
  104. #   is added automatically.  
  105. Default=<lsnr>  
  106. #  
  107. LOG_FILE_LISTENER = lsnr  
  108.   
  109. # LOG_DIRECTORY_<lsnr>  
  110. #   Sets the directory for the listener's log file.  
  111. # Default: <oracle_home>/network/log  
  112. #  
  113. LOG_DIRECTORY_LISTENER = /private/app/oracle/product/8.0.3/network/log  
  114.   
  115. # TRACE_LEVEL_<lsnr>  
  116. #   Specifies desired tracing level.  
  117. # Default: OFF  
  118. # Values: OFF/USER/ADMIN/SUPPORT/0-16  
  119. #  
  120. TRACE_LEVEL_LISTENER = SUPPORT  
  121.   
  122. # TRACE_FILE_<lsnr>  
  123. #   Sets the name of the listener's trace file. The .trc extension  
  124. #   is added automatically.  
  125. # Default: <lsnr>  
  126. #  
  127. TRACE_FILE_LISTENER = lsnr  
  128.   
  129. # TRACE_DIRECTORY_<lsnr>  
  130. #   Sets the directory for the listener's trace file.  
  131. # Default: <oracle_home>/network/trace  
  132. #  
  133. TRACE_DIRECTORY_LISTENER=/private/app/oracle/product/8.0.3/network/trace  
  134. # CONNECT_TIMEOUT_<lsnr>  
  135. #   Sets the number of seconds that the listener waits to get a   
  136. #   valid database query after it has been started.  
  137. # Default: 10  
  138. #  
  139. CONNECT_TIMEOUT_LISTENER=10  
  140.     


其中HOST中的地址要改成你CentOS7机器的IP地址,否则“lsnrctl start”命令启动侦听器,会报TNS-01189错误。


[3-3]在windows系统上测试CentOS7服务器上的Oracle是否可以链接
在Windows操作系统上下载win64_11gR2_client.zip解压缩后
admin模式下用"setup  -ignoreSysPrereqs"命令安装。


参考《Oracle的tnsnames.ora配置(PLSQL Developer)》
http://jingyan.baidu.com/article/b0b63dbfcd34834a4930704a.html
链接服务器,如果遇到超时错误
服务器执行“systemctl stop firewalld”临时关闭防火墙试试看。
这里奇怪的是执行“firewall-cmd --permanent --query-port=1521/tcp”命令看到端口已经开放,
后来发现得用“firewall-cmd  --list-all”命令才能真正看到端口是否开放。

Appendix:

[1]如何安装缺少的命令
yum search  command-name  #查找命令所在的包
yum install package-name  #安装包

Reference:

[1]《Oracle的tnsnames.ora配置(PLSQL Developer)》
http://jingyan.baidu.com/article/b0b63dbfcd34834a4930704a.html


[2]《PLSQL怎么创建oracle数据库用户》
http://jingyan.baidu.com/album/375c8e1997522e25f2a229c3.html?picindex=5


[3]Windows 7 64位PL/SQL Developer 连接Oracle 11g
http://blog.sina.com.cn/s/blog_5f9f04130101jqhu.html
原创粉丝点击