Centos7下部署oracle数据库server端

转载博客原址: 史上最详细最全的Linux上安装Oracle的教程-centos7-humf

一、安装Oracle前准备


1.创建运行oracle数据库的系统用户和用户组


 
 
  1. [ humf@localhost ~]$ su root   #切换到root
  2. Password:
  3. [ root@localhost sonny] # groupadd oinstall  #创建用户组oinstall
  4. [ root@localhost sonny] # groupadd dba  #创建用户组dba
  5. [ root@localhost sonny] # useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
  6. [ root@localhost sonny] # passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
  7. Changing password for user oracle.
  8. New password:    # 密码
  9. BAD PASSWORD: The password is shorter than 8 characters
  10. Retype new password:    # 确认密码
  11. passwd: all authentication tokens updated successfully.
  12. [ root@localhost sonny] # id oracle # 查看新建的oracle用户
  13. uid= 1001(oracle) gid= 1002(dba) groups= 1002(dba)
  14. [ root@localhost sonny] #


理论上单例按照需要3种用户组,实际只建两个oinstall和dba,后面再安装oracle数据库的时候把OSOPER组也设置是dba组。

a.oracle 清单组(一般为oinstall):

 OINSTALL 组的成员被视为 Oracle 软件的“所有者”,拥有对 Oracle 中央清单 (oraInventory) 的写入权限。在一个 Linux 系统上首次安装 Oracle 软件时,

 OUI 会创建 /etc/oraInst.loc 文件。该文件指定 Oracle 清单组的名称(默认为 oinstall)以及 Oracle 中央清单目录的路径。

b.数据库管理员(OSDBA,一般为 dba):

 OSDBA 组的成员可通过操作系统身份验证使用 SQL 以 SYSDBA 身份连接到一个 Oracle 实例。该组的成员可执行关键的数据库管理任务,如创建数据库、启动和关

 闭实例。该组的默认名称为dba。SYSDBA 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。不要混淆 SYSDBA 

 系统权限与数据库角色 DBA。DBA 角色不包括 SYSDBA 或 SYSOPER 系统权限。

c.数据库操作员组(OSOPER,一般为 oper):

 OSOPER 组的成员可通过操作系统身份验证使用 SQL 以 SYSOPER 身份连接到一个 Oracle 实例。这个可选组的成员拥有一组有限的数据库管理权限,如管理和运行备份。

 该组的默认名称为oper。SYSOPER 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。要使用该组,选择 Advanced 安装类型来安装 Oracle 数据库软件。 



 2.修改操作系统核心参数

在Root用户下执行以下步骤:

1)修改用户的SHELL的限制,修改/etc/security/limits.conf文件

输入命令:vi /etc/security/limits.conf,按i键进入编辑模式,将下列内容加入该文件。

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

编辑完成后按Esc键,输入“:wq”存盘退出

2)修改/etc/pam.d/login 文件,输入命令:vi /etc/pam.d/login,按i键进入编辑模式,将下列内容加入该文件。


 
 
  1. session required /lib/security/pam_limits.so
  2. session required pam_limits.so


编辑完成后按Esc键,输入“:wq”存盘退出

3)修改linux内核,修改/etc/sysctl.conf文件,输入命令: vi /etc/sysctl.conf ,按i键进入编辑模式,将下列内容加入该文件


 
 
  1. fs.file- max = 6815744
  2. fs.aio- max-nr = 1048576
  3. kernel.shmall = 2097152
  4. kernel.shmmax = 2147483648
  5. kernel.shmmni = 4096
  6. kernel.sem = 250 32000 100 128
  7. net.ipv4.ip_local_port_range = 9000 65500
  8. net.core.rmem_default = 4194304
  9. net.core.rmem_max = 4194304
  10. net.core.wmem_default = 262144
  11. net.core.wmem_max = 1048576


编辑完成后按Esc键,输入“:wq”存盘退出

4)要使 /etc/sysctl.conf 更改立即生效,执行以下命令。 输入:sysctl -p 显示如下:

 
 
  1. linux:~ # sysctl -p
  2. net.ipv4.icmp_echo_ignore_broadcasts = 1
  3. net.ipv4.conf.all.rp_filter = 1
  4. fs.file- max = 6815744
  5. fs.aio- max-nr = 1048576
  6. kernel.shmall = 2097152
  7. kernel.shmmax = 2147483648
  8. kernel.shmmni = 4096
  9. kernel.sem = 250 32000 100 128
  10. net.ipv4.ip_local_port_range = 9000 65500
  11. net.core.rmem_default = 4194304
  12. net.core.rmem_max = 4194304
  13. net.core.wmem_default = 262144
  14. net.core.wmem_max = 1048576



5)编辑 /etc/profile ,输入命令:vi /etc/profile,按i键进入编辑模式,将下列内容加入该文件。

 
 
  1. if [ U S E R &lt; / s p a n &gt; &lt; / s p a n &gt; = &lt; s p a n c l a s s = &quot; h l j s − s t r i n g &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − s t r i n g &quot; &gt; &quot; o r a c l e &quot; &lt; / s p a n &gt; &lt; / s p a n &gt; ] ; &lt; s p a n c l a s s = &quot; h l j s − k e y w o r d &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − k e y w o r d &quot; &gt; t h e n &lt; / s p a n &gt; &lt; / s p a n &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 2 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 3 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − k e y w o r d &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − k e y w o r d &quot; &gt; i f &lt; / s p a n &gt; &lt; / s p a n &gt; [ &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; USER&lt;/span&gt;&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;oracle&quot;&lt;/span&gt;&lt;/span&gt; ]; &lt;span class=&quot;hljs-keyword&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;then&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;2&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt; &lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;3&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;&lt;/span&gt; [ &lt;span class=&quot;hljs-variable&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt; USER</span></span>=<spanclass="hljsstring"><spanclass="hljsstring">"oracle"</span></span>];<spanclass="hljskeyword"><spanclass="hljskeyword">then</span></span></div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="2"></div></div><divclass="hljslncode"><divclass="hljslnline"></div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="3"></div></div><divclass="hljslncode"><divclass="hljslnline"><spanclass="hljskeyword"><spanclass="hljskeyword">if</span></span>[<spanclass="hljsvariable"><spanclass="hljsvariable">SHELL = “/bin/ksh” ]; then
  2. ulimit -p 16384
  3. ulimit -n 65536
  4. else
  5. ulimit -u 16384 -n 65536
  6. fi
  7. fi


编辑完成后按Esc键,输入“:wq”存盘退出


6)创建数据库软件目录和数据文件存放目录,目录的位置,根据自己的情况来定,注意磁盘空间即可,这里我把其放到oracle用户下,例如:

输入命令:

 
 
  1. mkdir /home/oracle/app
  2. mkdir /home/oracle/app/oracle
  3. mkdir /home/oracle/app/oradata
  4. mkdir /home/oracle/app/oracle/product


7)更改目录属主为Oracle用户所有,输入命令:

chown -R oracle:oinstall /home/oracle/app
 
 


8)配置oracle用户的环境变量,首先,切换到新创建的oracle用户下,

输入:su – oracle ,然后直接在输入 : vi .bash_profile

按i编辑 .bash_profile,进入编辑模式,增加以下内容:


 
 
  1. export ORACLE_BASE=/home/oracle/app
  2. export ORACLE_HOME= O R A C L E B A S E &lt; / s p a n &gt; &lt; / s p a n &gt; / o r a c l e / p r o d u c t / 11.2.0 / d b h o m e 1 &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 4 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 5 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − b u i l t i n &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − b u i l t i n &quot; &gt; e x p o r t &lt; / s p a n &gt; &lt; / s p a n &gt; O R A C L E S I D = o r c l &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 6 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 7 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − b u i l t i n &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − b u i l t i n &quot; &gt; e x p o r t &lt; / s p a n &gt; &lt; / s p a n &gt; P A T H = &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; ORACLE_BASE&lt;/span&gt;&lt;/span&gt;/oracle/product/11.2.0/dbhome_1&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;4&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt; &lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;5&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;export&lt;/span&gt;&lt;/span&gt; ORACLE_SID=orcl&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;6&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt; &lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;7&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;export&lt;/span&gt;&lt;/span&gt; PATH=&lt;span class=&quot;hljs-variable&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt; ORACLEBASE</span></span>/oracle/product/11.2.0/dbhome1</div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="4"></div></div><divclass="hljslncode"><divclass="hljslnline"></div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="5"></div></div><divclass="hljslncode"><divclass="hljslnline"><spanclass="hljsbuiltin"><spanclass="hljsbuiltin">export</span></span>ORACLESID=orcl</div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="6"></div></div><divclass="hljslncode"><divclass="hljslnline"></div></div></li><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="7"></div></div><divclass="hljslncode"><divclass="hljslnline"><spanclass="hljsbuiltin"><spanclass="hljsbuiltin">export</span></span>PATH=<spanclass="hljsvariable"><spanclass="hljsvariable">PATH: H O M E &lt; / s p a n &gt; &lt; / s p a n &gt; / b i n : &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − v a r i a b l e &quot; &gt; HOME&lt;/span&gt;&lt;/span&gt;/bin:&lt;span class=&quot;hljs-variable&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt; HOME</span></span>/bin:<spanclass="hljsvariable"><spanclass="hljsvariable">ORACLE_HOME/bin
  3. export LD_LIBRARY_PATH= O R A C L E H O M E &lt; / s p a n &gt; &lt; / s p a n &gt; / l i b : / u s r / l i b &lt; / d i v &gt; &lt; / d i v &gt; &lt; / l i &gt; &lt; / o l &gt; &lt; / c o d e &gt; &lt; d i v c l a s s = &quot; h l j s − b u t t o n &quot; d a t a − t i t l e = &quot; 复 制 &quot; &gt; &lt; / d i v &gt; &lt; / p r e &gt; &lt; b r &gt; 编 辑 完 成 后 按 E s c 键 , 输 入 “ : w q ” 存 盘 退 出 &lt; b r &gt; &lt; b r &gt; p s : 我 的 云 服 务 器 没 有 防 火 墙 , 如 果 你 们 有 , 可 以 关 闭 &lt; b r &gt; − − 关 闭 防 火 墙 C e n t O S 7.2 默 认 使 用 的 是 f i r e w a l l 作 为 防 火 墙 &lt; b r &gt; &lt; b r &gt; &lt; p r e o n c l i c k = &quot; h l j s . c o p y C o d e ( e v e n t ) &quot; &gt; &lt; c o d e c l a s s = &quot; l a n g u a g e − c s h l j s &quot; &gt; &lt; o l c l a s s = &quot; h l j s − l n &quot; &gt; &lt; l i &gt; &lt; d i v c l a s s = &quot; h l j s − l n − n u m b e r s &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e h l j s − l n − n &quot; d a t a − l i n e − n u m b e r = &quot; 1 &quot; &gt; &lt; / d i v &gt; &lt; / d i v &gt; &lt; d i v c l a s s = &quot; h l j s − l n − c o d e &quot; &gt; &lt; d i v c l a s s = &quot; h l j s − l n − l i n e &quot; &gt; [ &lt; s p a n c l a s s = &quot; h l j s − m e t a &quot; &gt; &lt; s p a n c l a s s = &quot; h l j s − m e t a &quot; &gt; h u m f @ l o c a l h o s t / &lt; / s p a n &gt; &lt; / s p a n &gt; ] ORACLE_HOME&lt;/span&gt;&lt;/span&gt;/lib:/usr/lib&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/code&gt;&lt;div class=&quot;hljs-button&quot; data-title=&quot;复制&quot;&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br&gt; 编辑完成后按Esc键,输入“:wq”存盘退出&lt;br&gt;&lt;br&gt; ps:我的云服务器没有防火墙,如果你们有,可以关闭&lt;br&gt; --关闭防火墙 CentOS 7.2默认使用的是firewall作为防火墙&lt;br&gt;&lt;br&gt;&lt;pre onclick=&quot;hljs.copyCode(event)&quot;&gt;&lt;code class=&quot;language-cs hljs&quot;&gt;&lt;ol class=&quot;hljs-ln&quot;&gt;&lt;li&gt;&lt;div class=&quot;hljs-ln-numbers&quot;&gt;&lt;div class=&quot;hljs-ln-line hljs-ln-n&quot; data-line-number=&quot;1&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;hljs-ln-code&quot;&gt;&lt;div class=&quot;hljs-ln-line&quot;&gt;[&lt;span class=&quot;hljs-meta&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;humf@localhost /&lt;/span&gt;&lt;/span&gt;] ORACLEHOME</span></span>/lib:/usr/lib</div></div></li></ol></code><divclass="hljsbutton"datatitle=""></div></pre><br>Esc:wq退<br><br>ps:<br>CentOS7.2使firewall<br><br><preonclick="hljs.copyCode(event)"><codeclass="languagecshljs"><olclass="hljsln"><li><divclass="hljslnnumbers"><divclass="hljslnlinehljslnn"datalinenumber="1"></div></div><divclass="hljslncode"><divclass="hljslnline">[<spanclass="hljsmeta"><spanclass="hljsmeta">humf@localhost/</span></span>] su root
  4. Password:
  5. [ root@localhost /] # systemctl status firewalld.service  #查看防火墙状态,运行中
  6. ● firewalld.service - firewalld - dynamic firewall daemon
  7. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
  8. Active: active (running) since Thu 2016 -04 -07 18: 54: 29 PDT; 2h 20min ago
  9. Main PID: 802 (firewalld)
  10. CGroup: /system.slice/firewalld.service
  11. └─ 802 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
  12. Apr 07 18: 54: 25 localhost.localdomain systemd[ 1]: Starting firewalld - dynamic firewall daemon…
  13. Apr 07 18: 54: 29 localhost.localdomain systemd[ 1]: Started firewalld - dynamic firewall daemon.
  14. [ root@localhost /] # systemctl stop firewalld.service  #关闭防火墙
  15. [ root@localhost /] # systemctl status firewalld.service  #再次查看防火墙状态,发现已关闭
  16. ● firewalld.service - firewalld - dynamic firewall daemon
  17. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
  18. Active: inactive (dead) since Thu 2016 -04 -07 21: 15: 34 PDT; 9s ago
  19. Main PID: 802 (code=exited, status= 0/SUCCESS)
  20. Apr 07 18: 54: 25 localhost.localdomain systemd[ 1]: Starting firewalld - dynamic firewall daemon…
  21. Apr 07 18: 54: 29 localhost.localdomain systemd[ 1]: Started firewalld - dynamic firewall daemon.
  22. Apr 07 21: 15: 33 localhost systemd[ 1]: Stopping firewalld - dynamic firewall daemon…
  23. Apr 07 21: 15: 34 localhost systemd[ 1]: Stopped firewalld - dynamic firewall daemon.
  24. [ root@localhost /] # systemctl disable firewalld.service  #禁止使用防火墙(重启也是禁止的)
  25. Removed symlink /etc/systemd/system/dbus-org.Fedoraproject.FirewallD1.service.
  26. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
  27. [ root@localhost /] #


 防火墙先禁用,搞好之后再配置,个人虚拟机,要毛线防火墙~~


6.关闭selinux(需重启生效)


 
 
  1. [root@localhost /] # vi /etc/selinux/config
  2. [root@localhost /] # cat /etc/selinux/config
  3. # This file controls the state of SELinux on the system.
  4. # SELINUX= can take one of these three values:
  5. # enforcing - SELinux security policy is enforced.
  6. # permissive - SELinux prints warnings instead of enforcing.
  7. # disabled - No SELinux policy is loaded.
  8. SELINUX=disabled #此处修改为disabled
  9. # SELINUXTYPE= can take one of three two values:
  10. # targeted - Targeted processes are protected,
  11. # minimum - Modification of targeted policy. Only selected processes are protected.
  12. # mls - Multi Level Security protection.
  13. SELINUXTYPE=targeted
  14. [root@localhost /] #



为啥要关闭selinux?因为selinux太高深,非专业人士搞不懂~~



二、正式Oracle的安装过程



1)当上述系统要求操作全部完成后,注销系统,在图形界面以Oracle用户登陆。



PS:对于不会用图形界面的这边教你怎么用Windows远程连接Oracle图形界面

   前提: 
2.1.1 CentOS已经安装桌面,如果无桌面,请执行 (yum不会的可以百度,这边不赘述了)

 
 
  1. # yum -y groups install “GNOME Desktop”
  2. # startx
2.1.2 配置源
<span>		</span># yum install  epel* -y
 
 
2.1.3 安装xrdp
<span><span>	</span>	</span># yum --enablerepo=epel -y install xrdp
 
 
2.1.4 启动xrdp并设置开机启动

 
 
  1. <span> </span> # systemctl start xrdp
  2. # systemctl enable xrdp

2.1.5 打开Windows的远程工具Mobaxterm输入服务器IP用Oracle账户登陆就行



一定要使用ssh -X 服务器IP进行登陆,-X参数使得图形指令也能够传输,这样远程通过将图形绘制指令传输到本地执行绘制以在本地显示远程图形化界面。首先将下载的Oracle安装包复制到linux中,建议使用现阶段使用最多的11gR2版本,遇到问题在网上也很好找到对应版本的解决办法,下载地址: linux-oracle-11gR2下载,用scp命令进行拷贝。

打开一个终端,运行unzip命令解压oracle安装文件,如:

输入命令:


 
 
  1. unzip linux .x64_11gR2_database_1of2 .zip
  2. unzip linux .x64_11gR2_database_2of2 .zip



解压完成后 cd 进入其解压后的目录database

输入命令:
cd database
 
 


使用ls命令可以查看解压后database所包含的文件,如下图:


2)执行安装,输入命令:./runInstaller


这里新手安装最好选择第一项Create and configure a database方便初次使用







装到这一步,可以看到,可以查看到有很多的rpm包没有,这里可以通过yum安装
我这边的是操作系统:Oracle Linux 7 centos
The following packages (or later versions) must be installed:
binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64 
gcc-4.8.2-3.el7.x86_64 
gcc-c++-4.8.2-3.el7.x86_64 
glibc-2.17-36.el7.i686 
glibc-2.17-36.el7.x86_64 
glibc-devel-2.17-36.el7.i686 
glibc-devel-2.17-36.el7.x86_64 
ksh
libaio-0.3.109-9.el7.i686 
libaio-0.3.109-9.el7.x86_64 
libaio-devel-0.3.109-9.el7.i686 
libaio-devel-0.3.109-9.el7.x86_64 
libgcc-4.8.2-3.el7.i686 
libgcc-4.8.2-3.el7.x86_64 
libstdc++-4.8.2-3.el7.i686 
libstdc++-4.8.2-3.el7.x86_64 
libstdc++-devel-4.8.2-3.el7.i686 
libstdc++-devel-4.8.2-3.el7.x86_64 
libXi-1.7.2-1.el7.i686 
libXi-1.7.2-1.el7.x86_64 
libXtst-1.2.2-1.el7.i686 
libXtst-1.2.2-1.el7.x86_64 
make-3.82-19.el7.x86_64 
sysstat-10.1.5-1.el7.x86_64 
一个一个的安装,命令也很简单,反正文档要求高版本也可以:


 
 
  1. [ humf@localhost data]$ su root
  2. Password:
  3. [ root@localhost data]# yum install binutils

省略...

一个一个检查package,在准备阶段中漏掉的,此处再安装,有些系统报错是因为现有的包的版本比检测要高,最后右上角忽略即可
若出现yum源中没有的包,可以去镜像链接: http://mirrors.163.com/centos/下载缺少的rpm包,然后使用rpm -ivh进行安装

3)安装过程是一个漫长的过程,中间有几次卡住,没有出现任何画面,屏幕中间有条小线,尝试多次,发现光标在该线上,右键点击Closed,不知道关闭了啥,又能继续安装了。先装吧,到时有问题看日志





4)配置监听listener


1)执行netca 报错


 
 
  1. [Oracle@localhost ~]$ netca
  2. Oracle Net Services Configuration:
  3. #
  4. # An unexpected error has been detected by HotSpot Virtual Machine:
  5. #
  6. # SIGSEGV (0xb) at pc=0x00007f69a69fcb9d, pid=8033, tid=140092892297024
  7. #
  8. # Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_17-b03 mixed mode)
  9. # Problematic frame:
  10. # C [libclntsh.so.11.1+0x62ab9d] snlinGetAddrInfo+0x1b1
  11. #
  12. # An error report file with more information is saved as hs_err_pid8033.log
  13. #
  14. # If you would like to submit a bug report, please visit:
  15. # http://java.sun.com/webapps/bugreport/crash.jsp
  16. #
  17. /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 $*
  18. [oracle@localhost ~]$


错误原因:安装操作系统是默认主机名localhost造成错误

解决办法:


 
 
  1. racle] # cat /etc/sysconfig/network
  2. # Created by anaconda
  3. [root@localhost oracle] # vi /etc/sysconfig/network  #增加HOSTNAME
  4. [root@localhost oracle] # cat /etc/sysconfig/network
  5. # Created by anaconda
  6. HOSTNAME=odb-sonny
  7. [root@localhost oracle] # cat /etc/hosts
  8. 127.0. 0. 1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  9. :: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  10. [root@localhost oracle] # vi /etc/hosts  #增加HOSTNAME
  11. [root@localhost oracle] # cat /etc/hosts
  12. 127.0. 0. 1 localhost localhost.localdomain localhost4 localhost4.localdomain4 odb-sonny
  13. :: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  14. [root@localhost oracle] # hostname odb-sonny  #执行
  15. [root@localhost oracle] #

最后注销当前oracle用户,重新登陆即可!!这次发现打开配置界面正常




5)创建Oracle数据实例Orcl


执行dbca命令,启动oracle实例安装界面,剩下的与Windows上安装一样,不废话了:


注意:必须先创建监听,并且监听是启动中,否则报错。


字符集的选择很关键,数据库存储编码选择ZHS16GBK,国家字符集编码选择AL32UTF8,这里关系到后面服务端和客户端环境变量字符集的配置




经过漫长的等待,当看到此界面,说明oracle建库完成


这样oracle服务器安装配置基本就完成了
接下来就是在~/.bashrc对oracle服务端相关环境变量进行配置:

注意:
1、Linux oracle数据库listener.ora存放路径

cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
 
 

2、Linux oracle数据库tnsnames.ora存放路径
cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
 
 

3、ORACLE启动监听器
(1)切换至oracle安装用户(一般为oracle)
su - oracle 
(2)启动监听器
lsnrctl start 
 
 
(3)停止监听器
lsnrctl stop
 
 
4、启动测试oracle:

 
 
  1. [ oracle@oracle ~]$ sqlplus /nolog
  2. SQL*Plus: Release 11.2 .0 .1 .0 Production on Fri Jul 27 02: 12: 12 2012
  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  4. SQL> quit

测试的另一种方法:找一台windows平台电脑,telnet oracle主机IP地址:1521,通的话,会出现一个黑屏,光标一闪一闪。
5、Linux开放1521端口允许网络连接Oracle Listener
症状:
(1)TCP/IP连接是通的。可以用ping 命令测试。
(2)服务器上Oracle Listener已经启动。
lsnrctl status 查看listener状态
lsnrctl start 启动Oracle listener 
(3)客户端得到的错误信息通常是:ORA-12170: TNS:连接超时 
这时,我们基本可以肯定是服务器没有开放1521端口(假设你用默认设置)
解决方法: 
(1)假如你是在一个局域网环境,配置了防火墙。那么可以关闭Linux的防火墙。
sudo service iptables stop
 
 
(2)编辑iptables, 开放1521端口:

 
 
  1. sudo vi /etc/sysconfig/iptables
  2. -A INPUT -p tcp - m state -- state NEW - m tcp --dport 1521 -j ACCEPT
  3. :wq
重启防火墙
sudo service iptables restart
保存配置,以便linux重启后依然有效
sudo service iptables save 
查看防火墙规则:
sudo iptables -L –n


PS:如果你是云服务器,请看看自己的安全策略组有没有给1521添加


6、linux下创建oracle用户表空间
就是在已有的数据库实例上创建一个新的帐号,访问一些新的表
操作步骤如下:
(1)登录linux,以oracle用户登录(如果是root用户登录的,登录后用 su - oracle命令切换成oracle用户)
(2)以sysdba方式来打开sqlplus,命令如下: sqlplus "/as sysdba"
(3)查看我们常规将用户表空间放置位置:执行如下sql:
select name from v$datafile
 
 
(4)创建用户表空间:
CREATE TABLESPACE NOTIFYDB DATAFILE '/home/oracle/app/oradata/orcl/scsdb.dbf' SIZE 200M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; 
 
 
(5)创建用户,指定密码和上边创建的用户表空间
CREATE USER scs IDENTIFIED BY scs DEFAULT TABLESPACE NOTIFYDB;
 
 
(6)赋予权限

 
 
  1. grant connect, resource to scs;
  2. grant unlimited tablespace to scs;
  3. grant create database link to scs;
  4. grant select any sequence, create materialized view to scs;

--经过以上操作,我们就可以使用scs/scs登录指定的实例,创建我们自己的表了



















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值