Oracle-ASM單例項資料庫安裝

Advertisement

oracle enterprise linux 6.4 oracle 11.2.0.4 單例項 ASM
部署手冊
一、 主機準備
ip:192.168.100.100
主機名: oracle 11g
目錄: /u01
磁碟: 35G
本地磁碟一個, 另外再分塊 16G
磁碟
1.1 檢查主機名和
IP 地址的對映:
hostname -i
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=ora11g
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.100 ora11g
1.2 規劃磁碟分割槽
/dev/sda 35G 格式化後掛載到/
安裝作業系統和 ORACLE
軟體
/dev/sdb 16G, 分成
6 個區, 不需格式化, 給
ASM 使用
[root@ora11g ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xe5fb8fdf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): p
Disk /dev/sdb: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe5fb8fdf
Device Boot Start End Blocks Id System
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e P
artition number (1-4): 1
First cylinder (1-2088, default 1):
Using default value 1
Last cylinder, cylinders or size{K,M,G} (1-2088, default 2088):
Using default value 2088
Command (m for help): p
Disk /dev/sdb: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe5fb8fdf

Device BootStartEndBlocksIdSystem
/dev/sdb112088167718285Extended
Command (m for help):
Command (m for help): n
Command action
l logical (5 or over)
pprimary partition (1-4)

l F
irst cylinder (1-2088, default 1):
Using default value 1
Last cylinder, cylinders or size{K,M,G} (1-2088, default 2088): 3G
Command (m for help): p
Disk /dev/sdb: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe5fb8fdf

Device BootStartEndBlocksIdSystem
/dev/sdb112088167718285Extended
/dev/sdb51393315670983Linux
/dev/sdb6394786315674183Linux
/dev/sdb77871179315674183Linux
/dev/sdb811801572315674183Linux
/dev/sdb915731834210448383Linux
/dev/sdb1018352088204022383Linux

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ora11g ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe5fb8fdf

Device BootStartEndBlocksIdSystem
/dev/sdb112088167718285Extended
/dev/sdb51393315670983Linux
/dev/sdb6394786315674183Linux
/dev/sdb77871179315674183Linux
/dev/sdb811801572315674183Linux
/dev/sdb915731834210448383Linux
/dev/sdb1018352088204022383Linux
[root@ora11g ~]# reboot

二. 配置本地 YUM
1.掛載光碟機
mkdir -p /media/cdrom /src
mount -o loop -t iso9660 /dev/sr0 /media/cdrom
2.安裝 createrepo
cd /media/cdrom/Server/Packages
rpm -ivh libxml2-python-2.7.6-8.0.1.el6_3.4.x86_64.rpm
rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
3.利用 createrepo
建立 yum
倉庫, 建立索引資訊
createrepo -v ./
4. 配置檔案, 將/etc/yum.repos.d/下現存檔案都刪除或重新命名.bak,然後新建一個
local.repo
檔案, 並新增相應內容:
[local]
name=oracle-local
baseurl=file:///media/cdrom/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
5. 安裝成功後, 測試
# yum clean all #清除快取
# yum makecache #重新建立快取
6. 檢查安裝環境
rpm -q –queryformat “%{NAME}-%{VERSION}-%{ARCH}\n” \
s 7
.安裝缺少的包
yum install binutils compat-libstdc -33 elfutils-libelf elfutils-libelf-devel glibc glibc-common
glibc-devel gcc gcc-c libaio-devel libaio libgcc libstdc libstdc -devel make sysstat
unixODBC unixODBC-devel ksh compat-libcap1
三. 安裝 VNC
1. 安裝 VNC
yum install tigervnc-server -y
2. 配置使用者
vim /etc/sysconfig/vncservers
VNCSERVERS=”1:root”
VNCSERVERARGS[1]=”-geometry 1365×768 -nolisten tcp”
3.建立密碼
#vncserver
You will require a password to access your desktops.
Password:oracle
Verify: oracle
xauth: file /root/.Xauthority does not exist
New ‘ora11g:1 (root)’ desktop is ora11g:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/ora11g:1.log
4.啟動
vncserver
service vncserver restart
5.客戶端連線 VNC
LINUX: 使用 TigerVNC Viewer
連線 ip:1
Windows: 使用 Real VNC Viewer
連線
6.關閉防火牆
service iptables stop
chkconfig iptables off
四.
配置 oracle
安裝環境
1.建立ORACLE使用者和組使用者
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmdba
groupadd asmoper
usermod -g oinstall -G dba,asmdba,oper oracle
useradd -g oinstall -G dba,asmadmin,asmdba,asmoper grid
passwd oracle (oracle123)
passwd grid (grid123)
2.建立以下目錄並授權
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
3. 設定 oracle、
grid 使用者的環境變數
3.1 oracle 使用者登陸:
vi ~/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=american_america.ZHS16GBK
export ORACLE_SID=oradb
export PATH=$PATH:$ORACLE_HOME/bin:.
3.2 grid 使用者登入: vi ~/.bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=American_america.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin:.
export ORACLE_SID= ASM
4. root 使用者更改系統引數(之前有配, 可省略)
4.1 vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152 // 可以不設
kernel.shmmax = 4398046511104 //一般設定為系統記憶體
75%單位是位元組, 可以不設
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 = 1048586
/sbin/sysctl -p
4.2 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
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
4.3 vi /etc/pam.d/login
#oracle
session required /lib64/security/pam_limits.so
session required pam_limits.so
5.上傳 Oracle
安裝介質到/u01/tmp
目錄下並解壓
mkdir -p /u01/tmp
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
p13390677_112040_Linux-x86-64_3of7.zip
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
unzip p13390677_112040_Linux-x86-64_3of7.zip
#chown -R grid:oinstall /u01/tmp/grid
五.安裝
grid 元件
1.Xmanager 軟體用
grid 使用者登入並安裝
xhost
su – grid
$cd /u01/tmp/grid
$./runInstaller
skip software updates–Install Oracle Grid Infrastructure Software only –english—privileged
operating system groups(asmadmin,asmdba,asmoper)–
oracle base:/u01/app/grid software location:/u01/app/11.2.0/grid—Inventory
Directory:/u01/app/oraInventory
安裝時可能會缺包, 根據提示安裝,另外還會報
resolv.conf 錯誤
yum -y install compat-libcap1
yum -y install ksh
NTP 報警處理
service ntpd stop
mv /etc/ntp.conf /etc/ntp.conf.bak
resolv.conf 報警, 主要是DNS配置問題, 不影響安裝. 暫時跳過
圖形介面安裝, 最後 root 使用者執行兩個指令碼, 執行指令碼的螢幕輸出如下:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/11.2.0/grid/root.sh
安裝日誌目錄
/u01/app/oraInventory/logs/installActions2017-01-22_02-53-39PM.log
根據上步執行的指令碼輸出提示, 確定單節點需要
root 使用者執行下面的命令

/u01/app/11.2.0/grid/perl/bin/perl-I/u01/app/11.2.0/grid/perl/lib
-I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl
/u01/app/11.2.0/grid/perl/bin/perl-I/u01/app/11.2.0/grid/perl/lib
-I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl

2.下載並安裝ASMLIB
2.1 oracle 官居網下載下面兩個包
oracleasmlib-2.0.4-1.el6.x86_64.rpm oracleasm-support-2.1.8-1.el6.x86_64.rpm
cd /etc/yum.repos.d/
2.2 下載 redhat6.8
核心 oracleasm

wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O
/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
如果使用的是 Oracle Linux
的 uek
核心, oracleasm
已經被編譯到了核心中, 如果使用的是和
Red Hat 相容的核心, 那麼需要手動安裝
kmod-oracleasm 包
yum install kmod-oracleasm(oracle linux
不用裝)
rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm oracleasm-support-2.1.8-1.el6.x86_64.rpm
2.3 配置 asmlib
驅動
[root@11gocp yum.repos.d]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets (‘[]’). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@11gocp yum.repos.d]#
2.4 啟動ASM
[root@11gocp yum.repos.d]# /etc/init.d/oracleasm start
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@11gocp yum.repos.d]#
2.5 建立ASM磁碟
/etc/init.d/oracleasm createdisk VOL1 /dev/sdb5
/etc/init.d/oracleasm createdisk VOL2 /dev/sdb6
/etc/init.d/oracleasm createdisk VOL3 /dev/sdb7
/etc/init.d/oracleasm createdisk VOL4 /dev/sdb8
/etc/init.d/oracleasm createdisk VOL5 /dev/sdb9
/etc/init.d/oracleasm createdisk VOL6 /dev/sdb10
[root@11gocp asm]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
VOL6
2.6 使用ASMCA建立ASM磁碟組
xhost
su – grid
asmca
asm administor sys:asm123 asmsnmp:asm123
DATA—>VOL1,VOL2,VOL3,VOL4 採用外部冗餘
RECDATA—->VOL5,VOL6
採用外部冗餘
六. 安裝ORACLE
1.解壓併發裝
oracle 軟體
#cd /u01/tmp/

#unzipp13390677_112040_Linux-x86-64_1of7.zip;unzip
p13390677_112040_Linux-x86-64_2of7.zip
#chown -R oracle:oinstall database
vnc 軟體用
oracle 使用者登入
xhost
su – oracle
$cd /u01/tmp/database/

$./runInstaller (此部選擇此安裝軟體)
Skip software updates—Install database software only–Single instance database
installation–select languages:english
–Enterprise Edition(4.7GB)–Oracle base:/u01/app/oracle Software
Locatoin:/u01/app/oracle/product/11.2.0/db_1—
database Administrator(OSDBA):dba Database Operator(OSOPER) Group (Optional):oper
圖形介面安裝, 最後 root
使用者執行一個指令碼
#/u01/app/oracle/product/11.2.0/db_1/root.sh
安裝日誌
/u01/app/oraInventory/logs/installActions2017-01-23_10-59-23AM.log
2.建立資料庫
vnc 軟體用
oracle 使用者登入
$dbca
sys 密碼: oracle123
圖形介面建庫, Storage Type
選擇 ASM, 資料放在 DATA
磁碟組, 歸檔放在 RDCDATA,資料庫
字符集根據實際情況選擇,先不要安裝EM, 如果安裝EM會出現
ORA-12154
3. 使用 grid
使用者建立監聽
Xmanager 軟體用
grid 使用者登入
$netca
lsnrctl start
13. 客戶端測試資料庫連線
ping IP 地址
tnsping IP 地址
sqlplus system/oracle@IP
地址/jyzhao
su – grid
sqlplus sys/asm123 as sysasm
sqlplus /nolog
SQL>conn / as sysasm
SQL> col name format a10;
SQL> col fgno format a20;
SQL> set line 200;
SQL> select group_number gno,name,state,type,total_mb,free_mb,required_mirror_free_mb
rmfmb,usable_file_mb ufmb from v$asm_diskgroup;
GNO NAME STATE TYPE TOTAL_MB
FREE_MB RMFMB UFMB
———- ———- ———————- ———— ———- ———- ———- ———-

1 DATAMOUNTEDEXTERN
28787028787
2 RECDATAMOUNTEDEXTERN
20242020242

30708
20472
–建立磁碟組
SQL> create diskgroup dg3 normal redundancy disk ‘ORCL:VOL9′,’ORCL:VOL10’;
1 2 3 4 5 6 D
iskgroup created.
或:
SQL> create diskgroup dg3 normal redundancy disk ‘ORCL:VOL9’ disk ‘ORCL:VOL10’;
Diskgroup created.
–新增磁碟
1 2 3 4 S
QL> alter diskgroup dg1 add disk ‘ORCL:VOL9’;
Diskgroup altered.
–刪除磁碟
SQL> alter diskgroup dg1 drop disk VOL9;
Diskgroup altered.
alter diskgroup dg1 undrop disks;
–調整大小
ALTER DISKGROUP DG1 RESIZE DISK VOL4 SIZE 1024 M
–unmount 和 mount
磁碟組
SQL> alter diskgroup dg3 dismount;
Diskgroup altered.
SQL> select group_number gno,name,state,type,total_mb,free_mb,required_mirror_free_mb
rmfmb,usable_file_mb ufmb from v$asm_diskgroup;
GNO NAME STATE TYPE
TOTAL_MB FREE_MB RMFMB UFMB
———- —————————— ———————- —————————— ———- ———- ———-
———-
1 DG1 MOUNTED NORMAL
4076 575 879 -152
2 DG2 MOUNTED NORMAL
4076 3531 139 1696
0 DG3 DISMOUNTED
SQL> alter diskgroup dg3 mount;
Diskgroup altered.
7.安裝EM
[oracle@ora11g ~]$ sqlplus / as sysdba
SQL> alter user dbsnmp identified by oracle123 account unlock;
User altered.
SQL> alter user sysman identified by oracle123 account unlock;
User altered.
SQL>
備註: oracle
資料庫 sys/system/dbsnmp/sysman
密碼: oracle123
ASM例項使用者名稱和密碼
sys/asm123
asmsnmp/asm123
[oracle@11gocp ~]$ emca -config dbcontrol db -repos recreate
STARTED EMCA at Jan 23, 2017 1:25:25 PM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle. All rights reserved.
Enter the following information:
Database SID: oradb
Listener port number: 1521
Listener ORACLE_HOME [ /u01/app/oracle/product/11.2.0/db_1 ]:
Password for SYS user: oracle123
Password for DBSNMP user: oracle123
Password for SYSMAN user: oracle123
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
ASM ORACLE_HOME [ /u01/app/11.2.0/grid]:
ASM SID [ ASM ]:
ASM port [ 1521 ]:
ASM username [ ASMSNMP ]:
ASM user password: asm123
—————————————————————–
———————————————————————-
WARNING : While repository is dropped the database will be put in quiesce mode.
———————————————————————-
Do you wish to continue? [yes(Y)/no(N)]: y
Aug 21, 2017 12:20:32 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at
/u01/app/oracle/cfgtoollogs/emca/oradb/emca_2017_08_21_00_20_01.log.
Aug 21, 2017 12:20:33 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) …
Aug 21, 2017 12:24:23 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Aug 21, 2017 12:24:24 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) …
Aug 21, 2017 12:32:28 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Aug 21, 2017 12:32:32 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) …
Aug 21, 2017 12:33:46 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Aug 21, 2017 12:33:47 AM oracle.sysman.emcp.ParamsManager getLocalListener
WARNING: Error retrieving listener for ora11g
Aug 21, 2017 12:33:49 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) …
Aug 21, 2017 12:34:21 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Aug 21, 2017 12:34:21 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) …
Aug 21, 2017 12:36:03 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Aug 21, 2017 12:36:03 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://ora11g:1158/em <<<<<<<<<<<
Aug 21, 2017 12:36:10 AM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************ WARNING ************************
Management Repository has been placed in secure mode wherein Enterprise Manager data will
be encrypted. The encryption key has been placed in the file:
/u01/app/oracle/product/11.2.0/db_1/ora11g_oradb/sysman/config/emkey.ora. Ensure this file
is backed up as the encrypted data will become unusable if this file is lost.
***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Aug 21, 2017 12:36:10 AM
EM 安裝日誌檔案:
tailf /u01/app/oracle/cfgtoollogs/emca/oradb/emca_2017_08_21_00_20_01.log