第十天 oracle安装
1.安装linux:
创建虚拟机:
名称:oracle11gR2_RHEL6.4_x64
类型:linux 64bit
内存:2048MB
硬盘大小:100GB
设置:
双向复制,处理器数量2,存储:加载光盘
启动顺序:硬盘,网络
网络:网卡1,host-only
去除声音、usb设备
安装:desktop方式
主机名:node1.test.com,网络:自动链接ip使用192.168.0.1 24,时区:亚洲上海 root:password swap 4GB,其余给/
- 调整linux系统:
关闭防火墙:
# service iptables stop
# service ip6tables stop
# chkconfig iptables off
# chkconfig ip6tables off
管理工具中disabled防火墙
关闭selinux:
# vi /etc/selinux/config
SELINUX=disabled
配置yum:
# rm -f /etc/yum.repos.d/*
或者:
# vi /etc/yum.repos.d/oel6.repo
[Server]
name=Server
baseurl=file:///media/"OEL_6.5 x86_64 Disc 1"/Server
enabled=1
gpgcheck=0
安装vb增强功能:
# cd /media/OL6.4\ x86_64\ Disc\ 1\ 20130225/Packages/
# yum install gcc kernel-uek-devel-2.6.39-400.17.1.el6uek.x86_64.rpm
# ln -s /usr/src/kernels/2.6.32-431.el6.x86_64/ /usr/src/linux
设备-->安装增强功能
右键eject弹出光盘
- 确认root身份:
# id
- 硬件配置:
# grep MemTotal /proc/meminfo 内存
# grep SwapTotal /proc/meminfo 交换内存
# vi /etc/fstab(永久修改)
tmpfs /dev/shm tmpfs defaults,size=2G 0 0
# mount -o remount /dev/shm
临时修改
# mount -t tmpfs shmfs -o size=2g /dev/shm
# uname -m
# df -h
替代6 7 8 9步
# cd /media/OL6.4\ x86_64\ Disc\ 1\ 20130225/Packages/
# yum install oracle-rdbms-server-11gR2-preinstall //安装这个安装包会把其他的软件包一块安装并且修改内核参数 环境设置
# groupadd -g 1000 oinstall
# groupadd -g 1001 dba
# groupadd -g 1002 oper
# useradd -u 1000 -g oinstall -G dba,oper oracle
# passwd oracle
- 修改内核参数:
# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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 = 1048576
# sysctl -p
- 修改资源限制:
# vi /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
- 创建目录:
# mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01
# chmod -R 775 /u01
- 修改概要文件:
# vi ~oracle/.bash_profile
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_HOSTNAME=node1.test.com
export ORACLE_UNQNAME=orcl
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=american_america.AL32UTF8
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export EDITOR=vi
export LANG=C
使用hosts文件解析主机名:
# hostname
node1.test.com
# vi /etc/hosts
192.168.0.1 node1.test.com node1
# ping node1
# ping node1.test.com
# cd /installation
# unzip p10404530_112030_Linux-x86-64_[12]of7.zip
或者:
在物理主机中解压缩2个安装包,然后共享给虚拟机,命令如下:
# mkdir /installation
# mount -t vboxsf installation /installation
cd /installation
unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
- 图形界面安装:
# xhost + //所有用户都有权限去桌面
# su - oracle
$ cd /database/
$ ./runInstaller
只安装软件
以root身份执行两个脚本
- 创建监听和数据库:
图形界面下创建监听,oracle执行:
$ netca
$ lsnrctl status
$ netstat -tlnp | grep 1521
图形界面创建db,oracle执行:
$ dbca
通用或事务处理,orcl 要选中样本权限 内存1200 数据库字符:UTF8
- 测试:
sqlplus测试:
$ sqlplus sys/password@orcl as sysdba
$ sqlplus / as sysdba
SQL> show user
SQL> select count(*) from hr.employees;
SQL> exit
浏览器测试:
https://192.168.0.1:1158/em
sys/password sysdba
安装rlwrap:
root身份安装
# yum install rlwrap-0.42-1.el6.x86_64.rpm
# vi ~oracle/.bashrc
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
# su - oracle
$ sqlplus / as sysdba
root身份安装(不用执行)
# yum install flash-plugin-11.2.202.508-release.x86_64.rpm
sqldeveloper测试:
root身份安装
在windows下,将rlwrap的安装包复制到installation下
检查挂载目录
# cd /installation/
# yum install jdk-8u51-linux-x64.rpm
# yum install sqldeveloper-4.1.1.19.59-1.noarch.rpm
# /usr/local/bin/sqldeveloper
输入jdk的路径 /usr/java/jdk1.8.0_51/
点左上角+号,创建新连接:
sys/password,连接类型:basic,角色:sysdba
192.168.0.1 端口1521 sid:orcl
测试,保存。
- 添加启动脚本:
以root身份
# vi /etc/oratab 把N改为Y
orcl:/u01/app/oracle/product/11.2.0/db_1:Y
# vi /etc/rc.d/init.d/oracle
#!/bin/bash
#chkconfig:35 99 01
case "$1" in
start)
echo -n "Starting Oracle Database & Listener:"
su - oracle -c 'dbstart $ORACLE_HOME' >/dev/null
echo "[ ok ]"
echo -n "Starting Oracle EM dbconsole:"
su - oracle -c "emctl start dbconsole" >/dev/null
echo "[ ok ]"
touch /var/lock/subsys/oracle
;;
stop)
echo -n "Shutting Down Oracle EM dbconsole:"
su - oracle -c "emctl stop dbconsole" >/dev/null
echo "[ ok ]"
echo -n "Shutting Down Oracle Database & Listener:"
su - oracle -c 'dbshut $ORACLE_HOME' >/dev/null
echo "[ ok ]"
rm -f /var/lock/subsys/oracle
;;
*)
echo "Usage: oracle {start|stop}"
exit 1
esac
# chmod 755 /etc/rc.d/init.d/oracle
# chkconfig --add oracle
# chkconfig --list oracle
- 删除口令有效期:
# su - oracle
$ sqlplus / as sysdba
SQL> alter profile default limit PASSWORD_LIFE_TIME unlimited;