Centos5.10_ 64位静默安装oracle10g _升级10.2.0.5.12[新装版]

好久没发技术文章了 最近要做个oracle 的项目迁移,本着偷懒的节奏,还是静默安装比较省力 虽然前期准备需要很多!但是一旦配置好,后面就是刷刷的安装了。。懒人办法。。。。

 

同步时间

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
crontab -e
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP
ntpdate  us.pool.ntp.org
hwclock -w

设置本地DVD 为源:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

#添加本地源

cat >>/etc/yum.repos.d/CentOS-Base.repo<<EOF
[local-cdrom-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta
EOF

#注意可能会碰到如下报错信息
Public key for *****.rpm is not installed

#其实此时要导入rpm的签名信息即可
以root登录,执行下面命令
# rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
根据我的Linux版本是CentOS 5.10

于是我执行下面命令
#rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#本地安装的方法

yum --disablerepo=* --enablerepo=local-cdrom-media install screen lrzsz -y
1、安装Oracle所需软件包[直接网络方式]
yum install avahi-compat-libdns_sd.x86_64 compat-db.i386 compat-db.x86_64 compat-gcc-34.x86_64 compat-gcc-34-c++.x86_64 compat-gcc-34-g77.x86_64 compat-glibc.i386 compat-glibc.x86_64 compat-glibc-headers.x86_64 compat-libf2c-34.x86_64 compat-libgcc-296.i386 compat-libstdc++-296.i386 compat-libstdc++-33.i386 compat-libstdc++-33.x86_64 java-1.4.2-gcj-compat.x86_64 elfutils-libelf.i386 elfutils-libelf-devel.x86_64 elfutils-libelf-devel-static.x86_64 compat-glibc.x86_64 glibc-devel.i386 glibc-devel.x86_64 glibc-headers.x86_64  glibc.x86_64 glibc.i686 kernel-headers.x86_64 libaio.i386  libaio.x86_64 libaio-devel.i386 libaio-devel.x86_64 libstdc++-devel.i386 libXp.i386 libXp.x86_64  libXpm.x86_64 sysstat.x86_64 readline-devel.x86_64 openssl-devel -y

[DVD本地源安装]

yum --disablerepo=* --enablerepo=local-cdrom-media install avahi-compat-libdns_sd.x86_64 compat-db.i386 compat-db.x86_64 compat-gcc-34.x86_64 compat-gcc-34-c++.x86_64 compat-gcc-34-g77.x86_64 compat-glibc.i386 compat-glibc.x86_64 compat-glibc-headers.x86_64 compat-libf2c-34.x86_64 compat-libgcc-296.i386 compat-libstdc++-296.i386 compat-libstdc++-33.i386 compat-libstdc++-33.x86_64 java-1.4.2-gcj-compat.x86_64 elfutils-libelf.i386 elfutils-libelf-devel.x86_64 elfutils-libelf-devel-static.x86_64 compat-glibc.x86_64 glibc-devel.i386 glibc-devel.x86_64 glibc-headers.x86_64  glibc.x86_64 glibc.i686 kernel-headers.x86_64 libaio.i386  libaio.x86_64 libaio-devel.i386 libaio-devel.x86_64 libstdc++-devel.i386 libXp.i386 libXp.x86_64  libXpm.x86_64 sysstat.x86_64 readline-devel.x86_64 openssl-devel -y

2、修改系统版本

vi /etc/redhat-release

redhat-4
#CentOS release 5.7 (Final)

3、修改内核参数

cat >>/etc/sysctl.conf<<EOF
#for oracle10G
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 655360
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=1048576
net.core.rmem_max=1048576
net.core.wmem_default=262144
net.core.wmem_max=262144
EOF
cat >>/etc/security/limits.conf<<EOF
#for oracle10G
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
#32位
cat>>/etc/pam.d/login<<EOF
#for oracle10G
session required /lib/security/pam_limits.so
EOF
 
#64位
cat>>/etc/pam.d/login<<EOF
#for oracle10G
session required /lib64/security/pam_limits.so
EOF

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

然后sysctl -p 应用系统参数。

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

if ( $USER == “oracle” ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif

4 ,在/etc/profile里添加如下行

vim /etc/profile

#for oracle10G
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
EOF

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

5,建立安装Oracle需要的用户、组及目录

(1)新增组和用户:

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

创建目录

mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle.oinstall /u01
chmod -R 755 /u01

创建oracle profile文件

#注意切换 oracle 用户

su – oracle
vim /home/oracle/.bash_profile
 
#Oracle Settings umask 022;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;
export ORACLE_SID=orcl;
export NLS_LANG='simplified chinese_china.ZHS16GBK'
export PATH=$ORACLE_HOME/bin:$PATH;
export LANG=en_US.UTF-8

if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -p 65536
    else
        ulimit -u 16384 -n 65536
    fi
    umask 022
fi

source .bash_profile

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

6 , 修改oracle安装文件
vim /home/oracle/database/install/oraparam.ini

oracle10G静默安装
oracle10G静默安装

配置enterprise.rsp文件
先拷贝一份

cp /home/oracle/database/response/enterprise.rsp /home/oracle/database/response/enterprise_new.rsp
vim /home/oracle/database/response/enterprise_new.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”还有环境变量都要参照前面自己定义好的来

完整的参考如下

RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME="oinstall"
FROM_LOCATION="../stage/products.xml"
NEXT_SESSION_RESPONSE=<Value Unspecified>
ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1"
ORACLE_HOME_NAME="OraDb10g_home1"
TOPLEVEL_COMPONENT={"oracle.server","10.2.0.1.0"}
DEINSTALL_LIST={"oracle.server","10.2.0.1.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_NODE_SELECTION_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
RESTART_SYSTEM=false
RESTART_REMOTE_SYSTEM=false
REMOVE_HOMES=<Value Unspecified>
ORACLE_HOSTNAME=<Value Unspecified>
SHOW_END_OF_INSTALL_MSGS=true
CLUSTER_NODES=<Value Unspecified>
COMPONENT_LANGUAGES={"zh_CN"}
INSTALL_TYPE="EE"
s_nameForDBAGrp="dba"
s_nameForOPERGrp="dba"
n_configurationOption=3
s_ASMSYSPassword=""
s_ASMSYSPasswordAgain=""
n_dbType=<Value Required>
oracle.assistants.server:s_responseFileName=<Value Unspecified>
s_globalDBName=<Value Required>
s_dbSid=<Value Required>
s_dbRetChar="WE8ISO8859P1"
b_loadExampleSchemas=false
b_useDBControl=true
b_receiveEmailNotification=false
s_dlgEMSMTPServer=<Value Unspecified>
s_dlgEMEmailAddress=<Value Unspecified>
s_dlgEMCentralAgentSelected=<Value Unspecified>
n_dbStorageType=<Value Unspecified>
s_mountPoint=<Value Unspecified>
s_rawDeviceMapFileLocation=<Value Unspecified>
b_enableAutoBackup=false
b_useFileSystemForRecovery=true
s_dlgRBORecoveryLocation=<Value Unspecified>
s_dlgRBOUsername=<Value Unspecified>
s_dlgRBOPassword=<Value Unspecified>
s_dlgASMCfgDiskGroupName="DATA"
s_dlgASMCfgDiskDiscoveryString=<Value Unspecified>
n_dlgASMCfgRedundancySelected=<Value Unspecified>
sl_dlgASMCfgSelectableDisks=<Value Unspecified>
sl_dlgASMCfgDiskSelections=<Value Unspecified>
sl_dlgASMDskGrpSelectedGroup={" "," "," "," "}
b_centrallyManageASMInstance=true
b_useSamePassword=true
s_superAdminSamePasswd=<Value Unspecified>
s_superAdminSamePasswdAgain=<Value Unspecified>
sl_superAdminPasswds=<Value Unspecified>
sl_superAdminPasswdsAgain=<Value Unspecified>
n_performUpgrade=0
n_upgradeDB=0
s_dbOHSelectedForUpgrade=""
s_dbSIDSelectedForUpgrade=""
n_upgradeASM=0
s_dbSelectedUsesASM="no"
sl_upgradableSIDBInstances={}
sl_upgradableRACDBInstances={}
n_dbSelection=0
b_stateOfUpgradeASMCheckbox=false
b_stateOfUpgradeDBCheckbox=false
b_oneClick=false
s_dlgASMCfgRedundancyValue=""
s_dlgASMCfgExistingFreeSpace="0"
s_dlgASMCfgNewDisksSize=""
s_dlgASMCfgAdditionalSpaceNeeded="0 MB"

正式安装

su - oracle
/home/oracle/database/runInstaller -silent -responseFile /home/oracle/database/response/enterprise_new.rsp

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

su root
sh /u01/app/oracle/oraInventory/orainstRoot.sh
sh /u01/app/oracle/product/10.2.0/db_1/root.sh

测试下
sqlplus / as sysdba

更新最新补丁 升级至最高版本
升级至最新的10.2.0.5.4

cp /home/oracle/Disk1/response/patchset.rsp /home/oracle/Disk1/response/patchset_new.rsp
vim /home/oracle/Disk1/response/patchset_new.rsp

1、编辑升级介质中的../Disk1/response/patchset.rsp文件,主要编辑以下条目

UNIX_GROUP_NAME=”oinstall”
ORACLE_HOME=”/u01/app/oracle/product/10.2.0/db_1″
ORACLE_HOME_NAME=”OraDb10g_home1″
ORACLE_HOME_NAME可以从../oraInventory/ContentsXML/inventory.xml文件中 HOME NAME获取。

2、升级Oracle软件【非全新安装的话】

$ ./runInstaller -silent -responseFile /home/oracle/Disk1/response/patchset_new.rsp

3、执行root.sh
4、SQL> startup upgrade启动数据库
5、SQL> SPOOL upgrade_info.log
6、执行@$ORACLE_HOME/rdbms/admin/utlu102i.sql 收集升级信息
7、SQL> SPOOL OFF保存至文件
8、启动监听:[[email protected] Disk1]$ lsnrctl start
9、进入sqlplus

SQL> startup upgrade
SQL> SPOOL patch.log
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql –升级脚本[刷新数据字典]
SQL> SPOOL OFF
10、重启oracle
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP
11、SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql
12、查询sys.dba_registry视图,看组件的status是否是valid
13、emca -upgrade db –更新EM资料库

完整的参考如下

RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME="oinstall"
FROM_LOCATION=<Value Required>
NEXT_SESSION_RESPONSE=<Value Unspecified>
ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1"
ORACLE_HOME_NAME="OraDb10g_home1"
TOPLEVEL_COMPONENT={"oracle.patchset.db","10.2.0.5.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_COMPONENT_LOCATIONS_PAGE=false
SHOW_CUSTOM_TREE_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=false
SHOW_OPTIONAL_CONFIG_TOOL_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_RELEASE_NOTES=false
SHOW_END_OF_INSTALL_MSGS=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
ACCEPT_LICENSE_AGREEMENT=true
RESTART_SYSTEM=<Value Unspecified>
CLUSTER_NODES=<Value Unspecified>
OUI_HOSTNAME=<Value Unspecified>
REMOVE_HOMES=<Value Unspecified>
COMPONENT_LANGUAGES={"en"}
sl_userNodeList=<Value Unspecified>
#MYORACLESUPPORT_USERNAME=<Value Unspecified>
#MYORACLESUPPORT_PASSWORD=<Value Unspecified>
PROXY_HOST=<Value Unspecified>
PROXY_PORT=<Value Unspecified>
PROXY_USER=<Value Unspecified>
PROXY_PWD=<Value Unspecified>
SECURITY_UPDATES_VIA_MYORACLESUPPORT=<Value Unspecified>
#DECLINE_SECURITY_UPDATES=<Value Unspecified>
COLLECTOR_UPGRADE=<Value Unspecified>
COLLECTOR_IGNORE_CONFIGURATION=<Value Unspecified>
COLLECTOR_IGNORE_FAILURES=<Value Unspecified>
COLLECTOR_USE_OBFUSCATED_PASSWORDS=<Value Unspecified>
COLLECTOR_RESPONSE_FILE=<Value Unspecified>
COLLECTOR_SUPPORTHUB_URL=<Value Unspecified>
[email protected]
DECLINE_SECURITY_UPDATES=true

完成后用 root 执行以下脚本

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

#OPatch

mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_bak
unzip p6880880_102000_Linux-x86-64.zip
cp -rf OPatch/ $ORACLE_HOME/

2、解压p16619894_10205_Linux-x86-64.zip到$ORACLE_HOME/OPatch下。

cd $ORACLE_HOME/OPatch/
unzip p16619894_10205_Linux-x86-64.zip

3、执行$ORACLE_HOME/OPatch下./opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./16619894

./opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./16619894

4、cd 16619894
5、.././opatch apply
6,

 cd $ORACLE_HOME/rdbms/admin
 sqlplus /nolog
 SQL> CONNECT / AS SYSDBA
 SQL> STARTUP
 SQL> @catbundle.sql psu apply
 SQL> -- Execute the next statement only if this is the first PSU applied for 10.2.0.5 or this is the first PSU  applied since 10.2.0.5.3.
 SQL> @utlrp.sql
 SQL> QUIT

检查补丁:
命令1.$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | egrep -i 'PSU|DATABASE PATCH SET UPDATE'
2.$ORACLE_HOME/OPatch/opatch lsinventory
3.select * from registry$history
三个命令任选一个

#安装监听

cp /home/oracle/database/response/netca.rsp /home/oracle/database/response/netca_new.rsp

修改以下值:
INSTALL_TYPE=""custom"" #安装的类型
LISTENER_NUMBER=1 #监听器数量
LISTENER_NAMES={"LISTENER"} #监听器的名称列表
LISTENER_PROTOCOLS={"TCP;1521"} # 监听器使用的通讯协议列表
LISTENER_START=""LISTENER"" # 监听器启动的名称

完整的参考如下

[GENERAL]
RESPONSEFILE_VERSION="10.0"
CREATE_TYPE= "CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""custom""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE = {"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}

#注意 在执行下面的语句时 一定要保证 /etc/hosts 跟hostname 一致 否则会报错
hostname
OrclData

cat /etc/hosts
127.0.0.1    OrclData localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6

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

修改 dbstart

sed -i "s//ade/vikrkuma_new/oracle/$ORACLE_HOME/g"  $ORACLE_HOME/bin/dbstart

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

增加数据实例

cp /home/oracle/database/response/dbca.rsp /home/oracle/database/response/dbca_new.rsp
vim /home/oracle/database/response/dbca_new.rsp

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

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

RESPONSEFILE_VERSION = "10.0.0"
OPERATION_TYPE = "createDatabase"
GDBNAME = "orcl" # 数据库全局名称
SID = "orcl" #这个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"

完整的参考如下

[GENERAL]
RESPONSEFILE_VERSION = "10.0.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "New_Database.dbt"
SYSPASSWORD = "system"
SYSTEMPASSWORD = "system"
DATAFILEDESTINATION ="/u01/app/oracle/oradata/"
RECOVERYAREADESTINATION="/u01/app/oracle/flash_recovery_area"
STORAGETYPE=FS
CHARACTERSET = "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_new.rsp

数据库创建成功后需要修改一些信息:
vi /etc/oratab
orcl:/ u01/app/oracle/product/10.2.0/db_1:N
改为:
orcl:/u01/app/oracle/product/10.2.0/db_1:Y

sed -i "s/db_1:N/db_1:Y/g"   /etc/oratab

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

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

su - root
cd /etc/rc.d/init.d/

touch oradbstart
vim 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=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG='simplified chinese_china.ZHS16GBK'

case "$1" in
        start)
        su - oracle -c "$ORACLE_HOME/bin/dbstart  $ORACLE_HOME"
        su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"
        touch /var/lock/oracle
        echo "OK"
        ;;

        stop)
        echo -n "Shutdown Oracle: "
        su - oracle -c "$ORACLE_HOME/bin/dbshut  $ORACLE_HOME"
        su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop"
        su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
        rm -f /var/lock/oracle
        echo "OK"
        ;;

        restart)
                $0 stop
                $0 start
                echo "restart ok!!"
        ;;

        *)
        echo "Usage: 'basename $0' start|stop|restart"
        exit 1
        esac
exit 0

修改数据脚本的权限

su - root
chown oracle.oinstall /etc/rc.d/init.d/oradbstart
chmod 775 /etc/rc.d/init.d/oradbstart

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

chkconfig --add oradbstart
chkconfig --list oradbstart

启动数据库实例
su - oracle
$ORACLE_HOME/bin/dbstart

测试:

su - oracle
sqlplus /nolog
SQL> connect /as sysdba
SQL> startup

测试成功。

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

修改tnsnames.ora文件
vi /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = OrclData)(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 = 192.168.75.20)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.75.20)(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 = OrclData)(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 = orcl)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST=192.168.75.20)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)

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

重启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安装已经完成,下面代码就是创建表空间、用户、数据库导入了,基于完整性,一并贴出来。

用系统用户创建表空间、用户等
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;

数据导入

cd /home
(此处是在另一服务器下载所需要的数据库dmp文件)
su – oracle
imp sys/[email protected] file=/home/database.dmp full=y ignore=y #导入命令
或者下面的语句更快
impdp sys/111111 directory=dump_dir dumpfile=database.dmp FULL=Y

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.