2014-03-31
1.下载oracle databases
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
2.oracle 10g/11g官方文档
3.oracle开发和管理工具
plsql developer ---window系统
toad for oracle --www.toadworld.com
4.配置yum源
[root@oracle53 ~]# mkdir /share
[root@oracle53 ~]# mkdir /mnt/dvd
[root@oracle53 dvd]# mount /dev/cdrom /mnt/dvd/
[root@oracle53 dvd]# rpm -ivh Server/vsftpd-2.0.5-21.el5.x86_64.rpm
[root@oracle53 dvd]# vim /etc/vsftpd/vsftpd.conf
=============================
anonymous_enable=YES
anon_upload_enable=YES
anon_root=/share
=================================
[root@oracle53 dvd]# /etc/init.d/vsftpd restart
[root@oracle53 dvd]# cp -r Cluster* /share/
[root@oracle53 dvd]# cp -r Server* /share/
[root@oracle52 share]# yum repolist
[root@oracle52 share]# yum makecache
5.安装oracle
(1)查看系统版本
建议安装oracle 11g,memory >3GB,SWAP=2倍memory
[root@ora243 share]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 6.9G 2.4G 75% /
/dev/sda5 43G 180M 41G 1% /u01
/dev/sda1 190M 13M 168M 7% /boot
tmpfs 1.6G 0 1.6G 0% /dev/shm
[root@ora243 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
[root@ora243 ~]# uname -r
2.6.18-274.el5
[root@ora243 ~]# uname -a
Linux ora243 2.6.18-274.el5 #1 SMP Mon Jul 25 13:17:49 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
(2)创建用户和用户组
[root@ora243 ~]# groupadd oinstall
[root@ora243 ~]# groupadd dba
[root@ora243 ~]# groupadd oper
[root@ora243 ~]# groupadd asmadmin
[root@ora243 ~]# useradd -g oinstall -G dba,oper,asmadmin oracle
##修改用户
[root@oracle53 share]# usermod -g oinstall -G dba,oper,asmadmin oracle
##为用户创建密码:
[root@ora243 ~]# echo "oracle"|passwd --stdin oracle
(3)远程调用图形界面
ssh -X [email protected]
(4)解压缩oracle软件包
[root@ora243 share]# unzip linux.x64_11gR2_database_1of2.zip
[root@ora243 share]# unzip linux.x64_11gR2_database_2of2.zip
(5)安装oracle数据库用的依赖包
yum install -y oracle-validated.x86_64 ---软件包依赖,系统内核参数,lmits.conf
vim /etc/security/limits.conf
=======================================
# Oracle-Validated setting for nofile soft limit is 131072
oracle soft nofile 131072
# Oracle-Validated setting for nofile hard limit is 131072
oracle hard nofile 131072
# Oracle-Validated setting for nproc soft limit is 131072
oracle soft nproc 131072
# Oracle-Validated setting for nproc hard limit is 131072
oracle hard nproc 131072
# Oracle-Validated setting for core soft limit is unlimited
oracle soft core unlimited
# Oracle-Validated setting for core hard limit is unlimited
oracle hard core unlimited
# Oracle-Validated setting for memlock soft limit is 50000000
oracle soft memlock 50000000
# Oracle-Validated setting for memlock hard limit is 50000000
oracle hard memlock 50000000
==========================================
[root@ora243 dbs]# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
fs.file-max = 6815744
kernel.msgmni = 2878
kernel.msgmax = 8192
kernel.msgmnb = 65536
kernel.sem = 250 32000 100 142
(6)创建目录
[root@ora243 share]# mkdir -p /u01/app/oracle
[root@ora243 share]# chown oracle.oinstall /u01/app/oracle/ -R
(7)指定oracle环境变量
vim /home/oracle/.bash_proflie
============================
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/11.2.0/db_1
export ORACLE_SID=orcl
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
=============================
[oracle@oracle52 share]# source /home/oracle/.bash_profile
##验证环境变量生效
[oracle@ora243 ~]$ export |grep ORACLE_SID
declare -x ORACLE_SID="orcl"
[oracle@ora243 ~]$ export |grep ORACLE_BASE
declare -x ORACLE_BASE="/u01/app/oracle"
[oracle@ora243 ~]$ export |grep ORACLE_HOME
declare -x ORACLE_HOME="/u01/app/oracle/11.2.0/db_1"
(8)安装
切换到创建用户:su - oracle
切换到安装目录:cd /share/database
[oracle@oracle52 database]$ ./runInstaller
Checking Temp space: must be greater than 120 MB. Actual 16305 MB Passed
Checking swap space: must be greater than 150 MB. Actual 8189 MB Passed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<
解决方法:
退出root用户,使用oracle用户登录ssh -X [email protected]。
安装过程create invntory报错:
[INS-32031]Invalid inventory location
[INS-32033]Central Inventory location is not vritable
[root@oracle52 database]# chown -R oracle.oinstall /usr/app/ -R
(8) 多次安装需要修改的地方
vim /etc/sysctl.conf
sysctl -p --生效
(9)修改主机名,否则会出现网络错误
vim /etc/hosts
====================
10.10.54.53 oracle53
=====================
(10)oracle依赖包关系
(11)oracle卸载
cd /u01/app/oracle/11.2.0/db_1/deinstall
./deinstall
6.sqlplus实现历史命令切换
(1)安装
Term-ReadLine-Gnu-1.16.tar.gz
IO-Tty-1.07.tar.gz
uniread-1.01.tar.gz(uniread最后安装)
(2)解压缩并安装
[root@oracle53 Term-ReadLine-Gnu-1.16]# vim INSTALL
=====================================================
% perl Makefile.PL [--prefix=...] [--includedir=...] [--libdir=...]
% make
% make test
% make install
===========================================
perl Makefile.PL && make && make install
(3)修改环境变量
su - oracle
[oracle@oracle53 ~]$ vim /home/oracle/.bash_profile
=========================
alias sql="/usr/bin/uniread sqlplus"
alias rman="/usr/bin/uniread rman"
========================
source .bash_profile ---生效环境变量
which sql/rman --验证
7.解锁scott/tiger用户
connect scott/tiger;
##查看状态
SQL> select username,ACCOUNT_STATUS from dba_users where username='SCOTT'
2 ;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SCOTT EXPIRED & LOCKED
##解锁SCOTT
SQL> conn sys/oracle as sysdba --系统用户登录
SQL> startup --启动数据库
SQL> alter user scott account unlock;
SQL> alter user scott identified by tiger;
##授权
SQL> grant connect,resource,unlimited tablespace to scott;
SQL> connect scott/tiger;
##重新定义格式
SQL> col object_name for a30;
##查看
SQL> select object_name,object_type from user_objects;
OBJECT_NAME OBJECT_TYPE
------------------------------ -------------------
SALGRADE TABLE
BONUS TABLE
PK_EMP INDEX
EMP TABLE
DEPT TABLE
PK_DEPT INDEX
------------------------------------------------
##解锁HR
SQL> conn sys/oracle as sysdba --系统用户登录
SQL> startup --启动数据库
SQL> alter user hr account unlock;
SQL> alter user hr identified by hr;
SQL> grant connect,resource,unlimited tablespace to hr;
##创建数据库--要用oracle用户登录
[oracle@oracle53 ~]$ dbca
DISPLAY not set.
Set DISPLAY environment variable, then re-run.
[oracle@oracle53 ~]$ export DISPLAY=10.10.54.53:1.0
##查看所创建数据库
SQL> select name,log_mode,created,open_mode from v$database;
NAME LOG_MODE CREATED OPEN_MODE
--------- ------------ --------- --------------------
SHIWEI NOARCHIVELOG 31-MAR-14 READ WRITE
#系统用户登录
[oracle@oracle53 ~]$ sql / as sysdba;