安裝 Oracle Database 12c.html
在安裝以前,更改一些安裝Oracle數據時的要求設置linux
[root@server ~]# yum -y install binutils compat-libcap1 gcc gcc-c++ glibc glibc.i686 glibc-devel glibc.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++l7.i686 libstdc++-devel libstdc++-devel.i686 compat-libstdc++-33 compat-libstdc++-33.i686 libXi libXi.i686 libXtst libXtst.i686 make sysstatc++
[root@server ~]# MEMTOTAL=$(free -b | sed -n '2p' | awk '{print $2}') 數據庫
[root@server ~]# SHMMAX=$(expr $MEMTOTAL / 2) 安全
[root@server ~]# SHMMNI=4096 bash
[root@server ~]# PAGESIZE=$(getconf PAGE_SIZE)服務器
[root@server ~]# cat >> /etc/sysctl.conf << EOF網絡
fs.aio-max-nr = 1048576session
fs.file-max = 6815744oracle
kernel.shmmax = $SHMMAX
kernel.shmall = `expr \( $SHMMAX / $PAGESIZE \) \* \( $SHMMNI / 16 \)`
kernel.shmmni = $SHMMNI
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
EOF
[root@server ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 6274715648
kernel.shmall = 392169728
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
[root@server ~]# i=54321; for group in oinstall dba backupdba oper dgdba kmdba; do
groupadd -g $i $group; i=`expr $i + 1`
done
[root@server ~]# useradd -u 1200 -g oinstall -G dba,oper,backupdba,dgdba,kmdba -d /home/oracle oracle
[root@server ~]# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@server ~]# mkdir -p /u01/app/oracle
[root@server ~]# chown -R oracle:oinstall /u01/app
[root@server ~]# chmod -R 775 /u01
[root@server ~]# vi /etc/pam.d/login
# near line 14: add
session required pam_selinux.so open
session required pam_namespace.so
session required pam_limits.so
session optional pam_keyinit.so force revoke
session include system-auth
-session optional pam_ck_connector.so
[root@server ~]# vi /etc/security/limits.conf
# 結尾處加入:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
dlp login: oracle
Password:
[oracle@server ~]$ vi ~/.bash_profile
#結尾處添加:
umask 022
export ORACLE_BASE=/u01/app/oracle
# 爲安裝建立一個臨時目錄
[oracle@server ~]$ mkdir tmp
[oracle@server ~]$ cd tmp
[oracle@server tmp]$ unzip linuxamd64_12102_database_1of2.zip
[oracle@server tmp]$ unzip linuxamd64_12102_database_2of2.zip
[oracle@server tmp]$ ./database/runInstaller
[5]在這個界面, 選擇 "Install database software only".
[8] 選擇你要安裝的版本
[9] 爲「甲骨文」指定基本目錄和文件。在這個例子中,默認狀況下,繼續進行下一個。
[10] 指定已經安裝的目錄,默認繼續.
[11]指定特權組,默認繼續.
[14]開始安裝
[15] 下面的界面出現以後,找到一個終端開始用root用戶執行下面的操做.
[root@server ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@server ~]#
[root@server ~]# /u01/app/oracle/product/12.1.0/dbhome_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/12.1.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]: # Enter
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
[16] 安裝完成,點擊關閉。
[17] 爲oracle用戶設置環境變量
[oracle@server ~]$ vi ~/.bash_profile
# 結尾處添加
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
[oracle@server ~]$ source ~/.bash_profile
[oracle@server ~]$ rm -rf tmp
在oracle網絡上建立oracle監聽
[1]登陸oracle界面,輸入netca命令
[2]檢查 "Listener Configuration"
[3]一直next下去.
[4] 輸入監聽名字,任意選擇一個。
[5] 默認"TCP".
[6] Set a port. This example goes next
[7] If you'd like to create more with keeping default. Listeners, Answer "Yes". This example selects "No".
[8]配置完成.
[9] 在建立監聽器,tnslsnr偵聽端口配置以下。
[oracle@server~]$ ss -napt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
ESTAB 0 52 10.0.0.30:22 10.0.0.5:50113
LISTEN 0 128 :::1521 :::* users:(("tnslsnr",3988,9))
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631 :::*
LISTEN 0 100 ::1:25 :::*
[oracle@server ~]$ tnsping localhost
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUL-2015 01:03:07
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)
(PORT=1521)))
OK (0 msec)
[2] Select "Create Database" and go next.
[3] On this example, select "Advanced Mode" and go next.
[4] This example selects "General
[5] Set Grobal Database name and SID Purpose ***" and go next. like follows. Input any one you like.
[6] This example goes next with keeping
[7] Set passwords. Please set a default.password for a user for security.
[8]配置監聽.
[9]配置內存設置.
[10] 配置簡單的示例和腳本
[11]配置 memory
[12] 指定最大進程
[13] 字符設置
[14] 選擇鏈接模式。若是您的服務器沒有多客戶端,請選擇「專用服務器模式」。若是您的服務器有許多客戶端,請選擇「共享服務器」
[15]繼續
[16]配置完成,選擇「finish」
[17] 數據庫開始建立.
[18] 點擊關閉。
[19] 添加SID到數據庫
[oracle@dserver~]$ vi /etc/oratab
#更改以下
dlp:/u01/app/oracle/product/12.1.0/dbhome_1:Y
[oracle@server ~]$ vi ~/.bash_profile
# 結尾添加
export ORACLE_SID=dlp
[1]建立完成數據庫以後,數據庫服務是運行狀態也有可能訪問企業管理器。訪問數據庫建立完成時所顯示的網址,而後顯示登陸表單,並有可能與數據庫用戶登陸。
[2]登陸成功後,就能夠開始管理了
[1] Login as root user and create Systemd files.
[root@server ~]# vi /etc/sysconfig/dlp.oracledb
# 建立新的:定義環境變量
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORACLE_SID=dlp
#配置監聽服務
[root@server ~]# vi /usr/lib/systemd/system/dlp@lsnrctl.service
# this is an example, modify for free
[Unit]
Description=oracle net listener
After=network.target
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/dlp.oracledb
ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start
ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl stop
User=oracle
[Install]
WantedBy=multi-user.target
# configure database service
[root@server ~]# vi /usr/lib/systemd/system/dlp@oracledb.service
# this is an example, modify for free
[Unit]
Description=oracle net listener
After=network.target lsnrctl.service
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/dlp.oracledb
ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0/dbhome_1
ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0/dbhome_1
User=oracle
[Install]
WantedBy=multi-user.target
[root@server ~]# systemctl daemon-reload
[root@server ~]# systemctl enable dlp@lsnrctl dlp@oracledb