Building oracle11G DG in linux (1): Environment preparation
Environment
Name |
Master Database |
Slave Database |
Host Name |
Bjsrv |
Shsrv |
Software Version |
RedHat performanise5.5, Oracle 11g 11.2.0.1 |
RedHat performanise5.5, Oracle 11g 11.2.0.1 |
I. Environment preparation: 1. vbox
Import Virtual Machine images (oracle and database creation installed)
1. Import virtual machines (master database-Beijing, bj for short) 2. Import virtual machines (slave database-Shanghai, sh for short)
3. Add a disk to the master database and slave database respectively.
Add one disk for the master database and the slave database respectively. The size is 30 GB.
(1) Add a disk to bj.
(2) bj Nic settings
Set host only or bridging as needed, for example:
(3) add disks and nic settings in sh
The procedure is the same as above (omitted ).
2. HOST 1, root Password (1), modify bj's root Password
(2) modify the sh root Password
.
2. Host Name (1). Modify the host name under bj.
Vi/etc/sysconfig/network // modify the Host Name
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = bjsrv
# Hostname bjsrv // enable the host name to take effect or restart the system
(2) modify the host name under sh
Vi/etc/sysconfig/network // modify the Host Name
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = shsrv
# Hostname shsrv // make the host name take effect or restart the system
3.. bash_profile
This is the display format setting. Do not modify it.
(1) Modify bj's. bash_profile
# Vi. bash_profile
#. Bash_profile
# Get the aliases and functions
If [-f ~ /. Bashrc]; then
.~ /. Bashrc
Fi
# User specific environment and startup programs
PATH = $ PATH: $ HOME/bin
Export PATH
Unset USERNAME
# PS1 = 'whoam' @ 'hostname' ': $ {PWD}>'
PS1 = '[\ u @ \ h \ w] \ $'
Export PS1
[Root @ bjsrv ~] # Source. bash_profile
(2) Modify sh's. bash_profile
# Vi. bash_profile
#. Bash_profile
# Get the aliases and functions
If [-f ~ /. Bashrc]; then
.~ /. Bashrc
Fi
# User specific environment and startup programs
PATH = $ PATH: $ HOME/bin
Export PATH
Unset USERNAME
# PS1 = 'whoam' @ 'hostname' ': $ {PWD}>'
PS1 = '[\ u @ \ h \ w] \ $'
Export PS1
[Root @ shsrv ~] # Source. bash_profile
4. network configuration (1). Modify bj Network Configuration
# Vi/etc/hosts
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 // modify IP Address
DEVICE = eth0
BOOTPROTO = static
IPADDR = 192.168.4.71
NETMASK = 255.255.255.0
ONBOOT = yes
# Service networkrestart
(2) modify the sh Network Configuration
# Vi/etc/hosts
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 // modify IP Address
DEVICE = eth0
BOOTPROTO = static
IPADDR = 192.168.4.72
NETMASK = 255.255.255.0
ONBOOT = yes
# Service networkrestart
3. Install the database
Since oracle has been installed in the imported virtual machine, it is not installed here. For installation instructions, see the "oracle Installation" document. This step is omitted.
[Root @ bjsrv ~] #Cat/etc/oratab// The verification database already exists.
Note: To install the oracle software and database in the master database, you only need to install the oracle software in the slave database.
4. Disk
Introduction:
Use logical volumes as physical volumes.
Create a 30 GB hard disk in bj and sh respectively, and create a logical volume. The logical volume of aix must be a whole disk, and a partition of the disk in linux, A logical volume group is to combine several physical volumes, and a logical volume is to separate partitions of various sizes from the logical group. (Modification required)
Objective: To Virtualize four disks
1. Add a disk to bj. 1. Partition> logical volume
It is a disk partition, which is divided into one primary partition. Then convert it to a logical volume.
[Root @ bjsrv ~] # Fdisk-l // view disk status
[Root @ bjsrv ~] # Fdisk/dev/sdb
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 extrafunctionality (experts only)
Command (m forhelp): n
Command action
E extended
P primary partition (1-4) p
Partition number (1-4): 1
First cylinder (1-3916, default 1 ):
Using default value1
Last cylinder or + size or + sizeM or + sizeK (1-3916, default 3916 ):
Using default value3916
Command (m forhelp): p
Disk/dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sdb1 1 3916 31455238 + 83 Linux
Command (m forhelp): t // (change a partition 'ssystem id) to the logical volume format
Selected partition 1
Hex code (type L tolist codes): L
8e Linux LVM
Hex code (type L tolist codes): 8e logical volume creation format
Changed system typeof partition 1 to 8e (Linux LVM)
Command (m forhelp): p
Disk/dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sdb1 1 3916 31455238 + 8e Linux LVM
// Check whether the logical volume format is successfully converted. The next step is to create the logical volume.
Command (m for help): w // save and exit
2. Create a physical volume
Create a physical volume (pv ):
[Root @ bjsrv ~] # Pvcreate/dev/sdb1 // use the partition as a physical volume
[Root @ bjsrv ~] # Pvdisplay // display physical volume information
3. Create a volume group
Add a physical volume to a volume group (vg ):
[Root @ bjsrv ~] # Vgcreate datavg/dev/sdb1 // create a volume group
// Format: vgcreate datavg/dev/sdb1
// Description: Create a logical volume group name physical volume.
[Root @ bjsrv ~] # Vgdisplay // view the volume group information
4. Create a logical volume
Create a logical volume under a volume group:
Lvcreate [-n name] [-L size]
Reference legend:
Operation:
# Lvcreate-n lv_dsk1-L 7g datavg
# Lvcreate-n lv_dsk2-L 7g datavg
# Lvcreate-n lv_dsk3-L 7g datavg
# Lvcreate-n lv_dsk4-L 8g datavg
// Leave some space for the volume group Header
# Lvdisplay // view logical volume information
5. format the logical volume
Format the logical volume:
Reference legend:
The procedure is as follows:
# Mkfs. ext3/dev/datavg/lv_dsk1
# Mkfs. ext3/dev/datavg/lv_dsk2
# Mkfs. ext3/dev/datavg/lv_dsk3
# Mkfs. ext3/dev/datavg/lv_dsk4
6. Create a virtual disk directory
Create a directory for the four virtualized disks:
# Mkdir/dsk1
# Mkdir/dsk2
# Mkdir/dsk3
# Mkdir/dsk4
7. automatic mounting
Set automatic mounting. The directory created in the last step will be set to automatic mounting upon startup.
# Vi/etc/fstab automatic mounting
Reference legend:
Add operation:
/Dev/datavg/lv_dsk1/dsk1 ext3 defaults 0 0
/Dev/datavg/lv_dsk2/dsk2 ext3 defaults 0 0
/Dev/datavg/lv_dsk3/dsk3 ext3 defaults 0 0
/Dev/datavg/lv_dsk4/dsk4 ext3 defaults 0 0
Mount four disks:
# Mount/dsk1
# Mount/dsk2
# Mount/dsk3
# Mount/dsk4
# Df-h // view disk Information
8. Authorization
Change the owner of the new directory to oracle and set the group to dba:
# Chown-R oracle: dba/dsk1
# Chown-R oracle: dba/dsk2
# Chown-R oracle: dba/dsk3
# Chown-R oracle: dba/dsk4
2. Add a disk to sh
For operation steps, refer to "operate on bj disk ".
STEP (omitted ).
5. Modify the database
Note: the transformation of the database has nothing to do with DG. It is used to set up a simulated environment.
1. Modify the display mode bj
$Vi $ ORACLE_HOME/sqlplus/admin/glogin. SQL
Modify
Setsqlprompt '_ user @ _ connect_identifier>'
Settermout on;
Set timeon
Set timingon
Refer:
Sh Modification
See bj to modify.
2. Modify the file location
Purpose: To simulate that the redo log and datafile are not on the same disk.
SQL>Startup; // start the database
[Supplement]: MEMORY_TARGETnot supported on this system is reported.
Error 00845 is reported when the database is started
View alarm logs:
$ Tail-f/u01/app/oracle/diag/rdbms/testdb12/TestDB12/alert/log. xml
$ Df-h
When the memory exceeds, You need to modify the parameter values in the initialization parameter file:
SQL>Create pfile fromspfile;
$Vi $ ORACLE_HOME/dbs/initTestDB12.ora;
Modify the memory value, as shown in:
SQL>Create spfile from pfile;
SQL>Startup;
Supplement ended
SQL>Select name from v $ controlfile; // view the Control File Location
SQL>Select member from v $ logfile; // view the log location
SQL>Select name from v $ datafile; // view the location of the data file
SQL>Archive log list // view the archive mode. The DG must be in the archive mode.
The above query is available:
The control files, log files, and data files are in the same directory and are not archived. The following describes how to transform the database based on the query results to simulate a complex environment.
Directory required to create a file location:
Planning:
Redo logs are stored under dsk1 and dsk2.
Archive logs under dsk4
1. create directory bj create directory
$ Mkdir-p/dsk1/oradata/bj
$ Mkdir-p/dsk2/oradata/bj
$ Mkdir-p/dsk3/oradata/bj
$ Mkdir-p/dsk4/oradata/bj
$ Mkdir-p/dsk4/arch_bj
Sh create directory
$ Mkdir-p/dsk1/oradata/sh
$ Mkdir-p/dsk2/oradata/sh
$ Mkdir-p/dsk3/oradata/sh
$ Mkdir-p/dsk4/oradata/sh
$ Mkdir-p/dsk4/arch_sh
Supplement:
View alarm logs
2. Modify the redo log location (bj)
SQL>Selectmember from v $ logfile;
SQL>Selectgroup #, status, bytes from v $ log;
SQL>Alterdatabase add logfile member
'/Dsk2/oradata/bj/redo01b. log' to group 1,
'/Dsk2/oradata/bj/redo02b. log' to group 2,
'/Dsk2/oradata/bj/redo03b. log' to group 3;
SQL>Selectmember from v $ logfile;
Migrate redo logs: (the logs must be mounted)
SQL>Shutdownimmediate;
$Cp/u01/app/oracle/oradata/TestDB12/redo03.log/dsk1/oradata/bj/redo03a. log;
$Cp/u01/app/oracle/oradata/TestDB12/redo02.log/dsk1/oradata/bj/redo02a. log;
$Cp/u01/app/oracle/oradata/TestDB12/redo01.log/dsk1/oradata/bj/redo01a. log;
$Ls/dsk1/oradata/bj
SQL>Startupmount;
SQL>Alterdatabase rename file
'/U01/app/oracle/oradata/TestDB12/redo03.log' to'/dsk1/oradata/bj/redo03a. log ';
SQL>Alterdatabase rename file
'/U01/app/oracle/oradata/TestDB12/redo02.log' to'/dsk1/oradata/bj/redo02a. log ';
SQL>Alterdatabase rename file
'/U01/app/oracle/oradata/TestDB12/redo01.log' to'/dsk1/oradata/bj/redo01a. log ';
SQL>Selectmember from v $ logfile;
Delete the old redo log file:
$Rm/u01/app/oracle/oradata/TestDB12/redo *;
$Ls/u01/app/oracle/oradata/TestDB12/
At this point, the directory separation between log files and data files is realized (that is, the simulation of files not on the same disk ).
3. Set archiving (bj)
SQL>Alterdatabase archivelog;
SQL>Showparameter archive
SQL>Altersystem set log_archive_dest_1 = 'location =/dsk4/arch_bj ';
SQL>Altersystem set log_archive_format = 'arch _ % t _ % s _ % r. log' scope = spfile;
SQL>Startupforce;
SQL>Archivelog list;
4. All operations generate redo settings (bj)
Force "all operations" to generate redo logs:
SQL>Alterdatabase force logging;
SQL>Selectname from v $ archived_log;// View the archived log information.
****************** ********
Statement:
Original works, from "Deep Blue blog" blog, allow reprint, reprint please be sure to indicate the source (http://blog.csdn.net/huangyanlong ).
The author has the right to pursue legal liability for copyright issues.