本文摘自http://www.cnblogs.com/yingsong/p/6031235.html
至于swap如何添加,后文将提到
1 2 | grep MemTotal /proc/meminfo grep SwapTotal /proc/meminfo |
--设置主机名,也可以直接修改配置文件/etc/sysconfig/network,不过这个是重启之后才起作用
#sed -i"s/HOSTNAME=localhost.localdomain/HOSTNAME=DB_2/g"/etc/sysconfig/network
--如果不想重启,则使用下面命令,使当前生效
#hostname DB_2
--添加主机名与IP对应记录
#vi /etc/hosts 10.10.0.48 DB_2
--我自己没有关闭过selinux,这个是网上提供说需要关闭的
# sed -i"s/SELINUX=enforcing/SELINUX=disabled/"/etc/selinux/config # setenforce 0
两个包全都下载下下来
放在你的工具目录
[oracle@bogon ~]$ cd /home/tools/ [oracle@bogon tools]$ ls linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
--修改或添加,具体参数意思,请百度或参考oracle官网解释
#vi/etc/sysctl.conf net.ipv4.ip_local_port_range=9000 65500 fs.file-max = 6815744 kernel.shmall = 10523004 kernel.shmmax = 6465333657 kernel.shmmni = 4096 kernel.sem = 250 32000 100128 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_max=1048576 fs.aio-max-nr = 1048576 # sysctl -p #使配置生效
#vim /etc/security/limits.conf 在文件后增加 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
--修改/etc/pam.d/login文件,增加如下:
session required /lib64/security/pam_limits.so //64为系统,千万别写成/lib/security/pam_limits.so,否则导致无法登录 session required pam_limits.so
//创建用户及组
#groupadd oinstall #groupadd dba #useradd -g oinstall -G dba -d /home/oracle oracle #passwd oracle
//创建安装目录
#mkdir -p /opt/app/oracle/product/11.2.0/dbhome_1
//数据文件存放目录
#mkdir -p /opt/app/oracle/oradata
//数据恢复目录
#mkdir -p /opt/app/oracle/recovery_area
//数据库创建及使用过程中的日志目录
#mkdir -p /opt/app/oracle/oraInventory
//修改安装目录权限
#chown -R oracle:oinstall /opt/app/oracle #chmod 775 /opt/app/oracle
//登录oracle用户,设置环境变量
#su - oracle $viw .bash_profile exportORACLE_BASE=/opt/app/oracle exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 exportPATH=$PATH:$ORACLE_HOME/bin exportCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64 export ORACLE_SID=wetalk //如果设置NLS_LANG,容易产生导入sql或dmp出错,因为其他环境下的不是utf8 我没设置 exportNLS_LANG=AMERICAN_AMERICA.AL32UTF8 $source .bash_profile //使设置生效
# yum -y install gcc gcc-c++ makebinutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-develglibcglibc-commonglibc-devel libaio libaio-devel libgcclibstdc++libstdc++-develunixODBC unixODBC-devel ksh 或 (我用的上者) # yum -y installbinutils compat-libstdc++-33compat-libstdc++-33.i686 elfutils-libelfelfutils-libelf-devel gcc gcc-c++glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686glibc-headers kshlibaio libaio.i686 libaio-devel libaio-devel.i686 libgcclibgcc.i686 libstdc++libstdc++.i686 libstdc++-devel make sysstat unixODBC unixODBC-devel
[oracle@bogon tools]$ ls linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip [oracle@bogon tools]$ mkdir /opt/database [oracle@bogon tools]$ unziplinux.x64_11gR2_database_1of2.zip -d /opt/database/ [oracle@bogon tools]$ unziplinux.x64_11gR2_database_2of2.zip -d /opt/database/
db_install.rsp 安装应答配置文件
dbca.rsp 创建数据库应答
etca.rsp 建立监听、本地服务名等网络设置应答
下面把主要修改的地方贴出来,具体详细文件,请查看另一篇文章:【Oracle 11gR2】db_install.rsp详解】http://www.cnblogs.com/yingsong/p/6031452.html
这是主要修改的配置
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=DB_m2 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/opt/app/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1 ORACLE_BASE=/opt/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oinstall oracle.install.db.config.starterdb.characterSet=AL32UTF8 oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/opt/app/oracle/oradata oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/opt/app/oracle/recovery_data DECLINE_SECURITY_UPDATES=true //一定要设为true
[oracle@bogon tools]$ cd /opt/database/database/ [oracle@bogon database]$ ls doc install response rpm runInstaller sshsetup stage welcome.html [oracle@bogon database]$./runInstaller -silent-responseFile /opt/database/database/response/db_install.rsp
//安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。
//打开另一个终端,执行命令
#tail -100 f /u01/app/oracle/oraInventory/logs/installActions......log
//可以实时跟踪查看安装日志,了解安装的进度。
//当出现
以下配置脚本需要以 "root" 用户的身份执行。 #!/bin/sh #要运行的 Root 脚本 /u01/app/oracle/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/db_1/root.sh 要执行配置脚本, 请执行以下操作: 1. 打开一个终端窗口 2. 以 "root" 身份登录 3. 运行脚本 4. 返回此窗口并按 "Enter" 键继续 Successfully Setup Software. 回到root执行 su - root /u01/app/oracle/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/db_1/root.sh
//出现这个的话,说明已安装成功,则需要按提示操作,操作完返回Enter成功
执行命令
netca /silent/responsefile /opt/database/database/response/netca.rsp
正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /home/oracle/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle NetServices 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
正在运行监听程序控制:
/opt/oracle/11.2.0/bin/lsnrctl start LISTENER
监听程序控制完成。
监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置
netca命令可能不存在需要在 oracle的家目录下的.bash_profile中配置
//成功运行后,在/opt/oracle/11.2.0/network/admin目录下生成sqlnet.ora和listener.ora两个文件。 //完成后通过命令“netstat -tlnp”可以查看到1521端口已开 tcp 0 0 :::1521 :::* LISTEN 5477/tnslsnr
vim /opt/database/database/response/dbca.rsp RESPONSEFILE_VERSION = "11.2.0" //不能更改 OPERATION_TYPE = "createDatabase" GDBNAME ="hello.dlxg.gov.cn" //全局数据库的名字=SID+主机域名 SID ="hello" //对应的实例名字 TEMPLATENAME= "General_Purpose.dbc" //建库用的模板文件 DATAFILEDESTINATION = /opt/oracle/oradata //数据文件存放目录 RECOVERYAREADESTINATION=/opt/oracle/recovery_data//恢复数据存放目录 CHARACTERSET= "AL32UTF8" //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。 TOTALMEMORY= "5120" //oracle内存5120MB
配置完之后,执行命令
dbca -silent -responseFile /opt/database/database/response/dbca.rsp
此时会清空所有 然后输入你要连接的密码 默认的用户是system 输入两次密码之后静静等待
1% 已完成 3% 已完成 11% 已完成 18% 已完成 26% 已完成 37% 已完成 正在创建并启动 Oracle 实例 40% 已完成 45% 已完成 50% 已完成 55% 已完成 56% 已完成 60% 已完成 62% 已完成 正在进行数据库创建 66% 已完成 70% 已完成 73% 已完成 85% 已完成 96% 已完成 100% 已完成 有关详细信息, 请参阅日志文件"/u01/app/oracle/cfgtoollogs/dbca/wang/wang.log"。 查看日志文件
$ cat/u01/app/oracle/cfgtoollogs/dbca/wang/wang.log
此时数据库已经安装完成
五. 开启归档模式,制定归档目录
具体请查看另一篇文章:【开启归档模式,归档日志已满处理】http://www.cnblogs.com/yingsong/p/6037531.html
启动关闭命令详解http://www.cnblogs.com/NaughtyBoy/archive/2013/07/09/3180947.html
[oracle@bogon ~]$ sqlplus " / as sysdba" SQL> startup 启动 ORACLE instance started. Total System Global Area 5344731136 bytes Fixed Size 2213136 bytes Variable Size 3019901680 bytes Database Buffers 2281701376 bytes Redo Buffers 40914944 bytes Database mounted. Database opened. [oracle@bogon ~]$ lsnrctl start 打开监听 LSNRCTL for Linux: Version 11.2.0.1.0 - Productionon 18-OCT-2017 10:42:14 Copyright (c) 1991, 2009, Oracle. All rights reserved. TNS-01106: Listener using listener name LISTENERhas already been started
oracle用户执行
export DISPLAY=172.16.128.163:1.0
xhost +
如果报错
[oracle@bogon database]$ xhost +
xhost: unable to open display ""
安装vnc
yum install -y vncserver
yum install tigervnc-server
启动vnc
vncserver
此时会输入密码2次
再次执行
export DISPLAY=172.16.128.163:1.0
xhost +
实在不行百度吧 我也是百度了半天才弄出来
http://blog.itpub.net/20674423/viewspace-711545根据这个博客操作
然后 重启oracle就行了
/opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE
[oracle@bogon dbs]$ ls
hc_DBUA0.dat hc_oracle.dat hc_wetalk.dat init.ora initwetalk.ora lkORACLE orapworacle spfileoracle.ora
回到root
[root@bogon ~]# fuser -ulkORACLE
无法分析 lkORACLE: 没有那个文件或目录
无法分析 lkORACLE: 没有那个文件或目录
[root@bogon~]# fuser -u/opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE
/opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE: 2052(oracle) 2058(oracle) 2063(oracle) 2065(oracle) 2069(oracle) 2071(oracle) 2073(oracle) 2075(oracle) 2077(oracle) 2079(oracle) 2081(oracle) 2083(oracle) 2085(oracle) 2109(oracle) 2130(oracle) 2132(oracle) 2134(oracle) 2180(oracle) 2506(oracle)
[root@bogon ~]# fuser -k /opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE
/opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE: 2052 2058 2063 2065 2069 2071 2073 2075 2077 2079 2081 2083 2085 2109 2130 2132 2134 2180 2506
[root@bogon ~]# fuser -u/opt/app/oracle/product/11.2.0/db_1/dbs/lkORACLE
[root@bogon ~]# su - oracle
[oracle@bogon ~]$ sqlplus " / as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct18 10:41:31 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP,Data Mining,
Oracle Database Vault and Real Application Testingoptions
SQL> shutdown
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 5344731136 bytes
Fixed Size 2213136 bytes
Variable Size 3019901680 bytes
Database Buffers 2281701376 bytes
Redo Buffers 40914944 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 11g EnterpriseEdition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP,Data Mining,
Oracle Database Vault and Real Application Testingoptions
[oracle@bogon ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Productionon 18-OCT-2017 10:42:14
Copyright (c) 1991, 2009, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENERhas already been started
本文出自 “蓝叶子_架构” 博客,请务必保留此出处http://dellinger.blog.51cto.com/12445009/1973696
原文:http://dellinger.blog.51cto.com/12445009/1973696