首先复制下面的初始化参数文件命名为oracleinstall.sh进行创建脚本文件并授可执行权限,并执行脚本
[root@oracle ~]vim oracleinstall.sh 复制脚本粘贴进来
[root@oracle ~]chmod +x oracleinstall.sh
[root@oracle ~]chmod +x ./oracleinstall.sh
运行初始化参数文件内容
#!/bin/bash
# oracle 11g R2 for linux 安装辅助脚本
# Redkey
# version 1.3
# date 2017.10.19
#定义常量
SYSCTL=/etc/sysctl.conf
LIMITS=/etc/security/limits.conf
PAM=/etc/pam.d/login
PROFILE=/etc/profile
BASH_PROFILE=/home/oracle/.bash_profile
#循环变量
i=1
#定义显示颜色
#颜色定义 信息(33黄色) 警示(31红色) 过程(36浅蓝)
#判断执行用户是否root
isroot()
{
if [ $USER != "root" ];then
echo -e "\n\e[1;31m the user must be root,and now you user is $USER,please su to root. \e[0m"
exit4
else
echo -e "\n\e[1;36m check root ... OK! \e[0m"
fi
}
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh compat-db control-center libstdc++ libstdc++-devel xscreensaver openmotif21 ksh* compat-libcap* zip unzip
#挂在光盘到/mnt/cdrom目录下
#mount_cdrom()
#{
#echo -e "\n\e[1;31m please insert RHEL to CDROM,press any key ...\e[0m"
#read -n 1
#if [ -d /mnt/cdrom ];then
# mount -t auto -o ro /dev/cdrom /mnt/cdrom
#else
# mkdir -p /mnt/cdrom
# mount -t auto -o ro /dev/cdrom /mnt/cdrom
#fi
#if [ $? -eq 0 ];then
# echo -e "\n\e[1;36m CDROM mount on /mnt/cdrom ... OK! \e[0m"
#fi
#}
#设置yum本地光盘源
#yum_repo()
#{
# rm -rf /etc/yum.repos.d/* && cat <<EOF >> /etc/yum.repos.d/Server.repo
#[Server]
#name=MyRPM
#baseurl=file:///mnt/cdrom/Server
#enabled=1
#gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
#EOF
#if [ $? -eq 0 ];then
#echo -e "\n\e[1;36m /etc/yum.repos.d/Server.repo ... OK! \e[0m"
#fi
#}
#添加oracle用户,添加oracle用户所属组oinstall及附加组dba
ouseradd()
{
if [[ `grep "oracle" /etc/passwd` != "" ]];then
userdel -r oracle
fi
if [[ `grep "oinstall" /etc/group` = "" ]];then
groupadd oinstall
fi
if [[ `grep "dba" /etc/group` = "" ]];then
groupadd dba
fi
useradd oracle -g oinstall -G dba && echo $1 |passwd oracle --stdin
if [ $? -eq 0 ];then
echo -e "\n\e[1;36m oracle's password updated successfully --- OK! \e[0m"
else
echo -e "\n\e[1;31m oracle's password set faild. --- NO!\e[0m"
fi
}
#检查oracle所需软件包并安装
packagecheck()
{
for package in binutils compat-libcap1 compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat
do
rpm -q $package 2> /dev/null
if [ $? != 0 ];then
yum -y install $package
echo -e "\n\e[1;36m $package is already installed ... OK! \e[0m"
fi
done
}
#安装桌面套件 X Window System / Desktop
#xdesk()
#{
# yum -y groupinstall "X Window System" "Desktop"
#}
# 设置内核参数
kernelset()
{
cp $SYSCTL{,.bak} && cat <<EOF >>$SYSCTL
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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 = 1048575
EOF
if [ $? -eq 0 ];then
echo -e "\n\e[1;36m kernel parameters updated successfully --- OK! \e[0m"
fi
sysctl -p
}
#设置oracle资源限制
oralimit()
{
cp $LIMITS{,.bak} && cat <<EOF >> $LIMITS
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
if [ $? -eq 0 ];then
echo -e "\n\e[1;36m $LIMITS updated successfully ... OK! \e[0m"
fi
}
#设置login文件
setlogin()
{
cp $PAM{,.bak} && cat <<EOF >>$PAM
session required pam_limits.so
EOF
if [ $? -eq 0 ];then
echo -e "\n\e[1;36m $PAM updated successfully ... OK! \e[0m"
fi
}
#设置profile文件
setprofile()
{
cp $PROFILE{,.bak} && cat <<EOF >>$PROFILE
if [ $USER = "oracle" ];then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
if [ $? -eq 0 ];then
echo -e "\n\e[1;36m $PROFILE updated successfully ... OK! \e[0m"
fi
}
#设置oracle的profile文件
setbash_profile()
{
cp $BASH_PROFILE{,.bak} && cat <<EOF >> $BASH_PROFILE
umask 022
ORACLE_BASE=/home/oracle/app
ORACLE_HOME=/home/orac
2.ROOT用户创建目录/app,修改chown oralce:oinstall /app
3.设置环境变量 vi /home/oralce/.bash_profile,一定要去掉NLS_LANG这个属性,否则报错,切换oracle 使用su - oracle
umask 022
ORACLE_BASE=/app
ORACLE_HOME=$ORACLE_BASE/product
ORACLE_SID=orcl
PATH=/app/product/bin/:/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
export path
LANG=en_US.UTF-8
stty erase ^H
export ORACLE_BASE ORACLE_HOME ORACLE_SID
保存然后执行source /home/oralce/.bash_profile
3.修改 /home/oracle/soft/database/response/db_install.rsp
切换oralce运行命令
./runInstaller -silent -ignorePrereq -responseFile /home/oracle/soft/database/response/db_install.rsp
命令执行完成后运行
/app/oraInventory/orainstRoot.sh
/app/product/root.sh
二 创建数据库
ORACLE 账户
export DISPLAY=192.168.0.1:0.0
安装xmanager 运行 Xmanager - Passive
创建过程会运行文件post。。。,默认是root,oracle不能运行,修改own
chown oracle:oinstall /app/cfgtoollogs/dbca/orcl/*
运行 ./dbca
三 创建监听
4、监听静默安装
export DISPLAY=192.168.0.1:0.0
[oracle@vmtest ~]$ netca
Oracle Net Services Configuration:
Stopping Oracle Net Listener:
Running Listener Control:
/app/product/bin/lsnrctl stop LISTENER
Listener Control complete.
Listener stop failed.
Deleted listener: LISTENER
Configuring Listener:LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/app/product/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
问题汇总
如果1521没有监听,运行netca重新配置一下或者运行lsnrctl start(没有尝试)
修改监听后运行lsnrctl reload重新加载
activiti 数据库配置错误:ORA-12505, TNS:listener does not currently know of SID given in connect desc,。
select INSTANCE_NAME from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> startup 开启实例
ORACLE instance started.
Total System Global Area 1202556928 bytes
Fixed Size 2212816 bytes
Variable Size 721423408 bytes
Database Buffers 469762048 bytes
Redo Buffers 9158656 bytes
Database mounted.
Database opened.
SQL> select INSTANCE_NAME from v$instance;
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1 )(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl )
)
)