最近要運維一個項目,準備在家辦公,公司無遠程做業環境,我的本本不喜歡別人碰,第一次在CentOS上安裝,本案留之後使用,畢竟不是常常安裝。html
注:Oracle11gR2 X64安裝java
1、環境準備python
安裝包:linux
1.VMware-workstation-full-11.1.0-2496824.exe 2.CentOS-7-x86_64-DVD-1511.iso 3.linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
以上以爲不是重點,不給下載地址,不描述安裝過程,安裝完CentOS 7,截圖以下:c++
第一次安裝防坑,沒有進行任何操做以前,先在VMware中建立該虛擬機快照,後期搞鬱悶了,能夠迴歸到該快照版本。特麼仍是不放心,又把該虛擬機完整克隆一份(強迫症)。web
2、安裝Oracle前準備數據庫
1.建立運行oracle數據庫的系統用戶和用戶組windows
[sonny@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]#
爲啥要建立oinstall用戶組及dba組? 參考:http://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-2-092412-zhs.html#13centos
理論上單例按照須要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.建立oracle數據庫安裝目錄
[sonny@localhost ~]$ su root Password: [root@localhost sonny]# mkdir -p /data/oracle #oracle數據庫安裝目錄 [root@localhost sonny]# mkdir -p /data/oraInventory #oracle數據庫配置文件目錄 [root@localhost sonny]# mkdir -p /data/database #oracle數據庫軟件包解壓目錄 [root@localhost sonny]# cd /data [root@localhost data]# ls #建立完畢檢查一下(強迫症) database oracle oraInventory [root@localhost data]# chown -R oracle:oinstall /data/oracle #設置目錄全部者爲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系統標識
oracle默認不支持CentOS系統安裝,Oracle Database 11g Release 2 的 OS要求參考: https://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#LADBI1106
我安裝是64位數據庫,On Linux x86-64:Red Hat Enterprise Linux 7 (RHEL 7)
另外,CentOS7.0.1511 基於 RHEL7.2 參考:https://linux.cn/article-3351-1.html
修改文件 /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數據庫所須要的軟件包
重複一遍,我安裝時Oracle Database 11g Release 2 64位數據庫。
Oracle Database Package Requirements for Linux x86-64 以下:(參考:https://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#BABCFJFG)
操做系統:Oracle Linux 7 and Red Hat Enterprise Linux 7 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
老實人,第一次搞,一個一個的安裝,命令也很簡單,反正文檔要求高版本也能夠:
[sonny@localhost data]$ su root Password: [root@localhost data]# yum install binutils
省略...
5.關閉防火牆 CentOS 7.2默認使用的是firewall做爲防火牆
[sonny@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 /]#
防火牆先禁用,搞好以後再配置,我的虛擬機,要毛線防火牆~~
6.關閉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 /]#
爲啥要關閉selinux?由於selinux過高深,非專業人士搞不懂~~
7.修改內核參數
紅色部分爲添加代碼
[sonny@localhost /]$ su root Password: [root@localhost /]# vi /etc/sysctl.conf [root@localhost /]# cat /etc/sysct.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/<name>.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 #設置最大打開文件數 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 #共享內存的總量,8G內存設置:2097152*4k/1024/1024 kernel.shmmax = 2147483648 #最大共享內存的段大小 kernel.shmmni = 4096 #整個系統共享內存端的最大數 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 /]#
使配置參數生效
[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 #設置最大打開文件數 fs.aio-max-nr = 1048576 sysctl: setting key "kernel.shmall": Invalid argument kernel.shmall = 2097152 #共享內存的總量,8G內存設置:2097152*4k/1024/1024 sysctl: setting key "kernel.shmmax": Invalid argument kernel.shmmax = 2147483648 #最大共享內存的段大小 sysctl: setting key "kernel.shmmni": Invalid argument kernel.shmmni = 4096 #整個系統共享內存端的最大數 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 /]#
8.對oracle用戶設置限制,提升軟件運行性能(紅色爲添加部分)
[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: # #<domain> <type> <item> <value> # #Where: #<domain> 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 # #<type> can have the two values: # - "soft" for enforcing the soft limits # - "hard" for enforcing hard limits # #<item> 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 # #<domain> <type> <item> <value> # #* 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.配置用戶的環境變量(紅色部分爲添加代碼)
[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數據庫安裝目錄 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle數據庫路徑 export ORACLE_SID=orcl #oracle啓動數據庫實例名 export ORACLE_TERM=xterm #xterm窗口模式安裝 export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統環境變量 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系統環境變量 export LANG=C #防止安裝過程出現亂碼 export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #設置Oracle客戶端字符集,必須與Oracle安裝時設置的字符集保持一致,如:ZHS16GBK,不然出現數據導入導出中文亂碼問題 [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 #進入/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]#
3、oracle安裝
1.圖形界面登錄oracle用戶:
2.啓動oralce安裝,到/data/database/database/目錄下,執行runInstaller
3.去掉勾,懶得填,我的使用環境不須要自動接收Oracle的安全更新。
4.下一步,只安裝數據庫軟件,我的用不要那些玩意~~
5.選擇單例安裝,前面的全部配置均爲單例安裝。
6.添加語言
7.默認安裝版本企業版-Enterprise Edition --圖沒了。
8.肯定數據軟件的安裝路徑,自動讀取前面oracle環境變量中配置的值。
9.理論上要建立Database Operation(OSOPER)Group:oper ,我的用,懶得建,就使用dba用戶組
10.安裝檢查,按照提示信息一個一個解決。
swap空間不足解決 :(要求2.67G 實際2G)
[root@localhost oracle]# free -m #查看當前虛擬內存 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 #將當前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 #增長並啓用虛擬內容 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
11.一個一個檢查package,在準備階段中漏掉的,此處再安裝,有些系統報錯是由於現有的包的版本比檢測要高,最後忽略便可。(點擊Check_Again 多檢查幾回)
12.準備完畢,fuck 「Finish」開始安裝。
13.安裝過程是一個漫長的過程,中間有幾回卡住,沒有出現任何畫面,屏幕中間有條小線,嘗試屢次,發現光標在該線上,右鍵點擊Closed,不知道關閉了啥,又能繼續安裝了。先裝吧,到時看安裝日誌再說。
14.提示安裝成功。安裝日誌懶得看,再說。
4、配置監聽listener
1.執行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 ~]$
錯誤緣由:安裝操做系統是默認主機名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 #執行 [root@localhost oracle]#
最後註銷當前oracle用戶,從新登錄便可!!此次發現打開配置界面正常,安裝windows下面配置便可。
5、建立Oracle數據實例Orcl
執行dbca命令,啓動oracle實例安裝界面,剩下的與Windows上安裝同樣,不廢話了:
注意:必須先建立監聽,而且監聽是啓動中,不然報錯。
6、檢查安裝日誌檢查
發現有幾個錯誤(緣由未知,後續再看):
錯誤1:
INFO: /lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14' collect2: error: ld returned 1 exit status INFO: make: *** [ctxhx] Error 1 INFO: End output from spawned process. INFO: ---------------------------------- INFO: Exception thrown from action: make Exception Name: MakefileException Exception String: Error in invoking target 'install' of makefile '/data/oracle/product/11.2.0/db_1/ctx/lib/ins_ctx.mk'. See '/data/oraInventory/logs/installActions2016-04-07_10-38-06PM.log' for details. Exception Severity: 1
錯誤2:
INFO: /usr/bin/ld: warning: -z lazyload ignored. /usr/bin/ld: warning: -z nolazyload ignored. /usr/bin/ld: /data/oracle/product/11.2.0/db_1/sysman/lib//libnmectl.a(nmectlt.o): undefined reference to symbol 'B_DestroyKeyObject' /usr/bin/ld: note: 'B_DestroyKeyObject' is defined in DSO /data/oracle/product/11.2.0/db_1/lib/libnnz11.so so try adding it to the linker command line /data/oracle/product/11.2.0/db_1/lib/libnnz11.so: could not read symbols: Invalid operation INFO: collect2: error: ld returned 1 exit status INFO: make[1]: *** [/data/oracle/product/11.2.0/db_1/sysman/lib/emdctl] Error 1 INFO: make[1]: Leaving directory `/data/oracle/product/11.2.0/db_1/sysman/lib' INFO: make: *** [emdctl] Error 2 INFO: End output from spawned process. INFO: ---------------------------------- INFO: Exception thrown from action: make Exception Name: MakefileException Exception String: Error in invoking target 'agent nmhs' of makefile '/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk'.
See '/data/oraInventory/logs/installActions2016-04-07_10-38-06PM.log' for details. Exception Severity: 1 INFO: Calling Action unixActions10.2.0.3.0 make registerOnly = false installMakePath = /usr/bin/make installMakeFileName = /data/oracle/product/11.2.0/db_1/rdbms/lib/ins_rdbms.mk installTarget = all_no_orcl undoMakeFileName = installArguments = ORACLE_HOME=/data/oracle/product/11.2.0/db_1 logFile = /data/oracle/product/11.2.0/db_1/install/make.log undoTarget = progMsg = Linking RDBMS Executables