Linux oracle10g 静默安装

浏览:
字体:
发布时间:2013-12-09 23:23:51
来源:

两天加一个通宵的劳动成果,和大家分享。。。开始本来是用图形界面安装的,奈何Linux系统中并未安装图形界面所需接口、软件,故改为静默安装;另外吐槽下,网上好多文档着实让俺走了不少弯路。。。

 

项目上线,客户要iq文档,下面摘出oracle安装部分。

 

检查Linux系统配置(内存、硬盘)神马的就不说 ,一般都是满足的,除非是哥们你用自己电脑搞着玩。。。

 

安装oracle 10g 数据库

 

1、 下载oracle文件到/root目录并解压

cd /root

wget –c http://nadmin.haott.com/oracle_linux32.zip (此处我的安装包在另一台服务器上,故需下载到被安装的服务器)

unzip ./oracle_linux32.zip(解压)

 

2、 参数设置

OS参数要求vi /etc/sysctl.conf , 在行末添加以下内容

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default=262144

net.core.rmem_max=262144

net.core.wmem_default=262144

net.core.wmem_max=262144

运行sysctl -p应用以上参数, /sbin/sysctl -p ,结果如下:

/

 

vi /etc/security/limits.conf 行末添加以下内容:

#use for oracle

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

 

vi /etc/pam.d/login 行末添加以下内容

session required /lib/security/pam_limits.so

注意:如果你的操作系统是x64的则为session required /lib64/security/pam_limits.so

否则系统拒绝登录

 

vi /etc/selinux/config 确保以下内容,关闭SELIINUX

SELINUX=disabled

 

如果是c shell,则环境变量文件 /etc/csh.login的修改值如下(此处若不确定,跳过):

if ( /$USER == "oracle" ) then

limit maxproc 16384

limit descriptors 65536

umask 022

endif

 

在/etc/profile里添加如下行

vi /etc/profile

export LIBXCB_ALLOW_SLOPPY_LOCK=true

if [ $USER = "oracle" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

umask 022

fi

使用命令source profile使环境变量生效

source /etc/profile

 

3、 创建用户及组

groupadd oinstall

groupadd dba

useradd -g oinstall -G dba oracle

passwd oracle

 

4、 创建目录

mkdir -p /u01/app/oracle/product/10.2.0/db_1

chown -R oracle.oinstall /u01

chmod -R 755 /u01

 

5、 创建oracle profile文件

su – oracle

vi /home/oracle/.bash_profile 用oracle用户编辑加入以下内容

#Oracle Settings umask 022;

export ORACLE_BASE=/u01/app/oracle;

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;

export ORACLE_SID=TSH1;

export PATH=$ORACLE_HOME/bin:$PATH;

export LANG=en_US.UTF-8

source .bash_profile

然后再设置本地字符集型export LANG=en_US.UTF-8

 

6、 安装依赖包 (此处选择在线安装,因为某个包可能会依赖其它几个包)

以root用户运行

su root

cd /etc/yum.repos.d

wget http://www.linuxidc.com/files/2011/05/06/CentOS-Base.repo

通过yum在线安装

yum -y install openmotif

yum -y install compat-db

yum -y install compat-gcc-34

yum -y install compat-libstdc++-33

yum -y install compat-libstdc++-296

yum -y install sysstat

yum -y install libXp libaio

yum -y install libaio-devel

yum -y install compat-libgcc*

yum -y install compat-gcc* --skip-broken

yum -y install libXp

yum -y install libXtst

 

7、 修改vi /etc/redhat-release文件,如下:

Red Hat Enterprise Linux AS release 4 (Nahant Update 4)

 

8、 配置inittab

vi /etc/inittab

把 id:5:initdefault: 修改为 id:3:initdefault 注意:改为3是没有图形化界面的 5是有的

 

9、配置静态ip (此步可选择跳过,我安装时没有执行)

linux系统在安装时若无更改,系统的网络默认为DHCP,若想将IP设置为静态的IP该怎么办呢?如安装

Oracle时,就被要求配置静态IP(Oracle吃内存,吃硬盘容量,需要一堆rpm包支持,IP也是那么的挑剔,苦哇~)。

今天在自己的笔记本上对RedHat Linux进行了上网配置,一切还算顺利。原来在Linux下配置网络也挺简单的。

步骤如下:

配置文件位于:

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

ROOTPROTO=static

HWADDR=00:0C:29:A3:2C:FB

ONBOOT=yes

NETMASK=255.255.255.0 -- redhat linux 子网掩码

IPADDR=192.168.0.6 -- redhat linux 的IP地址

GATEWAY=192.168.0.1 -- redhat linux的默认网关跟windows主机的默认网关是一致的

TYPE=Ethernet

USERCTL=no

IPV6INIT=no

PEERDNS=yes

将上面的IPADDR和GATEWAY换成自己的就可以了。也可以设置MAC的逻辑地址(地址欺骗),在上面的配置文件中加一行

HWADDR=你想填的MAC地址。

最后运行两个命令使新的设置生效

/sbin/ifdown ifcfg-eth0

/sbin/ifup ifcfg-eth0

 

还需配置DNS的主机名为 localhost.localdomain

主DNS解析域名为:202.96.209.5

第二DNS为:202.96.209.133 DNS

搜寻路径:ocaldomain

不然在安装的过程中同样会报checking network configuration requirements is: Not executed的错误提示

还需修改 vi /etc/hosts 文件

在安装oracle 10g的过程中,遇到了checking network configuration requirements is: Not executed的错误提示。发现是

/etc/hosts中没有指定静态ip地址导致,检测/etc/hosts发现果真如此,修改如下配置

127.0.0.1 localhost.localdomain localhost

#::1

192.168.18.192 localhost6.localdomain6 localhost6

---192.168.18.192是linux redhat 的ip地址不是windows ip 地址

重新检测,显示正常

需要将虚拟机连接方式设置为:桥接,而不是NAT,Host-only 的连接方式,不然也不能上网

 

10、 配置enterprise.rsp文件

mv /root/database /home/oracle/

chown –R oracle:oinstall /home/oracle/database

vi /home/oracle/database/response/enterprise.rsp

修改以下值

RESPONSEFILE_VERSION=2.2.1.0.0

UNIX_GROUP_NAME="oinstall"

ORACLE_HOME_NAME="OraDb10g_home1"

ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1"

SHOW_INSTALL_PROGRESS_PAGE= true

SHOW_END_OF_INSTALL_MSGS= true

COMPONENT_LANGUAGES={"zh_CN"}

s_nameForDBAGrp= "dba"

s_nameForOPERGrp="dba"

INSTALL_TYPE="EE"

n_configurationOption=3

RESTART_SYSTEM=false

RESTART_REMOTE_SYSTEM=false

说明:这几项要视情况而定比如说 UNIX_GROUP_NAME="oinstall" 和s_nameForDBAGrp= "dba" s_nameForOPERGrp="dba"还有环境变量都要参照前面自己定义好的来

 

11、正式安装

su - oracle

/home/oracle/database/runInstaller -silent -responseFile /home/oracle/database/response/enterprise.rsp

Installation in progress (Mon Sep 21 23:37:00 CST 2009)

............................................................... 18% Done.

............................................................... 36% Done.

............................................................... 54% Done.

............................................................... 72% Done.

................ 76% Done.

Install successful

Linking in progress (Mon Sep 21 23:39:49 CST 2009)

Link successful

Setup in progress (Mon Sep 21 23:43:11 CST 2009)

.............. 100% Done.

Setup successful

End of install phases.(Mon Sep 21 23:43:20 CST 2009)

WARNING:A new inventory has been created in this session. However, it has not yet been

registered as the central inventory of this system.

To register the new inventory please run the script

'/u01/app/oracle/oraInventory/orainstRoot.sh' with root privileges.

If you do not register the inventory, you may not be able to update or patch the products you installed.

The following configuration scripts /u01/app/oracle/product/10.2.0/db_1/root.sh

need to be executed as root for configuring the system. If you skip the execution of the

configuration tools, the configuration will not be complete and the product wont function

properly.

In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.

The installation of Oracle Database 10g was successful.

(恭喜你成功了如果没这个提示就看看他说的日志继续修改下ok)

Please check '/u01/app/oracle/oraInventory/logs/silentInstall2009-09-21_11-36-22PM.log' for more details.

 

12、接下来按提示操作, root身份登录

su root

sh /u01/app/oracle/oraInventory/orainstRoot.sh

sh /u01/app/oracle/product/10.2.0/db_1/root.sh

 

13、安装网络监听器

vi /home/oracle/database/response/netca.rsp

修改以下值:

INSTALL_TYPE=""custom"" #安装的类型

LISTENER_NUMBER=1 #监听器数量

LISTENER_NAMES={"LISTENER"} #监听器的名称列表

LISTENER_PROTOCOLS={"TCP;1521"} # 监听器使用的通讯协议列表

LISTENER_START=""LISTENER"" # 监听器启动的名称

 

su - oracle

$ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/database/response/netca.rsp

注意:此处可能会有错误 oracle 需要的软件包不全。

请根据 1 中列出的软件包,确保所有的软件包都已经正确安装( 2 ) 6 中对 gennttab 文件的修改不正确,本人就是没有去掉 n 后的空格导致了该错误。

如下报的缺少libXtst包

Exception in thread "main" java.lang.UnsatisfiedLinkError: /u01/app/oracle/product/10.2.0/db_1/jdk/jre/lib/i386/libawt.so: libXtst.so.6: cannot open shared object file:

用yum下载安装即可解决

[root@oraclebk ~]# yum install libXp

 

14、修改 dbstart

vi $ORACLE_HOME/bin/dbstart

ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

改为:

ORACLE_HOME_LISTNER=$ORACLE_HOME

确保数据库启动时,网络监听器同时启动。

 

15、增加数据实例

vi /home/oracle/database/response/dbca.rsp

根据数据库建立方式的不同编辑不同的数据库库选项。

比如在本次安装过程中设置了下列参数:( 注意下面参数视情况而定啦不要照抄该选项原文件都有说明的)

RESPONSEFILE_VERSION = "10.0.0"

OPERATION_TYPE = "createDatabase"

GDBNAME = "orcl" # 数据库全局名称

SID = "TSH1" #这个sid 必须要和前面的/home/oracle/.bash_profile文件中的sid相同

# 注意:一定要注意上面两个变量设置的两个值是不同的,但大多数情况下设置是相同的,相同值我没有测试,感兴趣的可以试一下(相同值会更容易理解)

TEMPLATENAME = "New_Database.dbt"

SYSPASSWORD = "system" # SYS 用户的初始密码

SYSTEMPASSWORD = "system" #SYSTEM 用户的初始密码

DATAFILEDESTINATION ="/u01/app/oracle/oradata/"

RECOVERYAREADESTINATION="/u01/app/oracle/flash_recovery_area"

STORAGETYPE=FS

CHARACTERSET = "ZHS16GBK" #数据库字符集(中文为 ZHS16GBK )

MEMORYPERCENTAGE = "40"

SCRIPTDESTINATION ="/u01/app/oracle/admin/ora10g/scripts"

EMCONFIGURATION=”LOCAL”

SYSMANPASSWORD = "system"

DBSNMPPASSWORD = "system"

 

su – oracle

$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/database/response/dbca.rsp

执行结果:

Creating and starting Oracle instance

1% complete

4% complete

Creating database files

8% complete

Creating data dictionary views

9% complete

10% complete

12% complete

13% complete

14% complete

15% complete

17% complete

18% complete

20% complete

21% complete

Adding Oracle JVM

22% complete

28% complete

34% complete

40% complete

42% complete

Adding Oracle Data Mining

43% complete

44% complete

46% complete

Adding Oracle Text

47% complete

49% complete

50% complete

Adding Oracle XML DB

52% complete

53% complete

54% complete

58% complete

Adding Oracle Intermedia

59% complete

60% complete

71% complete

Adding Oracle OLAP

72% complete

73% complete

74% complete

75% complete

Adding Oracle Spatial

76% complete

77% complete

78% complete

83% complete

Adding Enterprise Manager Repository

84% complete

86% complete

88% complete

Completing Database Creation

89% complete

90% complete

91% complete

95% complete

99% complete

100% complete

Look at the log file

"/u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/orcl/orcl.log" for further details.

最后提示创建成功后

数据库创建成功后需要修改一些信息:

vi /etc/oratab

THS1:/ u01/app/oracle/product/10.2.0/db_1:N

改为:

TSH1:/u01/app/oracle/product/10.2.0/db_1:Y

保证数据库实例能自动启动。

 

16、创建数据库和监听器自启动的服务

su - root

cd /etc/rc.d/init.d/

touch oradbstart

vi oradbstart

脚本内容如下:

#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for Oracle Databases

# /etc/rc.d/init.d/oradbstart

export ORACLE_BASE=/u01/app/oracle/

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_SID=TSH1

export PATH=$ORACLE_HOME/bin:$PATH

case "$1" in

start)

su oracle -c $ORACLE_HOME/bin/dbstart

touch /var/lock/oracle

echo "OK"

;;

stop)

echo -n "Shutdown Oracle: "

su oracle -c $ORACLE_HOME/bin/dbshut

rm -f /var/lock/oracle

echo "OK"

;;

*)

echo "Usage: 'basename $0' start|stop"

exit 1

esac

exit 0

 

17、修改数据脚本的权限

su - root

chown oracle.oinstall /etc/rc.d/init.d/oradbstart

chmod 775 /etc/rc.d/init.d/oradbstart

 

18、把oradbstart 服务添加到 chkconfig 中(此处可不执行)

chkconfig --add oradbstart

chkconfig --list oradbstart

 

19、启动数据库实例

su - oracle

$ORACLE_HOME/bin/dbstart

 

20、测试:

su - oracle

sqlplus /nolog

SQL> connect /as sysdba

SQL> startup

测试成功。

 

21、修改两个配置文件(此处比较重要,如果不改,可能在本地用plsql远程连接数据库连接失败)

修改tnsnames.ora文件

vi /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

ORCL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = AY1311041658000357deZ)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAME)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = PLSExtProc)

)

)

改为:

ORCL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 115.29.147.229)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

 

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 115.29.147.229)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = PLSExtProc)

)

)

注:标红部分请替换实际ip

 

修改listener.ora文件

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = AY1311041658000357deZ)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

改为:

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

(PROGRAM = extproc)

)

(SID_DESC =

(GLOBAL_DBNAME = orcl)

(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

(SID_NAME = TSH1)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST=115.29.147.229)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

注:标红部分为修改部分,请替换实际ip

 

22、重启oracle

su – oracle

-bash-3.2$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 7 15:44:19 2013

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> quit

-bash-3.2$ $ORACLE_HOME/bin/lsnrctl stop

-bash-3.2$ $ORACLE_HOME/bin/lsnrctl start

-bash-3.2$ sqlplus "/as sysdba"

SQL> startup open

SQL> quit

 

完成。

 

截止到上面其实oracle安装已经完成,下面代码就是创建表空间、用户、数据库导入了,基于完整性,一并贴出来。

 

23、用系统用户创建表空间、用户等

su - oracle

sqlplus “/as sysdba”

#创建表空间

create TEMPORARY TABLESPACE AFINITOR_TEMP TEMPFILE '/u01/app/oracle/oradata/orcl/AFINITOR_TEMP.ORA' SIZE 32M AUTOEXTEND ON NEXT 32M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL;

#创建临时表空间

create TABLESPACE AFINITOR LOGGING DATAFILE '/u01/app/oracle/oradata/orcl/AFINITOR.DBF' SIZE 32M AUTOEXTEND ON NEXT 32M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL;

#创建用户

create user afinitor identified by afinitor default tablespace AFINITOR temporary tablespace AFINITOR_TEMP;

#给用户授权

grant resource,connect,EXP_FULL_DATABASE,IMP_FULL_DATABASE,CREATE SESSION to afinitor;

grant dba to afinitor;

#授权导入导出

GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,DBA,CONNECT,RESOURCE,CREATE SESSION TO afinitor;

 

24、数据导入

cd /home

wget –c http://nadmin.haott.com/afinitor_db.dmp (此处是在另一服务器下载所需要的数据库dmp文件)

su – oracle

imp afinitor/afinitor@orcl file=/home/afinitor_data_20131206.dmp full=y ignore=y #导入命令

 

 

 

 

 

 

>更多相关文章
24小时热门资讯
24小时回复排行
资讯 | QQ | 安全 | 编程 | 数据库 | 系统 | 网络 | 考试 | 站长 | 关于东联 | 安全雇佣 | 搞笑视频大全 | 微信学院 | 视频课程 |
关于我们 | 联系我们 | 广告服务 | 免责申明 | 作品发布 | 网站地图 | 官方微博 | 技术培训
Copyright © 2007 - 2024 Vm888.Com. All Rights Reserved
粤公网安备 44060402001498号 粤ICP备19097316号 请遵循相关法律法规
');})();