您好,登錄后才能下訂單哦!
小編給大家分享一下linux下安裝oracle 11g數(shù)據(jù)庫的方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
linux下命令行安裝oracle 11g數(shù)據(jù)庫
本次安裝的基本環(huán)境:vmware中安裝centos6.10(虛擬機(jī)安裝這里就不做介紹了)
虛擬機(jī)要求:內(nèi)存推薦2G以上
需要下載Linux版本下對應(yīng)的oracle安裝包:
下載地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
對應(yīng)的oracle版本:
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
課程
(1)設(shè)置系統(tǒng):Oracle只支持操作系統(tǒng)Red Hat Enterprise Linux 6,故需將/etc/redhat-release中的內(nèi)容改成Red Hat
[root@Oracle ~]# vi /etc/redhat-release #CentOS release 6.10 (Final) Red Hat Enterprise Linux 6
(2)機(jī)器信息關(guān)閉,selinux,防火墻的不必要的服務(wù)
[root@Oracle ~]# cat /etc/selinux/config //selinux關(guān)閉(disabled) # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@Oracle ~]# /etc/init.d/iptables stop //防火墻關(guān)閉 [root@Oracle ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.152.130 Oracle //新增行:IP 機(jī)器名(這是我的ip和主機(jī)名)
(3)修改用戶的限制文件
[root@Oracle ~]# cat /etc/security/limits.conf //在該文件內(nèi)添加以下內(nèi)容 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
(4)修改內(nèi)核參數(shù)
[root@Oracle ~]# cat /etc/sysctl.conf //在文件中添加以下內(nèi)容 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 [root@Oracle ~]# sysctl –p // 執(zhí)行這條語句使配置生效
(5)依賴包安裝
[root@Oracle ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc glibc-devel glibc-devel*.i686 ksh libgcc*.i686 libgcc libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.i686 libaio libaio*.i686 libaio-devel libaio-devel*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 libXp
(1)建立用戶、組
[root@Oracle ~]# groupadd oinstall [root@Oracle ~]# groupadd dba [root@Oracle ~]# groupadd oper [root@Oracle ~]# useradd -g oinstall -G dba,oper oracle [root@Oracle ~]# echo "oracle" | passwd --stdin oracle [root@Oracle ~]# id oracle //查看用戶所屬組 uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper)
(2)新建安裝目錄
[root@Oracle ~]# mkdir -p /var/app [root@Oracle ~]# mkdir -p /var/app/oracle [root@Oracle ~]# mkdir -p /var/app/oracle/product [root@Oracle ~]# mkdir -p /var/app/oracle/product/11.2.0 [root@Oracle ~]# mkdir -p /var/app/oracle/product/11.2.0/dbhome_1 [root@Oracle ~]# mkdir -p /home/oracle/backup [root@Oracle ~]# mkdir -p /home/oracle/oraInventory [root@Oracle ~]# chown -R oracle:oinstall /var/app [root@Oracle ~]# chown -R oracle:oinstall /home/oracle/backup [root@Oracle ~]# chown -R oracle:oinstall /home/oracle/oraInventory [root@Oracle ~]# chmod -R 775 /var/app
(3)設(shè)置并刷新環(huán)境變量
[root@Oracle ~]# cat /home/oracle/.bash_profile //給該文件添加以下內(nèi)容 umask 022 export ORACLE_BASE=/var/app export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1 export ORACLE_SID=ora11g export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib [root@Oracle ~]# source /home/oracle/.bash_profile //執(zhí)行該句使配置生效
(1)拷貝Oracle安裝文件到指定目錄
[root@Oracle ~]# cp linux.x64_11gR2_database_*.zip /var/app/oracle/
(2)切換到oracle用戶,解壓安裝包
[root@Oracle ~]# su - oracle [oracle@Oracle ~]$ cd /var/app/oracle/ [oracle@Oracle oracle]$ unzip linux.x64_11gR2_database_1of2.zip [oracle@Oracle oracle]$ unzip linux.x64_11gR2_database_2of2.zip
解壓后得到database目錄,其中response目錄里面有三個rsp文件,用來作為靜默安裝時應(yīng)答文件的模板。分別為:
[oracle@Oracle response]$ ls -l total 76 -rw-rw-r-- 1 oracle oinstall 44960 Aug 8 17:10 dbca.rsp //安裝應(yīng)答 -rw-rw-r-- 1 oracle oinstall 22752 Aug 8 14:23 db_install.rsp //創(chuàng)建數(shù)據(jù)庫應(yīng)答 -rwxrwxr-x 1 oracle oinstall 5740 Feb 26 2009 netca.rsp //建立監(jiān)聽,本地服務(wù)名等網(wǎng)絡(luò)設(shè)置
(5)修改配置文件,安裝Oracle數(shù)據(jù)庫
[oracle@Oracle database]$ cp /var/app/oracle/database/response/ /home/oracle/ //備份
(6)修改后的靜默安裝配置文件db_install.rsp內(nèi)容如下:
[root@db response]# cat db_install.rsp | grep -v '^#' | grep -v '^$' oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=db UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/var/app/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/var/app/oracle/product/11.2.0/dbhome_1 ORACLE_BASE=/var/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.isCustomInstall=false 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=ora11g oracle.install.db.config.starterdb.SID=ora11g oracle.install.db.config.starterdb.characterSet=AL32UTF8 oracle.install.db.config.starterdb.memoryOption=true oracle.install.db.config.starterdb.memoryLimit=1500 oracle.install.db.config.starterdb.installExampleSchemas=false oracle.install.db.config.starterdb.enableSecuritySettings=true oracle.install.db.config.starterdb.password.ALL=oracle 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= 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=
(7)開始靜默安裝
[oracle@Oracle database]$ cd /var/app/oracle/database [oracle@Oracle database]$ ./runInstaller -silent -responseFile /var/app/oracle/database/response/db_install.rsp
(8)查看安裝進(jìn)度
[oracle@Oracle database]$ cd /var/app/oracle/oraInventory/logs [oracle@Oracle logs]$ tail -f installActions*log
(9)當(dāng)出現(xiàn)以下信息時
var/app/oracle/oraInventory/orainstRoot.sh var/app/oracle/product/11.2.0/dbhome_1/root.sh To execute the configuration scripts: 1. Open a terminal window 2. Log in as "root" 3. Run the scripts 4. Return to this window and hit "Enter" key to continue Successfully Setup Software.
打開新的客戶端使用root身份執(zhí)行以下腳本
[root@Oracle ~]# var/app/oracle/oraInventory/orainstRoot.sh [root@Oracle ~]# var/app/oracle/product/11.2.0/dbhome_1/root.sh
(10)執(zhí)行完上面的腳本后回到安裝界面按下Enter繼續(xù)。
(1)運(yùn)行監(jiān)聽文件
[oracle@Oracle ~]$ cd /var/app/oracle/database/response [oracle@Oracle response]$ netca /silent /responsefile /var/app/oracle/database/response/netca.rsp
運(yùn)行成功之后,在/var/app/oracle/product/11.2.0/dbhome_1/network/admin目錄下會生成sqlnet.ora和listener.ora兩個文件
[oracle@Oracle admin]$ ls listener.ora samples shrept.lst sqlnet.ora tnsnames.ora
執(zhí)行以下命令查看監(jiān)聽器是否已經(jīng)在1521端口上開始工作了
[root@Oracle ~]# netstat -tlnp | grep 1521 tcp 0 0 :::1521 :::* LISTEN 1792/tnslsnr
如果監(jiān)聽沒有啟動,則手動啟動監(jiān)聽器
[oracle@Oracle ~]$ lsnrctl start
(2)配置Oracle數(shù)據(jù)庫
[oracle@Oracle response]$ pwd /var/app/oracle/database/response [oracle@Oracle response]$ vi dbca.rsp GDBNAME = "orcl11.us.oracle.com" //78 行 全局?jǐn)?shù)據(jù)庫的名字=SID+主機(jī)域名 SID="ora11g" //149行 SID SYSPASSWORD = "oracle" //190行 SYSTEMPASSWORD = "oracle" //200行 CHARACTERSET="AL32UTF8" //415行 編碼 NATIONALCHARACTERSET="UTF8" //425行 編碼
(3)創(chuàng)建數(shù)據(jù)庫
[oracle@Oracle ~]$ $ORACLE_HOME/bin/dbca -silent -responseFile /var/app/oracle/database/response/dbca.rsp
進(jìn)入Oracle SQL命令行
[oracle@Oracle ~]$ sqlplus / as sysdba SQL> startup ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/var/app/oracle/product/11.2.0/dbhome_1/dbs/initora11g.ora'
啟動時會出現(xiàn)以上錯誤,解決方法如下:找到init.ora.78201817526文件,將其復(fù)制到/var/app/oracle/product/11.2.0/dbhome_1/dbs目錄下
[oracle@Oracle admin]$ locate init.ora //定位尋找目標(biāo)文件 /var/app/admin/orcl11g/pfile/init.ora.78201817526 //目標(biāo)文件 /var/app/oracle/product/11.2.0/dbhome_1/dbs/init.ora /var/app/oracle/product/11.2.0/dbhome_1/srvm/admin/init.ora [oracle@Oracle admin]$ cd /var/app/admin/orcl11g/pfile/ [oracle@Oracle pfile]$ ls init.ora.78201817526 [oracle@Oracle pfile]$ cp init.ora.78201817526 /var/app/oracle/product/11.2.0/dbhome_1/dbs/ [oracle@Oracle dbs]$ mv init.ora.78201817526 initora11g.ora //將目標(biāo)文件改成所需文件名
進(jìn)入到Oracle SQL命令行中,執(zhí)行startup
[oracle@Oracle ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Aug 10 01:59:43 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> startup //啟動數(shù)據(jù)庫實(shí)例 ORACLE instance started. Total System Global Area 839282688 bytes Fixed Size 2217992 bytes Variable Size 494929912 bytes Database Buffers 339738624 bytes Redo Buffers 2396160 bytes Database mounted. Database opened.
看完了這篇文章,相信你對linux下安裝oracle 11g數(shù)據(jù)庫的方法有了一定的了解,想了解更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。