CentOS7下oracle11gR2的安裝流程

? ? ? ? 近兩天在CentOS7上安裝了oracle,在網(wǎng)上找了一些資料,發(fā)現(xiàn)不是很全面,為了方便以后再次安裝,所以將此次安裝記錄下來,如果有不正確的地方,希望指出。

以下參考:CentOS7安裝Oracle 11gR2 圖文詳解_數(shù)據(jù)庫技術(shù)_Linux公社-Linux系統(tǒng)門戶網(wǎng)站

? ? ? ? ? ? ? ? ? ?centos安裝oracle 11g 完全圖解 - 鄭文亮 - 博客園

一、環(huán)境準(zhǔn)備

1.VMware-workstation-full-11.1.0-2496824.exe

2.CentOS-7-x86_64DVD1511.iso

3.linux.x64_11gR2_database_1of2.zip

4.linux.x64_11gR2_database_2of2.zip

二、安裝Oracle前的準(zhǔn)備工作

1.創(chuàng)建運(yùn)行oracle數(shù)據(jù)庫的系統(tǒng)用戶和用戶組

[sonny@localhost ~]$ su root  #切換到root

Password:

[root@localhost sonny]# groupadd oinstall  #創(chuàng)建用戶組oinstall

[root@localhost sonny]# groupadd dba  #創(chuàng)建用戶組dba

[root@localhost sonny]# useradd -g oinstall -g dba -m oracle  #創(chuàng)建oracle用戶,并加入到oinstall和dba用戶組

[root@localhost sonny]# passwd oracle  #設(shè)置用戶oracle的登陸密碼,不設(shè)置密碼,在CentOS的圖形登陸界面沒法登陸

Changing password for user oracle.

New password:   # 密碼

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:   # 確認(rèn)密碼

passwd: all authentication tokens updated successfully.

[root@localhost sonny]# id oracle # 查看新建的oracle用戶

uid=1001(oracle) gid=1002(dba) groups=1002(dba)

[root@localhost sonny]#

為什么要創(chuàng)建oinstall用戶組及dba組??

參考:在 Oracle Enterprise Linux 和 iSCSI 上構(gòu)建您自己的 Oracle RAC 11g 集群,第 2 頁

2.創(chuàng)建oracle數(shù)據(jù)庫安裝目錄

[sonny@localhost ~]$ su root

Password:

[root@localhost sonny]# mkdir -p /data/oracle  #oracle數(shù)據(jù)庫安裝目錄

[root@localhost sonny]# mkdir -p /data/oraInventory  #oracle數(shù)據(jù)庫配置文件目錄

[root@localhost sonny]# mkdir -p /data/database  #oracle數(shù)據(jù)庫軟件包解壓目錄

[root@localhost sonny]# cd /data

[root@localhost data]# ls  #創(chuàng)建完畢檢查一下

database? oracle? oraInventory

[root@localhost data]# chown -R oracle:oinstall /data/oracle  #設(shè)置目錄所有者為oinstall用戶組的oracle用戶

[root@localhost data]# chown -R oracle:oinstall /data/oraInventory

[root@localhost data]# chown -R oracle:oinstall /data/database

[root@localhost data]#

3.修改OS系統(tǒng)標(biāo)識

oracle默認(rèn)不支持CentOS系統(tǒng)安裝,我安裝是64位數(shù)據(jù)庫,On Linux x86-64:Red Hat Enterprise Linux 7? (RHEL 7)

另外,CentOS7.0.1511 基于 RHEL7.2? 參考:CentOS 7-1511 發(fā)布下載_Linux下載_Linux公社-Linux系統(tǒng)門戶網(wǎng)站

修改文件 /etc/RedHat-release

[sonny@localhost data]$ su root

Password:

[root@localhost data]# cat /proc/version

Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015

[root@localhost data]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@localhost data]# vi /etc/redhat-release

[root@localhost data]# cat /etc/redhat-release

redhat-7

[root@localhost data]#

4.安裝oracle數(shù)據(jù)庫所需要的軟件包

Oracle Database Package Requirements for Linux x86-64 如下:(參考:docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#BABCFJFG

操作系統(tǒng):Oracle Linux 7 and Red Hat Enterprise Linux 7

The following packages (or later versions) must be installed:

在我參考的那篇文章里因?yàn)閷懥司唧w要安裝的具體版本信息,所以我也是那樣寫的,結(jié)果運(yùn)行時一直出現(xiàn)沒有這個命令,后來查了一些東西問了別人,做出修改,如下:

yum install binutils-*.x86_64

yum install compat-libcap1-*.x86_64

yum install gcc-*.x86_64

yum install gcc-c++-*.x86_64

yum install glibc-*.i686

yum install glibc-*.x86_64

yum install glibc-devel-*.i686

yum install glibc-devel-*.x86_64

yum install ksh-*

yum install libaio-*.i686

yum install libaio-*.x86_64

yum install libaio-devel-*.i686

yum install libaio-devel-*.x86_64

yum install libgcc-*.i686

yum install libgcc-*.x86_64

yum install libstdc++-*.i686

yum install libstdc++-*.x86_64

yum install libstdc++-devel-*.i686

yum install libstdc++-devel-*.x86_64

yum install libXi-*.i686

yum install libXi-*.x86_64

yum install libXtst-*.i686

yum install libXtst-*.x86_64

yum install make-*.x86_64

yum install sysstat-*.x86_64

[sonny@localhost data]$ su root

Password:

[root@localhost data]# yum install binutils

對于軟件包的安裝這里,也有部分文章采用的是rpm而不是yum,yum的好處簡單來說:

<1>能夠從指定的服務(wù)器自動下載RPM包并且安裝,可以自動處理依賴性關(guān)系,并且一次安裝所有依賴的軟體包,無須繁瑣地一次次下載、安裝。

<2>yum提供了查找、安裝、刪除某一個、一組甚至全部軟件包的命令,而且命令簡潔而又好記。

參考文章:linux yum命令詳解 - chuncn - 博客園

? ? ? ? ? ? ? ? ? ? ?Linux rpm 命令參數(shù)使用詳解[介紹和應(yīng)用] - 小炒花生米 - 博客園

? ? ? ? ? ? ? ? ? ? ?rpm命令與yum命令_絮絮落英_新浪博客

5.關(guān)閉防火墻 CentOS 7.2默認(rèn)使用的是firewall作為防火墻

[sonny@localhost /]$ su root

Password:

[root@localhost /]# systemctl status firewalld.service  #查看防火墻狀態(tài),運(yùn)行中

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2016-04-07 18:54:29 PDT; 2h 20min ago

Main PID: 802 (firewalld)

CGroup: /system.slice/firewalld.service

└─802 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

[root@localhost /]# systemctl stop firewalld.service  #關(guān)閉防火墻

[root@localhost /]# systemctl status firewalld.service  #再次查看防火墻狀態(tài),發(fā)現(xiàn)已關(guān)閉

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

Active: inactive (dead) since Thu 2016-04-07 21:15:34 PDT; 9s ago

Main PID: 802 (code=exited, status=0/SUCCESS)

Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...

Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

Apr 07 21:15:33 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon...

Apr 07 21:15:34 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon.

[root@localhost /]# systemctl disable firewalld.service  #禁止使用防火墻(重啟也是禁止的)

Removed symlink /etc/systemd/system/dbus-org.Fedoraproject.FirewallD1.service.

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@localhost /]#

6.關(guān)閉selinux(需重啟生效)

[root@localhost /]# vi /etc/selinux/config

[root@localhost /]# cat /etc/selinux/config

# 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? #此處修改為disabled

# SELINUXTYPE= can take one of three two values:

#? ? targeted - Targeted processes are protected,

#? ? minimum - Modification of targeted policy. Only selected processes are protected.

#? ? mls - Multi Level Security protection.

SELINUXTYPE=targeted

[root@localhost /]#

7.修改內(nèi)核參數(shù)

加粗斜體部分為添加代碼

[sonny@localhost /]$ su root

Password:

?[root@localhost /]# vi /etc/sysctl.conf?

[root@localhost /]# cat /etc/sysctl.conf

cat: /etc/sysct.conf: No such file or directory

[root@localhost /]# cat /etc/sysctl.conf?

# System default settings live in /usr/lib/sysctl.d/00-system.conf.

# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file

#

# For more information, see sysctl.conf(5) and sysctl.d(5).

net.ipv4.icmp_echo_ignore_broadcasts = 1

net.ipv4.conf.all.rp_filter = 1

fs.file-max = 6815744 #設(shè)置最大打開文件數(shù)

fs.aio-max-nr = 1048576

kernel.shmall = 2097152 #共享內(nèi)存的總量,8G內(nèi)存設(shè)置:2097152*4k/1024/1024

kernel.shmmax = 2147483648 #最大共享內(nèi)存的段大小

kernel.shmmni = 4096 #整個系統(tǒng)共享內(nèi)存端的最大數(shù)

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范圍

net.core.rmem_default = 262144

net.core.rmem_max= 4194304

net.core.wmem_default= 262144

net.core.wmem_max= 1048576

[root@localhost /]#

使配置參數(shù)生效

[root@localhost /]# sysctl -p

net.ipv4.icmp_echo_ignore_broadcasts = 1

net.ipv4.conf.all.rp_filter = 1

sysctl: setting key "fs.file-max": Invalid argument

fs.file-max = 6815744 #設(shè)置最大打開文件數(shù)

fs.aio-max-nr = 1048576

sysctl: setting key "kernel.shmall": Invalid argument

kernel.shmall = 2097152 #共享內(nèi)存的總量,8G內(nèi)存設(shè)置:2097152*4k/1024/1024

sysctl: setting key "kernel.shmmax": Invalid argument

kernel.shmmax = 2147483648 #最大共享內(nèi)存的段大小

sysctl: setting key "kernel.shmmni": Invalid argument

kernel.shmmni = 4096 #整個系統(tǒng)共享內(nèi)存端的最大數(shù)

kernel.sem = 250 32000 100 128

sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument

net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范圍

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

[root@localhost /]#

注:關(guān)于systctl的解釋:Sysctl是一個允許改變正在運(yùn)行中的Linux系統(tǒng)的接口,它包含一些 TCP/IP 堆棧和虛擬內(nèi)存系統(tǒng)的高級選項。

參考文章:用Sysctl 調(diào)整Linux操作系統(tǒng)的性能 - 張善友 - 博客園

8.對oracle用戶設(shè)置限制,提高軟件運(yùn)行性能(加粗斜體為添加部分)

[sonny@localhost /]$ su root

Password:

[root@localhost /]# vi /etc/security/limits.conf?

[root@localhost /]# cat /etc/security/limits.conf

# /etc/security/limits.conf

#

#This file sets the resource limits for the users logged in via PAM.

#It does not affect resource limits of the system services.

#

#Also note that configuration files in /etc/security/limits.d directory,

#which are read in alphabetical order, override the settings in this

#file in case the domain is the same or more specific.

#That means for example that setting a limit for wildcard domain here

#can be overriden with a wildcard setting in a config file in the

#subdirectory, but a user specific setting here can be overriden only

#with a user specific setting in the subdirectory.

#

#Each line describes a limit for a user in the form:

#

#Where:#can be:

#? ? ? ? - a user name

#? ? ? ? - a group name, with @group syntax

#? ? ? ? - the wildcard *, for default entry

#? ? ? ? - the wildcard %, can be also used with %group syntax,

#? ? ? ? ? ? ? ? for maxlogin limit##can have the two values:#? ? ? ? - "soft" for enforcing the soft limits

#? ? ? ? - "hard" for enforcing hard limits##can be one of the following:

#? ? ? ? - core - limits the core file size (KB)

#? ? ? ? - data - max data size (KB)

#? ? ? ? - fsize - maximum filesize (KB)

#? ? ? ? - memlock - max locked-in-memory address space (KB)

#? ? ? ? - nofile - max number of open file descriptors

#? ? ? ? - rss - max resident set size (KB)

#? ? ? ? - stack - max stack size (KB)

#? ? ? ? - cpu - max CPU time (MIN)

#? ? ? ? - nproc - max number of processes

#? ? ? ? - as - address space limit (KB)

#? ? ? ? - maxlogins - max number of logins for this user

#? ? ? ? - maxsyslogins - max number of logins on the system

#? ? ? ? - priority - the priority to run user process with

#? ? ? ? - locks - max number of file locks the user can hold

#? ? ? ? - sigpending - max number of pending signals

#? ? ? ? - msgqueue - max memory used by POSIX message queues (bytes)

#? ? ? ? - nice - max nice priority allowed to raise to values: [-20, 19]

#? ? ? ? - rtprio - max realtime priority

#

#*? ? ? ? ? ? ? soft? ? core? ? ? ? ? ? 0

#*? ? ? ? ? ? ? hard? ? rss? ? ? ? ? ? 10000

#@student? ? ? ? hard? ? nproc? ? ? ? ? 20

#@faculty? ? ? ? soft? ? nproc? ? ? ? ? 20

#@faculty? ? ? ? hard? ? nproc? ? ? ? ? 50

#ftp? ? ? ? ? ? hard? ? nproc? ? ? ? ? 0

#@student? ? ? ? -? ? ? maxlogins? ? ? 4

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

# End of file

[root@localhost /]#

9.配置用戶的環(huán)境變量(加粗斜體部分為添加代碼)

[root@localhost /]# vi /home/oracle/.bash_profile

[root@localhost /]# cat /home/oracle/.bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export ORACLE_BASE=/data/oracle #oracle數(shù)據(jù)庫安裝目錄

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle數(shù)據(jù)庫路徑

export ORACLE_SID=orcl #oracle啟動數(shù)據(jù)庫實(shí)例名

export ORACLE_TERM=xterm #xterm窗口模式安裝

export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統(tǒng)環(huán)境變量

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系統(tǒng)環(huán)境變量

export LANG=C #防止安裝過程出現(xiàn)亂碼

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK? #設(shè)置Oracle客戶端字符集,必須與Oracle安裝時設(shè)置的字符集保持一致,如:ZHS16GBK,否則出現(xiàn)數(shù)據(jù)導(dǎo)入導(dǎo)出中文亂碼問題

[root@localhost /]#

使上述配置立即生效:

[oracle@localhost /]$ su root

Password:

[root@localhost /]# source /home/oracle/.bash_profile

[root@localhost /]#

10.上傳安裝包,我也是用xftp上傳的,很好用的工具,將oracle安裝包上傳到/usr/local/src

11.解壓安裝包

[oracle@localhost /]$ cd /usr/local/src  #進(jìn)入/usr/local/src目錄

[oracle@localhost src]$ ls

linux.x64_11gR2_database_1of2.zip? linux.x64_11gR2_database_2of2.zip

[oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/  #解壓

(省略...)

[oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/  #解壓

(省略...)

[oracle@localhost src]$ su root

Password:

[root@localhost src]# chown -R oracle:oinstall /data/database/database/

[root@localhost src]#

接下來終于到了oracle的安裝啦,小伙伴們,要加油奧。

三、oracle安裝

我昨天安裝沒有截圖,可以參考:CentOS7安裝Oracle 11gR2 圖文詳解 第3頁_數(shù)據(jù)庫技術(shù)_Linux公社-Linux系統(tǒng)門戶網(wǎng)站

1.圖形界面登陸oracle用戶

2.啟動oralce安裝,到/data/database/database/目錄下,執(zhí)行./runInstaller

這里會出現(xiàn)亂碼情況,解決如下:

先執(zhí)行:export LANG=zh_CN.UTF-8 【中文】? ? ? export LANG=en_US.UTF-8 【英文】

再運(yùn)行:./runInstaller

3.去掉勾,Email可以不用填寫,個人使用環(huán)境不需要自動接收Oracle的安全更新。

4.下一步,只安裝數(shù)據(jù)庫軟件,選擇install database software only

5.選擇單例安裝,前面的所有配置均為單例安裝。

6.添加語言,選擇English(united Kingdom)

7.默認(rèn)安裝版本企業(yè)版-Enterprise Edition

8.確定數(shù)據(jù)軟件的安裝路徑,自動讀取前面Oracle環(huán)境變量中配置的值,我是默認(rèn)安裝路徑。

9.理論上要創(chuàng)建Database Operation(OSOPER)Group:oper ,個人用,可以就使用dba用戶組

10.安裝檢查,按照提示信息一個一個解決。

swap空間不足解決 :(要求2.67G 實(shí)際2G)

[root@localhost oracle]# free -m  #查看當(dāng)前虛擬內(nèi)存

total? ? ? ? used? ? ? ? free? ? ? shared? buff/cache? available

Mem:? ? ? ? ? 1824? ? ? ? 1369? ? ? ? ? 93? ? ? ? ? 10? ? ? ? 361? ? ? ? 250

Swap:? ? ? ? ? 2048? ? ? ? ? 20? ? ? ? 2028

[root@localhost oracle]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000  #將當(dāng)前swap空間由2048M 增加到 3048M 新增一個2014的swap文件

1024000+0 records in

1024000+0 records out

1048576000 bytes (1.0 GB) copied, 29.4051 s, 35.7 MB/s

[root@localhost oracle]# mkswap /home/swap

Setting up swapspace version 1, size = 1023996 KiB

no label, UUID=5e3d39d7-285e-4c74-b321-1e2b3ffabf83

[root@localhost oracle]# free -m

total? ? ? ? used? ? ? ? free? ? ? shared? buff/cache? available

Mem:? ? ? ? ? 1824? ? ? ? 1275? ? ? ? ? 95? ? ? ? ? 10? ? ? ? 454? ? ? ? 342

Swap:? ? ? ? ? 2048? ? ? ? 141? ? ? ? 1907

[root@localhost oracle]# swapon /home/swap  #增加并啟用虛擬內(nèi)容

swapon: /home/swap: insecure permissions 0644, 0600 suggested.

[root@localhost oracle]# free -m  #再次查看

total? ? ? ? used? ? ? ? free? ? ? shared? buff/cache? available

Mem:? ? ? ? ? 1824? ? ? ? 1275? ? ? ? ? 94? ? ? ? ? 10? ? ? ? 454? ? ? ? 342

Swap:? ? ? ? ? 3048? ? ? ? 141? ? ? ? 2907

注:增加swap的時候注意后面是幾個零奧,不要寫錯了,我第一次少寫了一個0,后來又增加了一個swap1。

11.一個一個檢查package,在準(zhǔn)備階段中漏掉的,此處再安裝,有些系統(tǒng)報錯是因?yàn)楝F(xiàn)有的包的版本比檢測要高,最后忽略即可

12.準(zhǔn)備完畢,fuck “Finish”開始安裝

13.安裝過程是一個漫長的過程,中間有幾次卡住,沒有出現(xiàn)任何畫面,屏幕中間有條小線,嘗試多次,發(fā)現(xiàn)光標(biāo)在該線上,右鍵點(diǎn)擊Closed。

注:這里的線是一個消息提示框,可以拉伸開來,查看具體信息。

14.提示安裝成功

注:安裝過程中(我是第8步,安裝路徑那里),有時會出現(xiàn)界面卡著一直不動,我就遇到了這種情況,點(diǎn)擊關(guān)閉什么的都沒有反應(yīng),沒辦法只好用kill殺死進(jìn)程。這里大概遇到了4、5次,最后請教別人才發(fā)現(xiàn),我的空間不夠,因?yàn)榘惭b了好幾次,所以安裝日志就有好多,刪了前面的那些安裝日志,再重新開始運(yùn)行./runInstaller就可以了。

查看進(jìn)程號:ps -ef | grep java

殺死進(jìn)程方法:kill -9 進(jìn)程號

四、配置監(jiān)聽listener

1.執(zhí)行netca 報錯

[Oracle@localhost ~]$ netca

Oracle Net Services Configuration:

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

#? SIGSEGV (0xb) at pc=0x00007f69a69fcb9d, pid=8033, tid=140092892297024

#

# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_17-b03 mixed mode)

# Problematic frame:

# C? [libclntsh.so.11.1+0x62ab9d]? snlinGetAddrInfo+0x1b1

#

# An error report file with more information is saved as hs_err_pid8033.log

#

# If you would like to submit a bug report, please visit:

#? http://java.sun.com/webapps/bugreport/crash.jsp

#

/data/oracle/product/11.2.0/db_1/bin/netca: line 178:? 8033 Aborted? ? ? ? ? ? ? ? (core dumped) $JRE $JRE_OPTIONS -classpath $CLASSPATH oracle.net.ca.NetCA $*

[oracle@localhost ~]$

錯誤原因:安裝操作系統(tǒng)是默認(rèn)主機(jī)名localhost造成錯誤

解決辦法:

[racle]# cat /etc/sysconfig/network

# Created by anaconda

[root@localhost oracle]# vi /etc/sysconfig/network  #增加HOSTNAME

[root@localhost oracle]# cat /etc/sysconfig/network

# Created by anaconda

HOSTNAME=odb-sonny

[root@localhost oracle]# cat /etc/hosts

127.0.0.1? localhost localhost.localdomain localhost4 localhost4.localdomain4

::1? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6

[root@localhost oracle]# vi /etc/hosts  #增加HOSTNAME

[root@localhost oracle]# cat /etc/hosts

127.0.0.1? localhost localhost.localdomain localhost4 localhost4.localdomain4 odb-sonny

::1? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6

[root@localhost oracle]# hostname odb-sonny  #執(zhí)行

[root@localhost oracle]#

最后注銷當(dāng)前oracle用戶,重新登陸即可!

五、創(chuàng)建Oracle數(shù)據(jù)實(shí)例Orcl

注意:必須先創(chuàng)建監(jiān)聽,并且監(jiān)聽是啟動中,否則報錯。

su – oracle #切換到oracle用戶

dbca?#啟動oracle實(shí)例安裝界面

Next

選擇第一項:創(chuàng)建數(shù)據(jù)庫

Next

默認(rèn)選擇第一項:一般用途或事務(wù)處理

Next

全局?jǐn)?shù)據(jù)庫名:orcl

SID:orcl

Next

默認(rèn)即可,Next

口令配置,可以為每個賬戶設(shè)置不同的口令,也可以為所有賬戶設(shè)置一個相同的口令

選擇第二項:所有賬戶使用同一管理口令

Next

存儲類型:文件系統(tǒng)

存儲位置:使用模版中的數(shù)據(jù)庫文件位置

Next

默認(rèn)選擇:指定快速恢復(fù)區(qū)

Next

快速恢復(fù)區(qū)大小設(shè)置,如果系統(tǒng)剩余空間小于設(shè)置值會出現(xiàn)上面的提示

Next

默認(rèn),Next

切換到調(diào)整大小:進(jìn)程300(可以根據(jù)服務(wù)器配置設(shè)置)

切換到字符集設(shè)置

選擇第三項:從字符集列表中選擇

選擇:ZHS16GBK- GBK 16-bit Simplified Chinese

國家字符集:AL16UTF16-Unicode UTF-16 Universal character set

默認(rèn)語言:Simplified Chinese

默認(rèn)地區(qū):China

切換到連接模式,選擇:專用服務(wù)器模式

Next

全部設(shè)置完成之后,點(diǎn)Finish

勾選:創(chuàng)建數(shù)據(jù)庫

勾選:生成數(shù)據(jù)庫創(chuàng)建腳本

點(diǎn)Finish

Ok

Ok

Ok

注意:這里如果出現(xiàn)上面的提示,可以等安裝完成之后用root賬號登錄,執(zhí)行下面兩個命令

/data/oracle/product/11.2.0/db_1/root.sh

/data/oraInventory/orainstRoot.sh

生成/etc/oratab文件

正在創(chuàng)建數(shù)據(jù)庫

數(shù)據(jù)庫創(chuàng)建完成,點(diǎn)Exit退出

六、啟動oracle數(shù)據(jù)庫

su – oracle?#切換到oracle用戶

sqlplus /nolog #進(jìn)入sqlplus

conn / as sysdba?#以超級管理員權(quán)限登錄

startup?#啟動數(shù)據(jù)庫實(shí)例

quit?#退出

lsnrctl start?#啟動監(jiān)聽

startup參數(shù)說明:

startup?#不帶任何參數(shù),啟動數(shù)據(jù)庫實(shí)例并打開數(shù)據(jù)庫,一般選擇這種啟動方式

startup nomount?#只啟動數(shù)據(jù)庫實(shí)例,不打開數(shù)據(jù)庫,一般用于創(chuàng)建新的數(shù)據(jù)庫時使用

startup mount?#啟動數(shù)據(jù)庫實(shí)例,并加載數(shù)據(jù)庫,但不打開數(shù)據(jù)庫,一般用于修改數(shù)據(jù)庫名稱等管理時使用

七、關(guān)閉oracle數(shù)據(jù)庫

su – oracle?#切換到oracle用戶

lsnrctl stop?#關(guān)閉監(jiān)聽器

sqlplus /nolog?#進(jìn)入sqlplus

shutdown immediate?#關(guān)閉數(shù)據(jù)庫實(shí)例

quit?#退出

注:sqlplus /nolog ?/nolog是不登陸到數(shù)據(jù)庫服務(wù)器的意思,如果不加 /nolog sqlplus會提示輸入用戶名和密碼。

參考文獻(xiàn):www.360doc.com/content/10/1119/14/2614615_70659801.shtml

shutdown參數(shù)說明:

normal?#等待所有的用戶斷開連接,執(zhí)行命令后不允許新連接

immediate?#等待用戶完成當(dāng)前的語句后,再斷開用戶連接,不允許新用戶連接

transactional?#等待用戶完成當(dāng)前的事務(wù)后斷開連接,不允許新用戶連接

abort?#強(qiáng)行斷開連接并直接關(guān)閉數(shù)據(jù)庫

前面三種方法不會導(dǎo)致數(shù)據(jù)庫出錯,最后一種方法非特殊狀況不建議使用,

一般使用shutdown immediate關(guān)閉數(shù)據(jù)庫

備注:如果執(zhí)行shutdown immediate出現(xiàn)ORA-01012: not logged on錯誤

請先執(zhí)行以下語句

ps -ef|grep ora_dbw0_$orcl

kill -9 pid?#pid為進(jìn)程號

其中orcl 是數(shù)據(jù)庫的SID

八、設(shè)置oracle開機(jī)啟動

說明:linux下默認(rèn)安裝完Oracle后不會實(shí)現(xiàn)開機(jī)自啟動

1、su – root?#切換到root用戶操作

/data/oracle/product/11.2.0/db_1/root.sh?#執(zhí)行腳本,生成/etc/oratab文件

/data/oraInventory/orainstRoot.sh

2、vi /etc/oratab??#編輯

找到:$ORACLE_SID:$ORACLE_HOME::

取消前面的#注釋,修改為:

orcl:/data/oracle/product/11.2.0/db_1:Y??#orcl為oracle數(shù)據(jù)庫實(shí)例名稱

:wq!?#保存退出

3、vi /data/oracle/product/11.2.0/db_1/bin/dbstart?#編輯

找到:ORACLE_HOME_LISTNER=$1

修改為:ORACLE_HOME_LISTNER=$ORACLE_HOME

4、vi /data/oracle/product/11.2.0/db_1/bin/dbshut?#編輯

找到:ORACLE_HOME_LISTNER=$1

修改為:ORACLE_HOME_LISTNER=$ORACLE_HOME

5、創(chuàng)建oracle啟動腳本

vi /etc/init.d/oracle #編輯,添加以下代碼

##########################################################

#!/bin/sh

# chkconfig: 0356 99 10

# description: Startup Script for Oracle Databases

# Script path:/etc/init.d/oracle

# Author:www.osyunwei.com by qihang01

#

ORACLE_BASE=/data/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

ORACLE_SID=orcl

PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

#

ORA_OWNR="oracle"

#

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

echo "Oracle startup: cannot start"

exit 1

fi

#

case "$1" in

start)

su – $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart

echo "Oracle Start Succesful!"

;;

stop)

#

su – $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut

echo "Oracle Stop Succesful!"

;;

restart)

$0 stop

$0 start

;;

*)

echo $"Usage: `basename $0` {start|stop|restart}"

exit 1

esac

exit 0

##########################################################

:wq! #保存退出

chown oracle.oinstall /etc/init.d/oracle #更改文件所有者

chmod 755 /etc/init.d/oracle #添加執(zhí)行權(quán)限

ln -s /etc/init.d/oracle /etc/rc3.d/S99oracle #添加系統(tǒng)啟動級別3軟連接

ln -s /etc/init.d/oracle /etc/rc5.d/S99oracle #添加系統(tǒng)啟動級別5軟連接

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle #添加系統(tǒng)關(guān)機(jī)軟連接

ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle #添加系統(tǒng)重啟軟連接

chkconfig –add oracle #添加系統(tǒng)服務(wù)

chkconfig oracle on #設(shè)置開機(jī)啟動

備注:# chkconfig: 0356 99 10

0356:定義運(yùn)行級別

99:開機(jī)啟動優(yōu)先級(數(shù)字越大啟動越晚)

10:關(guān)機(jī)停止優(yōu)先級(數(shù)字越小關(guān)閉越早)

6、恢復(fù)操作系統(tǒng)標(biāo)識

vi /etc/redhat-release #編輯

把:redhat-7

修改為:CentOS Linux release 7.2.1511 (Core)

:wq! #保存退出

7、更改系統(tǒng)默認(rèn)啟動級別為3

vi /etc/inittab #編輯

id:3:initdefault: #修改5為3

:wq! #保存退出

8、測試

shutdown -r now #重啟系統(tǒng)

service oracle start #啟動oracle

service oracle stop #關(guān)閉oracle

/etc/init.d/oracle restart #重啟oracle

su – oracle #切換到oracle用戶

dbstart #啟動oracle

dbshut #關(guān)閉oracle

ps -ef | grep ora #查看oracle進(jìn)程

ps -ef | grep LISTEN | grep -v gre #查看oracle端口監(jiān)聽

lsnrctl status #查看oracle運(yùn)行狀態(tài)

至此,CentOS下安裝Oracle 11g R2完成。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容