読者です 読者をやめる 読者になる 読者になる

kenken0807_DBメモ

つば九郎が好きなDBAです。Oracle Standard Editionでの運用やツールとかとかの備忘録。特に記載がない場合はoracle11gR2です。時々MySQL

Centos7にORACLE database11.2.0.4 SEoneをさくっとサイレントインストールしてみる

GUIを使用せずに簡単にORACLE DATABASEを作成する。 SIDはorclで作成。

環境

今回はdockerを使用する。
dockerのデフォルトshmsizeが64MBで小さすぎてORACLEインスタンス起動できなかったので
--shm-sizeを指定できるversion1.10を使用。

# docker --version
Docker version 1.10.3, build 20f81dd

とりあえずcentos7立ち上げる

docker run --privileged -it --shm-size=512m   centos  bash

パッケージ取得

yum -y install wget vim sudo epel-release rlwrap vim sudo

さくっとインストールまで

  • ユーザグループ作成
    ORACLE preinstallRPMを使用するので作成する必要はないがuid、gid決める場合は先に作成。
# groupadd -g 501 oinstall 
# groupadd -g 502 dba
# useradd -u 501 -g oinstall -G dba oracle
# mkdir -p /opt/app/oracle
# chown -R oracle. /opt/app/oracle
# chown -R oracle. /opt/app
# mkdir -p /opt/app/oraInventory
# chown -R oracle. /opt/app/oraInventory
# chown -R oracle. /data/orabin
                     ↑ (ここにPSRを置く予定)
# wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
# cd /etc/yum.repos.d/
# wget http://public-yum.oracle.com/public-yum-ol7.repo
# yum -y install oracle-rdbms-server-11gR2-preinstall

preinstallRPMのログはここ /var/log/oracle-rdbms-server-11gR2-preinstall/results ↓のようなログ

Adding group oinstall with gid 54321
groupadd: group 'oinstall' already exists
Adding group dba
groupadd: group 'dba' already exists
User oracle is already present
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
Creating oracle user passed

Verifying  kernel parameters as per Oracle recommendations...
Adding fs.file-max = 6815744
Adding kernel.sem = 250 32000 100 128
Adding kernel.shmmni = 4096
Adding kernel.shmall = 1073741824
Adding kernel.shmmax = 4398046511104
Adding kernel.panic_on_oops = 1
Adding net.core.rmem_default = 262144
Adding net.core.rmem_max = 4194304
Adding net.core.wmem_default = 262144
Adding net.core.wmem_max = 1048576
Adding net.ipv4.conf.all.rp_filter = 2
Adding net.ipv4.conf.default.rp_filter = 2
Adding fs.aio-max-nr = 1048576
Adding net.ipv4.ip_local_port_range = 9000 65500
Setting kernel parameters as per oracle recommendations...
Altered file /etc/sysctl.conf
Original file backed up at /etc/sysctl.conf.orabackup
Verifying & setting of kernel parameters passed
・
・
・
Adding kernel.shmall = 1073741824  
Adding kernel.shmmax = 4398046511104  

は各自調整

  • PSRのダウンロード
    ORACLE SUPPORTからダウンロードする。
    ↓がすごい便利だった。MOSから直接ダウンロードできるスクリプト

github.com

  • getMOSPatch.sh取得
# cd /data/orabin
# wget --no-check-certificate -nv https://raw.github.com/MarisElsins/TOOLS/master/Shell/getMOSPatch.sh 
               && chmod 755 getMOSPatch.sh
  • 11.2.0.4のPSRをダウンロード
# ./getMOSPatch.sh  patch=13390677 ←パッチ番号を指定する(13390677は11.2.0.4.0 PATCH SET FOR ORACLE DATABASE SERVER)
Oracle Support Userid: xxxx@gmail.com  ←サポートのユーザID入力
Oracle Support Password:               ←サポートのパスワード入力

Getting the Platform/Language list
Available Platforms and Languages:
537P - Acme Packet 1100
529P - Acme Packet 3820
・
・
46P - Linux x86
226P - Linux x86-64
912P - Microsoft Windows (32-bit)
208P - Microsoft Windows Itanium (64-bit)
・
・
106L - Icelandic (IS)
46L - Indonesian (IN)
108L - Italian (I)
15L - Japanese (JA)
16L - Korean (KO)
43L - Vietnamese (VN)
999L - Worldwide Spanish (ESW)
Comma-delimited list of required platform and language codes: 226P,15L ←プラットフォームと言語を選択
Configuration saved

Getting list of files for patch 13390677 for "Linux x86-64"
1 - p13390677_112040_Linux-x86-64_1of7.zip
2 - p13390677_112040_Linux-x86-64_2of7.zip
3 - p13390677_112040_Linux-x86-64_3of7.zip
4 - p13390677_112040_Linux-x86-64_4of7.zip
5 - p13390677_112040_Linux-x86-64_5of7.zip
6 - p13390677_112040_Linux-x86-64_6of7.zip
7 - p13390677_112040_Linux-x86-64_7of7.zip
Comma-delimited list of files to download: 1,2  ←ダウンロードするものを選択
Files to download:
  p13390677_112040_Linux-x86-64_1of7.zip
  p13390677_112040_Linux-x86-64_2of7.zip

Downloading the patches:
Downloading file p13390677_112040_Linux-x86-64_1of7.zip ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1330M  100 1330M    0     0  5230k      0  0:04:20  0:04:20 --:--:-- 3534k
p13390677_112040_Linux-x86-64_1of7.zip completed with status: 0
Downloading file p13390677_112040_Linux-x86-64_2of7.zip ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1097M  100 1097M    0     0  2362k      0  0:07:55  0:07:55 --:--:-- 2500k
p13390677_112040_Linux-x86-64_2of7.zip completed with status: 0


# unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip
# ls
database  getMOSPatch.sh  p13390677_112040_Linux-x86-64_1of7.zip  p13390677_112040_Linux-x86-64_2of7.zip

ダウンロード完了。

  • サイレントインストール
    • レスポンスファイル作成
# su - oracle
$ cat << EOS  > ~/ora.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oraInventory
SELECTED_LANGUAGES=en,ja
ORACLE_HOME=/opt/app/oracle/product/11.2.0.4/dbhome_1
ORACLE_BASE=/opt/app/oracle
oracle.install.db.InstallEdition=SEONE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac: 1.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
EOS
$ /data/orabin/database/runInstaller -silent -responseFile ~/ora.rsp 
                                -ignoresysprereqs -ignoreprereq -force -waitforcompletion

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 94285 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2047 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-03-25_10-12-37AM. Please wait ...[WARNING] - My Oracle Support Username/Email Address Not Specified
You can find the log of this install session at:
 /opt/app/oraInventory/logs/installActions2016-03-25_10-12-37AM.log
The installation of Oracle Database 11g was successful.
Please check '/opt/app/oraInventory/logs/silentInstall2016-03-25_10-12-37AM.log' for more details.

As a root user, execute the following script(s):
        1. /opt/app/oraInventory/orainstRoot.sh
        2. /opt/app/oracle/product/11.2.0.4/dbhome_1/root.sh


Successfully Setup Software.

dockerであると事前チェックエラーがいくつか発生してインストールできないので-ignoresysprereqs-ignoreprereqを追加してインストールしている。

# /opt/app/oraInventory/orainstRoot.sh
# /opt/app/oracle/product/11.2.0.4/dbhome_1/root.sh

これでインストールは完了。

データベースを作成する

  • bash_profile編集
# su - oracle
$ cat << EOS >> ~/.bash_profile
export ORACLE_BASE=/opt/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0.4/dbhome_1
export NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS'
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$ORACLE_HOME/lib
export PATH=\$PATH:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch
export NLS_LANG=Japanese_Japan.AL32UTF8
export LANG=ja_JP.UTF-8
EOS

$ source ~/.bash_profile
$ mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/adump
$ mkdir -p ${ORACLE_BASE}/flash_recovery_area
$ mkdir -p ${ORACLE_BASE}/oradata/${ORACLE_SID}/
  • 初期化ファイル作成
$ cat << EOS >> $ORACLE_HOME/dbs/init${ORACLE_SID}.ora
db_name='${ORACLE_SID}'
memory_target=512M
processes = 150
audit_file_dest='${ORACLE_BASE}/admin/${ORACLE_SID}/adump'
audit_trail ='none'
db_block_size=8192
db_domain=''
db_recovery_file_dest='${ORACLE_BASE}/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='${ORACLE_BASE}'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = '${ORACLE_BASE}/control01.ctl'
compatible ='11.2.0'
EOS
  • ORACLE起動し、データベース作成
$ echo "startup nomount" | sqlplus / as sysdba 
$ echo "create spfile from pfile;" | sqlplus / as sysdba 

$ echo  -e "CREATE DATABASE orcl
    USER SYS IDENTIFIED BY oracle
    USER SYSTEM IDENTIFIED BY oracle
    LOGFILE GROUP 1 ('/opt/app/oracle/oradata/orcl/redo01.log') SIZE 10M,
            GROUP 2 ('/opt/app/oracle/oradata/orcl/redo02.log') SIZE 10M,
            GROUP 3 ('/opt/app/oracle/oradata/orcl/redo03.log') SIZE 10M
    MAXLOGFILES 5
    MAXLOGMEMBERS 5
    MAXLOGHISTORY 1
    MAXDATAFILES 1024
    CHARACTER SET AL32UTF8
    NATIONAL CHARACTER SET AL16UTF16
    EXTENT MANAGEMENT LOCAL
    DATAFILE '/opt/app/oracle/oradata/orcl/system01.dbf' SIZE 325M REUSE
    SYSAUX DATAFILE '/opt/app/oracle/oradata/orcl/sysaux01.dbf' SIZE 325M REUSE
    DEFAULT TABLESPACE users
       DATAFILE '/opt/app/oracle/oradata/orcl/users01.dbf'
       SIZE 50M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
    DEFAULT TEMPORARY TABLESPACE temp1
       TEMPFILE '/opt/app/oracle/oradata/orcl/temp01.dbf'
       SIZE 20M REUSE
    UNDO TABLESPACE undotbs1
       DATAFILE '/opt/app/oracle/oradata/orcl/undotbs01.dbf'
       SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;" | sqlplus / as sysdba
$ echo -e "@?/rdbms/admin/catalog.sql;"  | sqlplus / as sysdba
$ echo -e " @?/rdbms/admin/catproc.sql; " | sqlplus / as sysdba
$ echo -e "@?/sqlplus/admin/pupbld.sql;"  | sqlplus / as sysdba
$ echo -e "@?/rdbms/admin/utlrp.sql"  | sqlplus / as sysdba
$ echo -e "@?/sqlplus/admin/pupbld.sql" | sqlplus system/oracle

これでデータベース作成完了。