oracle安装与手工建库

2017-01-01 12:34:18来源:CSDN作者:liguangyuan66人点击

第七城市







安装前的准备

有关安装的事前准备和各方面的要求可以参照以下guide

http://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#LADBI1096


(1)检查系统配置
①下载oralce软件,然后把它传到虚拟机
http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/index.html

例如我上传到这里

/home/liguangyuan2/Downloads
total 2295592
-rwxrwxrwx. 1 root root 1239269270 Dec 14 14:11 linux.x64_11gR2_database_1of2.zip
-rwxrwxrwx. 1 root root 1111416131 Dec 14 14:05 linux.x64_11gR2_database_2of2.zip
[root@localhost oracle]# 

②查看内存情况,不少于1g

[root@localhost oracle]# grep MemTotal /proc/meminfo                                                                                                                                                 
MemTotal:        2048580 kB                                                                                                                                                                         
[root@localhost oracle]# 

③查看swap情况
[root@localhost oracle]# grep SwapTotal /proc/meminfo
SwapTotal:       1952764 kB


④查看磁盘空间,不少于5g
[root@localhost oracle]# df -h                                                                                                                                                                       
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        28G   16G   11G  62% /
devtmpfs        987M     0  987M   0% /dev
tmpfs          1001M  479M  523M  48% /dev/shm
tmpfs          1001M  8.9M  992M   1% /run
tmpfs          1001M     0 1001M   0% /sys/fs/cgroup
tmpfs          1001M  144K 1001M   1% /tmp
tmpfs           201M  4.0K  201M   1% /run/user/42
tmpfs           201M   12K  201M   1% /run/user/1002
[root@localhost oracle]# 


⑤/tmp的空间要大于400M
[root@localhost oracle]# df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs          1001M  144K 1001M   1% /tmp

另外还要支持256色以上显卡,cpu主频不小于550mHZ





(2)检查软件安装包情况(root用户)

①检查内核版本
[root@localhost oracle]# uname -r
3.10.0-514.el7.x86_64

②检查软件包的安装情况

[root@localhost oracle]# rpm -qa                                                                                                                                                                     

rpm -q binutils compat-libstdc++-33 compat-libcap1-1.10 gcc gcc-c++ glibc-2.17 glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat


如果包有显示is not installed(没安装),就用yum install 命令安装,如:
yum install compat-libstdc++-33
yum install compat-libcap1-1.10
yum install gcc
yum install  gcc-c++
yum install libaio-devel
yum install libstdc++-devel


关于需要哪些包,可以参考以下官方网站

(3)环境配置(root用户)

①创建用户组oinstall,命令如下:

groupadd oinstall
grep oinstall /etc/group

②创建用户组dba,命令如下:
groupadd dba
grep dba /etc/group


③设定安全策略,首先允许修改这类配置文件。命令如下:
chattr -i /etc/passwd /etc/shadow

④把用户oracle加入到oinstall和dba组,命令如下:
useradd -g oinstall -G dba oracle

⑤开始修改密码,命令如下
passwd oracle

⑥创建用户完成,把文件权限设回来,避免信息被篡改,命令如下:
chattr +i /etc/passwd /etc/shadow


(4)配置Linux内核参数(root用户)
①修改/etc/sysctl.conf文件,增加以下内容:

kernel.shmmax = 4294967295
kernel.shmall = 4194304
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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                                                                                                                                                                        
~                              

②修改之后,sysctl -p 设置生效



(5)配置资源使用情况(root用户)
①修改/etc/security/limits.conf文件,增加以下内容

vi /etc/security/limits.conf

oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
*              soft    memlock  unlimited
*              hard    memlock  unlimited


②创建相应的目录结构,命令如下:

mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1/dbsmkdir -p /u01/app/oracle/admin/orcl/adumpmkdir -p /u01/app/oracle/admin/orcl/dpdumpmkdir -p /u01/app/oracle/admin/orcl/pfilemkdir -p /u01/app/oracle/auditmkdir -p /u01/app/oracle/fast_recovery_area/orclmkdir -p /u01/app/oracle/oradata/orclmkdir -p /u01/app/oracle/flash_recovery_areamkdir -p /u01/app/oraInventorychown -R oracle:oinstall /u01chmod -R 775 /u01
ls -ld /u01/app/oracle/product/11.2.0/dbhome_1/dbsls -ld /u01/app/oracle/admin/orcl/adumpls -ld /u01/app/oracle/admin/orcl/dpdumpls -ld /u01/app/oracle/admin/orcl/pfilels -ld /u01/app/oracle/auditls -ld /u01/app/oracle/fast_recovery_area/orclls -ld /u01/app/oracle/oradata/orclls -ld /u01/app/oraInventory


③修改/etc/pam.d/login文件,增加以下内容:

session    required       pam_limits.so


④配置环境变量(oracle用户)

假设数据库的实例名为ORCL,则修改.bash_profile,增加如下内容

umask 022
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"


(6)解压oracle安装文件(root用户)
cd /home/guangyuan/oracle
mkdir /u01
chown oracle:oinstall /u01

unzip linux*_11gR2_database_1of2.zip -d /u01 (解压到/u01目录下,可选目录)
unzip linux*_11gR2_database_2of2.zip -d /u01


(7)用oracle用户登陆虚拟机,cd到/u01/database下面,输入./runInstaller ,会出现以下的图
















手工建库

(1)确认.bash_profile文件有如下内容

umask 022
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"



(2)准备密码文件及初始化参数文件和创建数据库脚本(oracle用户)



②准备创参数文件
cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs
cat init.ora | grep -v ^$ | grep -v ^# > initORCL.ora


vi initORCL.ora


db_name='ORCL'
memory_target=300m
processes = 150
audit_file_dest='/home/oracle/app/admin/ORCL/adump'
audit_trail ='db'
db_block_size=8192
db_domain='us.oracle.com'
db_recovery_file_dest='/home/oracle/app/fast_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/home/oracle/app'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = ('/home/oracle/app/oradata/ORCL/ora_control1.ctl', '/home/oracle/app/oradata/ORCL/ora_control2.ctl')
compatible ='11.2.0'
③准备相关目录




④开始手工建库
sqlplus / as sysdbaexport ORACLE_SID=ORCLstartup nomoutCreate spfile from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora'show paramater pfileshow paramater spfilels -l /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileORCL.ora
set echo on
set timing on
@/u01/app/oracle/product/11.2.0/dbhome_1/dbs/cdb.sql
或者
start /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/cdb.sql


create database ORCl maxlogfiles 5 maxlogmembers 5 maxdatafiles 100 maxinstances 1 logfile group 1 ('/u01/app/oracle/oradata/orcl/redo1.log') size 10m, group 2 ('/u01/app/oracle/oradata/orcl/redo2.log') size 10m, group 3 ('/u01/app/oracle/oradata/orcl/redo3.log') size 10m datafile '/u01/app/oracle/oradata/orcl/system.dbf' size 200m reuse sysaux datafile '/u01/app/oracle/oradata/orcl/sysaux.dbf' size 100m default tablespace users datafile '/u01/app/oracle/oradata/orcl/userdata.dbf' size 100m undo tablespace undotbs1 datafile '/u01/app/oracle/oradata/orcl/undo1.dbf' size 100m default temporary tablespace temp1 tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' size 100m reuse character set al32utf8;

⑤建完数据库后,开始建数据字典

vi /u01/app/oracle/product/11.2.0/dbhome_1/dbs/proc.sql
 @$ORACLE_HOME/rdbms/admin/catalog.sql
 @$ORACLE_HOME/rdbms/admin/catproc.sql
 @$ORACLE_HOME/sqlplus/admin/pupbld.sql

@ /u01/app/oracle/product/11.2.0/dbhome_1/dbs/proc.sql

把memory_target和memory_max_target修改得大点alter system set memory_max_target=3g scope=spfile;alter system set memory_target=3g scope=spfile;show parameter memory_targetshow parameter memory_max_target
shutdownstartup 可能会报以下的错ORA-00845: MEMORY_TARGET not supported on this system因为/dev/shm有点小,一般只有系统的一半,可以用以下命令修改mount -t tmpfs shmfs -o size=3g /dev/shm
然后再startup就ok了


http://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#LADBI1085





第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台