一、安装VMware tools工具(非必须)
1、虚拟机上点击安装
因为我在虚拟机中做的,后面oracle 安装是图形化安装,需要屏幕大一点,不然有些按钮点不住。
2、安装
① 解包
[[email protected] VMware Tools]# cd /media/VMware\ Tools/
[[email protected] VMware Tools]# tar zxvf VMwareTools-10.1.6-5214329.tar.gz -C /tmp
② 执行安装脚本
[[email protected] ~]# cd /tmp/vmware-tools-distrib/
[[email protected] vmware-tools-distrib]# ./vmware-install.pl 执行perl 语言的脚本,然后一直回车
③ 安装完毕,重启一下机器
二、安装oracle准备
1、准备,2个安装包,1个安装脚本
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
orainst_11g.sh
2、解压安装包,一定要解压到/root 下,因为脚本中有设置
[[email protected] ~]# unzip p13390677_112040_Linux-x86-64_1of7.zip ;unzip p13390677_112040_Linux-x86-64_2of7.zip
解压完,会在/root 下生成一个database 的目录
3、安装脚本如下
[[email protected] ~]# vim orainst_11g.sh #!/bin/bash #1.安装依赖包 PKG=" #定义一个变量,需要安装的包 unixODBC unixODBC-devel binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat " PACKINSTALL= for PACKAGE in $PKG ;do #for循环,安装 rpm -q $PACKAGE || PACKINSTALL="$PACKINSTALL $PACKAGE" done echo if [ -z "$PACKINSTALL" ];then true else echo "The followling packages will be install: $PACKINSTALL " read -p "Continue? (y/N): " answer case $answer in ([yY]|[Yy][Ee][Ss]) echo 1 yum -y install $PACKINSTALL ;; (*);; esac fi #2.创建所需要的组、和用户 cat /etc/group |grep oinstall &> /dev/null || /usr/sbin/groupadd oinstall cat /etc/group |grep dba &> /dev/null || /usr/sbin/groupadd dba id oracle &> /dev/null if [ $? = 0 ];then groups oracle | grep dba &> /dev/null || /usr/sbin/usermod -g oinstall -G dba oracle else /usr/sbin/useradd -g oinstall -G dba oracle echo oracle |passwd --stdin oracle fi #3.对内核的调整,设置内核的值 KELNUM=$(cat /etc/sysctl.conf |grep -v ^# |grep -v ^$ |grep -E "fs.aio-max-nr|fs.file-max|kernel.shmall|kernel.shmmax|kernel.shmmni|kernel.sem|net.ipv4.ip_local_port_range|net.core.rmem_default|net.core.rmem_max|net.core.wmem_default|net.core.wmem_max" |awk '{print $1}' |sort -u |wc -l ) if [ $KELNUM -lt 11 ];then cat >> /etc/sysctl.conf <<EOF 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 = 1048586 EOF /sbin/sysctl -p fi #4.修改limits.conf 文件 grep oracle /etc/security/limits.conf &> /dev/null if [ $? != 0 ];then cat >> /etc/security/limits.conf << EOF oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 1024 EOF fi #5.修改/etc/pam.d/login 的值 grep pam_limits.so /etc/pam.d/login &> /dev/null if [ $? != 0 ];then cat >> /etc/pam.d/login <<EOF session required pam_limits.so EOF fi #6.创建oracle 安装的目录,这个目录所在的区或盘需要最少30G,建议生产环境,最好放在逻辑卷上 [ -d /mnt/app ] || ( mkdir -p /mnt/app/ ; chown -R oracle:oinstall /mnt/app/ ; chmod -R 775 /mnt/app ) #7.修改一些环境变量 grep -i oracle ~oracle/.bash_profile &> /dev/null if [ $? != 0 ];then cat >> ~oracle/.bash_profile <<EOF export ORACLE_BASE=/mnt/app/oracle #oracle软件的主目录 export ORACLE_HOME=\$ORACLE_BASE/11.2.0/db_1 #oracle数据库的目录 export ORACLE_SID=orcl #oracle实例 export PATH=\$PATH:\$ORACLE_HOME/bin #oracle命令 EOF fi
4、脚本执行前需注意
① IP地址必须是静态获取,不能是dhcp动态获取
② 保证主机名能解析,ping自己的主机名
[[email protected] ~]# vim /etc/hosts #加上解析自己的主机名
192.168.10.6 along
③ oracle 安装的目录所在的区或盘需要最少30G,建议生产环境,最好放在逻辑卷上
5、准备安装oracle 需要的硬盘
① 虚拟加一个30G硬盘
② 查看加入硬盘的名字
[[email protected] ~]# fdisk -l
③ 分区,把所有空间都分成一个区
[[email protected] ~]# fdisk /dev/sdb
④ 文件系统格式化
[[email protected] ~]# mkfs.ext4 /dev/sdb1
⑤ 挂载
[[email protected] ~]# mount /dev/sdb1 /mnt
6、执行脚本
① 给脚本加权限,注意需要在图形化中执行
② 执行完脚本,会弹出安装Oracle的框
③ 如果不小心关闭了安装框,在图形化中,打开一个新的终端
[[email protected] ~]# xhost +
[[email protected] ~]# su - oracle
[[email protected] ~]$ ./database/runInstaller 就会弹出安装框了
三、安装Oracle软件
1、欢迎界面
因为没买正版,所以去掉√
2、让你输入账号,跳过就好
3、安装方式
① 既安装Oracle,又安装数据库(一部到位)
② 只安装Oracle软件(√)
③ 更新已存在的数据库
为了让大家了解怎么去配置数据库,我选择第二个
4、实例选择
① 单实例数据库
② 多实例数据库
我安装最基本的,单实例
5、字符集,加上汉语
6、安装版本,选择最高级版本
7、安装路径,因为脚本设置过了
8、上一步直接跳过,这一步选择默认的数据库oinstall
9、自行检查错误
① 需修改一个参数,按照他要求的修改
[[email protected] ~]# vim /etc/sysctl.conf
kernel.shmmax = 2001682432
[[email protected] ~]# sysctl -p 生效一下
② 缺少一个包,安装。(这个包,我的网盘有提供)
[[email protected] ~]# rpm -e ksh 卸载一个包,因为和需要安装的包冲突
[[email protected] ~]# rpm -ivh pdksh-5.2.14-30.x86_64.rpm 安装
③ 再检测,检测通过
10、安装,等待就可以;安装的是Oracle软件
11、要求运行2个脚本
注意需要root权限运行,复制脚本,运行时,有什么提示,都回车就行
12、安装Oracle软件完成,已有Oracle命令了
四、安装Oracle库
还是图形化安装
1、打开配置框
[[email protected] ~]# su - oracle
[[email protected] ~]$ dbca #反应会有的慢
2、创建数据库
3、选择常规配置
4、实例名配置
5、基于web界面管理工具,如果需要这项功能,则需要监听管理工具
启动监听管理工具,注意要用oracle用户
[[email protected] ~]$ lsnrctl start
6、设置密码,如果密码太简单,会有提示,继续yes就行
7、开启归档,上一步跳过
8、需不需要安装示例库
9、字符集和操作系统的一致
10、开始安装
11、等待安装即可
安装完成,弹出简单的说明
整个安装过程完成!
五、登录数据库
[[email protected] ~]# su - oracle
[[email protected] ~]$ sqlplus / as sysdba
/:本地系统认证(省去登录用户密码的步骤)
as + 角色
http://news.ozn1702.cn/
http://news.zbb7727.cn/
http://news.vtl3405.cn/
http://news.zht3189.cn/
http://news.zzl7747.cn/
http://news.abd5921.cn/
http://news.hch9349.cn/
http://news.hwp3498.cn/
http://news.wll1115.cn/
http://news.rol3427.cn/
http://news.akb6775.cn/
http://news.giy4971.cn/
http://news.tyo9948.cn/
http://news.uzh3227.cn/
http://news.mfc7569.cn/
http://news.otm3953.cn/
http://news.ewh1005.cn/
http://news.iip1291.cn/
http://news.dyg4913.cn/
http://news.ase4727.cn/
http://news.uqx4260.cn/
http://news.sif0574.cn/
http://news.sdb0307.cn/
http://news.thg4282.cn/
http://news.rvc0755.cn/
http://news.qld9407.cn/
http://news.idd5091.cn/
http://news.cqu4082.cn/
http://news.skk3561.cn/
http://news.lsz6488.cn/
http://news.ncc8754.cn/
http://news.tsx6039.cn/
http://news.ayr4754.cn/
http://news.cjd7774.cn/
http://news.wzf9854.cn/
http://news.nzl1119.cn/
http://news.zdn2144.cn/
http://news.ief1694.cn/
http://news.buu7798.cn/
http://news.eig6365.cn/
http://news.djf2649.cn/
http://news.hvc6084.cn/
http://news.opg6486.cn/
http://news.hud3144.cn/
http://news.iit3286.cn/
http://news.wyu4949.cn/
http://news.lus6696.cn/
http://news.epi0997.cn/
http://news.rdk6709.cn/
http://news.lwa7903.cn/
http://news.kjx4882.cn/
http://news.nwf3326.cn/
http://news.thy6127.cn/
http://news.xho5322.cn/
http://news.bfc2814.cn/
http://news.lhl7110.cn/