#!/bin/bash
# Version 1.0, 2020-11-19
# author: Chen
# just for oracle 11g install
echl(){
echo -ne "\033[$1m $2 \033[0m"
echo ""
}
# 31 red 32 green 33 yellow 34 blue 35 black 36 cyan 37 grey
# tput blink tput sgr0
user=`users |awk '{print $1}'`
tput blink
echl 31 "Oracle 11g 半自动化安装正在进行************"
echl 31 "图形安装中遇到问题,可参考 加参数 help 运行该脚本"
tput sgr0
tput blink
read -p " press c to continue or enter help for document help " comm
tput sgr0
if [ $comm == "help" ];then
echo " oracle 11g install document "
echl 33 "第一步不填,去掉√ ,是!!!!!!!!!!!!!"
echl 33 "第二步不更新,继续"
echl 33 "... ..."
echl 33 "第n部,配置路径,好密码,如果不显示界面,图形变暗,中间一个 |,则直接按左键,回车(不行就换右键)继续"
echl 33 "等待安装前检察,出现进度条,时间稍长,请耐心等待"
echl 33 "......."
echl 33 "缺少elfuntils-libelf-devel-0.97 pdksh-5.2.14 ignore all 忽略这两个包"
echl 33 "下一步弹出若干看不到的东西,显示 |,按左或右键回车即可"
echl 33 "The Oracle system identifier(SID) orcl already"
echl 33 "删除Orcl目录"
echl 33 "oratab,删除最后一 行: orcl:/u01/oracle:N "
echl 33 "execute root scripts(根脚本执行)-failed"
echl 33 "切换到root用户:"
echl 33 "#/app/oraInventory/orainstRoot.sh"
echl 33 "#/app/oracle/product/11.2.0/db_1/root.sh"
echl 33 " 执行完这连个脚本后再点击try便可执行成功"
echl 33 "可参考:https://www.cnblogs.com/hoobey/p/6010804.html"
read -p "按回车 continue!"
clear
echo ""
echo ""
fi
tput blink
echl 32 "请保持网络通畅,否则可能造成不可预期的错误!"
sleep 2
tput sgr0
if [ $user! = 'root' ];then
tput blink
echl 31 "请确认以 root 身份登录执行"
read -p " press enter to continue!!!"
tput sgr0
exit
fi
#
#设置yum
read -p "需要配置yum? 是[1],否[0]" num1
if [ $num1 == "1" ];then
echl 36 "yum配置中... ..."
sleep 2
mkdir /etc/yum.repos.d/repo.bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
echl 31 "yum configuration cmplete!"
sleep 0.5
fi
# add user and group
for i in {1..60}
do
echo -ne "-"
sleep 0.05
done
echo ""
echl 32 "添加必要的用户和组"
useradd oracle
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
echl 33 "设置 oracle用户密码"
echo oracle |passwd --stdin oracle
tput blink
read -p "输入本机ip" ip
hn=`hostname`
if [$ip == "" ];then
echo $ip hostname >> /etc/hosts
fi
echl 33 "软件安装在/opt/oracle下,正在创建目录设置该目录权限"
read -p " press enter to continue!!!"
tput sgr0
mkdir /opt/oracle
chown -R oracle:oinstall /opt/
chmod 2755 /opt/
echo "export ORACLE_BASE=/opt/oracle/base
export ORACLE_HOME=/opt/oracle/orc_home
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH" >> /etc/profile
echo "注意安装时配置与此处相同"
read -p "enter nothing to continue!!!"
#图形化的x 功能 xclock 等
xhost +
# 装包
yum -y install gcc-3.4.6 elfuntils-libelf-devel-0.97 gcc-* pdksh-5.2.14
echo "这些包是非必要的"
read -p " press enter to continue!!!"
#制作交换分区
read -p "make swap please enter 1,or not make enter 2" mk
if [ $mk == '1' ];then
echl 36 "正在制作交换分区"
dd if=/dev/zero of=/opt/swap.txt bs=1M count=2560
mkswap /opt/swap.txt
swapon /opt/swap.txt
if [ $?==0 ];then
echl 36 "制作交换分区完成"
else
echl 31 "制作交换分区失败,exit!"
read -p " press enter to continue!!!"
exit
fi
fi
#防止乱码
export LANG=Zh-CN.UTF-8
echl 31 "正在安装解压,请将
p13390677_112040_Linux-x86-64_2of7.zip
p13390677_112040_Linux-x86-64_1of7.zip
oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
三个软件放入/root/下"
read -p " press enter to continue!!!"
read -p “完成后按回车确认”
unzip -n -d /opt/oracle/ p13390677_112040_Linux-x86-64_2of7.zip
n1=$?
unzip -d /opt/oracle/ p13390677_112040_Linux-x86-64_1of7.zip
n2=$?
yum -y install oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
n3=$?
if [$1 == 0 ] & [ $2 == 0 ] & [ $3 == 0 ];then
rm -rf oracle-da* p13390677*
fi
echo "正在执行安装"
echo "when install complete,cp disql /usr/bin/"
echo "when install complete,cp disql /usr/bin/"
echo "when install complete,cp disql /usr/bin/"
su oracle /opt/oracle/database/runInstaller