oracle前言
Oracle开发的关系数据库产品因性能卓越而闻名,Oracle数据库产品为财富排行榜上的前1000家公司所采用,许多大型网站也选用了Oracle系统,是世界最好的数据库产品。此外,Oracle公司还开发其他应用程序和软件。同时,Oracle在英语里还是“神谕”的意思,意为“替神说话的”,寓指Oracle公司的发展目标和决心地位。
以下环境适用于Redhat 8 系列及复刻Redhat 8系列系统
download Oracle
oracle 21c 需要oralce 账号哦 | oracle 百度云下载地址 | 文档 |
download | download | 参考 |
Linux 各系统下载使用参考
Red Hat | Rocky Linux | Oracle Linux | AlmaLinux | ubuntu | suselinux | esxi | RHEL标准安装 | 系统安装参考 | YUM参考 | MobaXterm 远程连接工具 | Red Hat Enterprise 9.0 文档 | Kickstart 生成器 | |||||
download | download | download | download | download | download | download | 参考 | 参考 | 配置参考 | download | 参考 | Kickstart | |||||
版本兼容性 |
oracle 依赖安装,内核配置,防火墙配置,用户,用户组,权限分配
-
root模式下执行,预计耗时5分钟
-
Linux系统创建的oracle用户名密码oracle/oracle@123
-
/u01/app/oracle 数据库安装目录
-
/etc/sysctl.d/50-oracle.conf 内核配置
-
/etc/security/limits.d/50-oracle.conf 添加以下行来在文件中设置用户oracle的shell限制
vi /oracle_basics_install.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/05/26
# root Lower execution
ORACLE_USER_CHECK=`compgen -u oracle`
install_oracle_basics (){
if [ -d $ORACLE_USER_CHECK ];then
if [ $? -eq 0 ];then
echo "Install the Oracle dependent environment"
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y binutils gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libgcc.i686 libstdc++ libstdc++-devel libXi libXtst libnsl make sysstat
yum install -y libmpc bc libgomp compat-openssl10 elfutils-libelf
yum install -y cpp isl libXrender libX11 libXau libnsl libxcb libibverbs policycoreutils policycoreutils-python-utils smartmontools
echo "Firewall port development"
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
firewall-cmd --zone=public --add-port=80/tcp --add-port=443/tcp --add-port=1521/tcp --add-port=5500/tcp --permanent && firewall-cmd --reload
echo "Edit Kernel parameters"
cat > /etc/sysctl.d/50-oracle.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
kernel.panic_on_oops = 1
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
EOF
sysctl --system
echo "Create an oracle user or user group"
i=54321; for group in oinstall dba oper backupdba dgdba kmdba asmdba asmoper asmadmin racdba; do
groupadd -g $i $group; i=$(expr $i + 1)
done
echo "Create an oracle user or user group"
useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,racdba -d /usr/oracle oracle
echo "Add oracle users to users and user groups"
echo "oracle@123" | passwd --stdin oracle
echo "create oracle directory"
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app
chmod -R 755 /u01
echo "Add following lines to set shell limits for user oracle in file"
cat >>/etc/security/limits.d/50-oracle.conf<<EOF
# create new
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
oracle soft data unlimited
oracle hard data unlimited
EOF
echo -e "\033[32mThe oralce Initialization Install Success...\033[0m"
else
echo -e "\033[31mThe oracle Initialization Install Failed...\033[0m"
exit 1
fi
else
echo -e "\033[33mThe oracle Initialization already...\033[0m"
fi
}
main (){
install_oracle_basics
}
main
执行依赖安装,内核配置,防火墙配置
sh /oracle_basics_install.sh
安装oracle 数据库
- oracle 用户模式下执行,预计耗时10分钟
- root下切换oracle用户不需要输入密码,因为root是老大
- ~/.bash_profile 环境变量信息,目录,数据库登录密码
- oracle 数据库登录密码 Ciasm123
- oracle_SID: orcl
- /usr/oracle/database #oracle解压安装目录
- /u01/app/oraInventory 指定存放库存文件的位置
- /usr/oracle/database/runInstaller --help 获取安装参数的支持,版本不同参数不同
- oracle_database 下载地址,以下是我自己内网的下载,官网下载需要oralce 账号,文档前有官方和百度云地址更改此处即可http://192.168.11.252:9999/ISO/oracle/LINUX.X64_213000_db_home.zip
- HFSHTTP 文件服务器,拉取发布软件到程序即可 dowload
su - oracle
echo "oracle environment variable"
echo 'umask 022' >> ~/.bash_profile
echo 'export ORACLE_HOME=/usr/oracle/database' >> ~/.bash_profile
echo 'export ORACLE_BASE=/u01/app/oracle' >> ~/.bash_profile
echo 'export PATH=$PATH:$ORACLE_HOME/bin' >> ~/.bash_profile
echo 'export CV_ASSUME_DISTID=RHEL8.0' >> ~/.bash_profile
echo 'export ORA_INVENTORY=/u01/app/oraInventory' >> ~/.bash_profile
echo 'export ORACLE_SID=orcl' >> ~/.bash_profile
echo 'export ORACEL_DATABASE_PASSWORD=Ciasm123' >> ~/.bash_profile
echo 'export DISPLAY=":0.0"' >> ~/.bash_profile
source ~/.bash_profile
echo "download oracle"
mkdir -p $ORACLE_HOME
wget -N -P $ORACLE_HOME http://192.168.11.252:9999/ISO/oracle/LINUX.X64_213000_db_home.zip
chmod 777 $ORACLE_HOME/LINUX.X64_213000_db_home.zip
unzip -q $ORACLE_HOME/LINUX.X64_213000_db_home.zip -d $ORACLE_HOME
echo "Install Oracle Database"
cd $ORACLE_HOME
./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile $ORACLE_HOME/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=$ORA_INVENTORY \
ORACLE_HOME=$ORACLE_HOME \
ORACLE_BASE=$ORACLE_BASE \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=oper \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
exit
得到了关于交换内存的警告,但它是可忽略的错误,您被要求以root用户运行两个脚本。一旦完成,就会安装二进制文件
- root模式下执行,预计耗时10秒
sh /u01/app/oraInventory/orainstRoot.sh
sh /usr/oracle/database/root.sh
dbca 创建oracle库名称orcl,创建监听
- oracle 用户模式下执行,预计耗时10分钟
- root下切换oracle用户不需要输入密码,因为root是老大
- 监听端口 1521
- 监听文件位置/usr/oracle/database/netca.rsp
- orcl 数据库名称
- characterSet 字符集 AL32UTF8 ,以下支持的字符集,可以根据实际需求更改
#--------------------------------------------------------
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#--------------------------------------------------------
- 启用em https管理数据库https://YOU_IP:5500/em {用户名密码sys/Ciasm123}
su - oracle
echo "creation netca.rsp"
cat >>$ORACLE_HOME/netca.rsp<<EOF
[GENERAL]
RESPONSEFILE_VERSION="21.0.0"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
EOF
#lsnrctl start
echo "start netca.rsp"
netca -silent -responsefile $ORACLE_HOME/netca.rsp
echo "Login with Oracle user and Create Database with [dbca] command."
dbca -silent -createDatabase \
-databaseConfigType SINGLE \
-templateName General_Purpose.dbc \
-gdbname ${ORACLE_SID}.$(hostname -d) \
-sid ${ORACLE_SID} \
-listeners LISTENER \
-responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword ${ORACEL_DATABASE_PASSWORD} \
-systemPassword ${ORACEL_DATABASE_PASSWORD} \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName orclpdb \
-pdbAdminPassword ${ORACEL_DATABASE_PASSWORD} \
-databaseType MULTIPURPOSE \
-memoryPercentage 30 \
-storageType FS \
-datafileDestination "${ORACLE_BASE}/oradata/${ORACLE_SID}" \
-emConfiguration DBEXPRESS \
-emExpressPort 5500
exit
创建oracle 系统启动服务脚本
- root模式下,预计耗时10秒
- 重启验证是否开机自启动oracle,开机稍微等待3分钟左右oralce 监听,库,em都会启动
- netstat -lntp 查看端口是否全部启动,1521,5500
echo "Set this parameter in root mode"
sed -i "s#orcl:/usr/oracle/database:N#orcl:/usr/oracle/database:Y#" /etc/oratab
echo "oracle Boot script"
cat >>/usr/lib/systemd/system/orcl@oracledb.service<<EOF
# this is an example, modify for free
[Unit]
Description=Oracle Database service
After=network.target
[Service]
User=oracle
Type=forking
Environment=ORACLE_BASE=/u01/app/oracle
Environment=ORACLE_HOME=/usr/oracle/database
Environment=ORACLE_SID=orcl
ExecStart=/usr/oracle/database/bin/dbstart /usr/oracle/database
ExecStop=/usr/oracle/database/bin/dbshut /usr/oracle/database
Restart=always
[Install]
WantedBy=multi-user.target
EOF
echo "The startup setting is set after startup"
systemctl daemon-reload && systemctl enable orcl@oracledb
em 管理系统打开
- https://(servers hostname or IP address):5500/em
- sys/Ciasm123 em登录管理用户名密码
这是Enterprise Manager管理控制台
重启验证是否开机自启动oracle 数据库,监听,em
reboot
netstat -lntp