轉載來源:https://blog.csdn.net/qq_22260641/article/details/76182447java
1、安裝Oracle前準備python
<code class="language-plain">[humf@localhost ~]$ su root #切換到root Password: [root@localhost sonny]# groupadd oinstall #建立用戶組oinstall [root@localhost sonny]# groupadd dba #建立用戶組dba [root@localhost sonny]# useradd -g oinstall -g dba -m oracle #建立oracle用戶,並加入到oinstall和dba用戶組 [root@localhost sonny]# passwd oracle #設置用戶oracle的登錄密碼,不設置密碼,在CentOS的圖形登錄界面無法登錄 Changing password for user oracle. New password: # 密碼 BAD PASSWORD: The password is shorter than 8 characters Retype new password: # 確認密碼 passwd: all authentication tokens updated successfully. [root@localhost sonny]# id oracle # 查看新建的oracle用戶 uid=1001(oracle) gid=1002(dba) groups=1002(dba) [root@localhost sonny]# </code>
<code class="language-plain">oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536</code>
<code class="language-plain">session required /lib/security/pam_limits.so session required pam_limits.so </code>
<code class="language-plain">fs.file-max = 6815744 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576</code>
<code class="language-plain">linux:~ # sysctl -p net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.all.rp_filter = 1 fs.file-max = 6815744 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576</code>
<code class="language-plain">if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi</code>
<code class="language-plain">mkdir /home/oracle/app mkdir /home/oracle/app/oracle mkdir /home/oracle/app/oradata mkdir /home/oracle/app/oracle/product</code>
<code class="language-plain">chown -R oracle:oinstall /home/oracle/app</code>
<code class="language-plain">export ORACLE_BASE=/home/oracle/app export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib</code>
<code class="language-plain">[humf@localhost /]$ su root Password: [root@localhost /]# systemctl status firewalld.service #查看防火牆狀態,運行中 ● 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 #關閉防火牆 [root@localhost /]# systemctl status firewalld.service #再次查看防火牆狀態,發現已關閉 ● 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 /]# </code>
<code class="language-plain">[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 /]# </code>
<code class="language-plain"> # yum -y groups install "GNOME Desktop" # startx</code>
<code class="language-plain"><span> </span># yum install epel* -y</code>
<code class="language-plain"><span><span> </span> </span># yum --enablerepo=epel -y install xrdp</code>
<code class="language-plain"><span> </span># systemctl start xrdp # systemctl enable xrdp</code>
<code class="language-plain">unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip</code>
<code class="language-plain">cd database</code>
<code class="language-plain">[humf@localhost data]$ su root Password: [root@localhost data]# yum install binutils</code>
<code class="language-plain">[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 ~]$ </code>
<code class="language-plain">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 #執行 [root@localhost oracle]# </code>
<code class="language-plain">cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora</code>
<code class="language-plain">cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora</code>
<code class="language-plain">su - oracle </code>
<code class="language-plain">lsnrctl start </code>
<code class="language-plain">lsnrctl stop</code>
<code class="language-plain">[oracle@oracle ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 27 02:12:12 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> quit</code>
<code class="language-plain">sudo service iptables stop</code>
<code class="language-plain">sudo vi /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT :wq</code>
<code class="language-plain">sudo service iptables restart</code>
<code class="language-plain">sudo service iptables save </code>
<code class="language-plain">sudo iptables -L –n</code>
<code class="language-sql">select name from v$datafile</code>
<code class="language-sql">CREATE TABLESPACE NOTIFYDB DATAFILE '/home/oracle/app/oradata/orcl/scsdb.dbf' SIZE 200M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; </code>
<code class="language-sql">CREATE USER scs IDENTIFIED BY scs DEFAULT TABLESPACE NOTIFYDB;</code>
<code class="language-plain">grant connect,resource to scs; grant unlimited tablespace to scs; grant create database link to scs; grant select any sequence,create materialized view to scs; </code>