Centos7命令行安裝oracle11g

1、準備:
本次安裝的基本環境:vmware中安裝centos6.10(虛擬機安裝這裏就不做介紹了)

虛擬機要求:內存推薦2G以上

需要下載Linux版本下對應的oracle安裝包:

下載地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

推薦下載工具(迅雷下載太坑,各種會員限速 freedownloadmanager軟件):https://www.freedownloadmanager.org/zh/landing5.htm

對應的oracle版本:

       linux.x64_11gR2_database_1of2.zip

       linux.x64_11gR2_database_2of2.zip

2、機器基礎配置修改
(1)設置系統:Oracle只支持操作系統Red Hat Enterprise Linux 6,故需將/etc/redhat-release中的內容改成Red Hat

[root@Oracle ~]# vi /etc/redhat-release  
#CentOS release 6.10 (Final)
Red Hat Enterprise Linux 6


(2)機器信息關閉,selinux,防火牆的不必要的服務

[root@Oracle ~]# cat /etc/selinux/config                         //selinux關閉(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                        //防火牆關閉
[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 機器名(這是我的ip和主機名)



(3)修改用戶的限制文件

[root@Oracle ~]# cat /etc/security/limits.conf                //在該文件內添加以下內容
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240


(4)修改內核參數

[root@Oracle ~]# cat /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
[root@Oracle ~]# sysctl –p                // 執行這條語句使配置生效
ps: 執行sysctl –p 返回 sysctl: cannot stat /proc/sys/–p: No such file or directory解決辦法如下:
執行modprobe br_netfilter命令後就可以了
https://blog.csdn.net/weixin_30730151/article/details/101687318


(5)依賴包安裝

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


3、建立用戶、組,安裝目錄
(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=1004(oracle) gid=1004(oinstall) groups=1004(oinstall),1005(dba),1006(oper)


(2)新建安裝目錄

[root@Oracle ~]# mkdir -p /data
[root@Oracle ~]# mkdir -p /data/oracle
[root@Oracle ~]# mkdir -p /data/oracle/product
[root@Oracle ~]# mkdir -p /data/oracle/product/11.2.0
[root@Oracle ~]# mkdir -p /data/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 /data
[root@Oracle ~]# chown -R oracle:oinstall /home/oracle/backup
[root@Oracle ~]# chown -R oracle:oinstall /home/oracle/oraInventory
[root@Oracle ~]# chmod -R 775 /data


(3)設置並刷新環境變量

[root@Oracle ~]# cat /home/oracle/.bash_profile   //給該文件添加以下內容
umask 022
export ORACLE_BASE=/data
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        //執行該句使配置生效


4、安裝Oracle
(1)拷貝Oracle安裝文件到指定目錄

[root@Oracle ~]# cp linux.x64_11gR2_database_*.zip /data/oracle/


(2)切換到oracle用戶,解壓安裝包

[root@Oracle ~]# su - oracle
[oracle@Oracle ~]$ cd /data/oracle/
[oracle@Oracle oracle]$ unzip linux.x64_11gR2_database_1of2.zip
[oracle@Oracle oracle]$ unzip linux.x64_11gR2_database_2of2.zip
解壓後得到database目錄,其中response目錄裏面有三個rsp文件,用來作爲靜默安裝時應答文件的模板。分別爲:

[oracle@Oracle response]$ ls -l
total 76
-rw-rw-r-- 1 oracle oinstall 44960 Aug  8 17:10 dbca.rsp      //安裝應答
-rw-rw-r-- 1 oracle oinstall 22752 Aug  8 14:23 db_install.rsp      //創建數據庫應答
-rwxrwxr-x 1 oracle oinstall  5740 Feb 26  2009 netca.rsp //建立監聽,本地服務名等網絡設置


(5)修改配置文件,安裝Oracle數據庫

[oracle@Oracle database]$ cp -r /data/oracle/database/response/ /home/oracle/      //cp -r遞歸複製備份


(6)修改後的靜默安裝配置文件db_install.rsp內容如下:

[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=/data/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/data/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 /data/oracle/database
[oracle@Oracle database]$ ./runInstaller -silent -responseFile  /data/oracle/database/response/db_install.rsp

ps:如果未設置交換空間會報如下問題
Using paramFile: /data/oracle/database/install/oraparam.ini


Checking Temp space: must be greater than 120 MB.   Actual 48633 MB    Passed
Checking swap space: 0 MB available, 150 MB required.    Failed <<<<

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,
Exiting Oracle Universal Installer, log for this session can be found at /tmp/OraInstall2020-05-08_03-35-07PM/installActions2020-05-08_03-35-07PM.log


參考鏈接:https://www.cnblogs.com/a9999/p/6957280.html
解決辦法:

1、檢查 Swap 空間在設置 Swap 文件之前,有必要先檢查一下系統裏有沒有既存的 Swap 文件。運行以下命令:

1 swapon -s
如果返回的信息概要是空的,則表示 Swap 文件不存在。

2、檢查文件系統在設置 Swap 文件之前,同樣有必要檢查一下文件系統,看看是否有足夠的硬盤空間來設置 Swap 。運行以下命令:

1 df -hal

3、創建並允許 Swap 文件下面使用 dd 命令來創建 Swap 文件。檢查返回的信息,還剩餘足夠的硬盤空間即可。

 

1 dd if=/dev/zero of=/swapfile bs=1024 count=512k
參數解讀:if=文件名:輸入文件名,缺省爲標準輸入。即指定源文件。< if=input file >of=文件名:輸出文件名,缺省爲標準輸出。即指定目的文件。< of=output file >bs=bytes:同時設置讀入/輸出的塊大小爲bytes個字節count=blocks:僅拷貝blocks個塊,塊大小等於bs指定的字節數。

4、格式化並激活 Swap 文件上面已經創建好 Swap 文件,還需要格式化後才能使用。運行命令:

mkswap /swapfile

激活 Swap ,運行命令:

swapon /swapfile
以上步驟做完,再次運行命令:

 

swapon -s
 

你會發現返回的信息概要:

1 Filename                Type        Size    Used    Priority
2 /swapfile               file        524284    0     -1
 

 

如果要機器重啓的時候自動掛載 Swap ,那麼還需要修改 fstab 配置。用 vim 打開 /etc/fstab 文件,在其最後添加如下一行:

1 /swapfile          swap            swap    defaults        0 0
最後,賦予 Swap 文件適當的權限:

1 chown root:root /swapfile 
2 chmod 0600 /swapfile


(8)查看安裝進度

[oracle@Oracle database]$ cd /data/oracle/oraInventory/logs
[oracle@Oracle logs]$ tail -f installActions*log


(9)當出現以下信息時

 /data/oracle/oraInventory/logs/installActions2020-05-08_03-43-49PM.log
The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/data/oracle/oraInventory/orainstRoot.sh
/data/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身份執行以下腳本

[root@miguvideo~]# chown -R root /data                       //將文件所有者設置爲root
[root@miguvideo-1 ~]#  sh /data/oracle/oraInventory/orainstRoot.sh
Changing permissions of /data/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /data/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@miguvideo-1 ~]# sh /data/oracle/product/11.2.0/dbhome_1/root.sh
Check /data/oracle/product/11.2.0/dbhome_1/install/root_miguvideo-1.novalocal_2020-05-08_17-17-27.log for the output of root script

5、配置Oracle監聽
(1)運行監聽文件

[root@Oracle ~] su - oracle                               //此處一定要切到oracle用戶
[oracle@Oracle ~]$ cd /var/app/oracle/database/response
[oracle@Oracle response]$ netca /silent /responsefile /data/oracle/database/response/netca.rsp


運行成功之後,在/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


執行以下命令查看監聽器是否已經在1521端口上開始工作了

[root@Oracle ~]# netstat -tlnp | grep 1521
tcp6       0      0 :::1521                 :::*                    LISTEN      12218/tnslsnr  


如果監聽沒有啓動,則手動啓動監聽器

[oracle@Oracle ~]$ lsnrctl start


(2)配置Oracle數據庫

[oracle@Oracle response]$ pwd
/data/oracle/database/response
[oracle@Oracle response]$ vi dbca.rsp
GDBNAME = "orcl11.us.oracle.com"     //78 行 全局數據庫的名字=SID+主機域名
SID="ora11g"    //149行 SID
SYSPASSWORD = "oracle"    //190行
SYSTEMPASSWORD = "oracle"   //200行
CHARACTERSET="AL32UTF8" //415行 編碼
NATIONALCHARACTERSET="UTF8" //425行 編碼


(3)創建數據庫

[oracle@miguvideo-1 response]$ $ORACLE_HOME/bin/dbca -silent -responseFile  /data/oracle/database/response/dbca.rsp   

Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/data/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.


 

6、啓動數據庫
進入Oracle SQL命令行

[oracle@miguvideo-1 response]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 8 16:58:55 2020

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
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 3340451840 bytes
Fixed Size                  2217952 bytes
Variable Size            1811941408 bytes
Database Buffers         1509949440 bytes
Redo Buffers               16343040 bytes
Database mounted.
Database opened.
SQL> 

ps:shutdown immediate 關閉數據庫在重啓操作 
ORA-01081: cannot start already-running ORACLE - shut it down first參考博客:
http://blog.sina.com.cn/s/blog_14e9fed4c0102wqdl.html

附:

命令:quit // 或 exit  退出sqlpuls

刪除實例:

命令:dbca -silent -deleteDatabase -sourcedb dbsrv2

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章