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模式下执行安装,预计耗时50分钟
- Linux系统创建的oracle用户名密码oracle/oracle@123
- oracle 数据库登录密码 Ciasm123
- /u01/app/oracle 数据库安装目录
- ~/.bash_profile 环境变量信息,目录
- oracle_SID: orcl #数据库名称
- /opt/oracle/product/21c/dbhome_1 #oracle解压安装目录
- /u01/app/oraInventory 指定存放库存文件的位置
- /opt/oracle/product/21c/dbhome_1/runInstaller --help 获取安装参数的支持,版本不同参数不同
- root下切换oracle用户不需要输入密码,因为root是老大
- 监听端口 1521,监听文件位置/etc/sysconfig/oracledb_orcl-21c.conf
- /etc/init.d/oracledb_ORCLCDB-21c #oracle 配置文件,可更改名称和em,字符集
- 重启验证是否开机自启动oracle,开机稍微等待3分钟左右oralce 监听,库,em都会启动
- netstat -lntp 查看端口是否全部启动,1521,5500
- em https管理数据库https://YOU_IP:5500/em {用户名密码sys/Ciasm123}
- oracle_database 下载地址,以下是我自己内网的下载,官网下载需要oralce 账号,文档前有官方和百度云地址更改此处即可 http://192.168.12.252:9999/ISO/oracle/oracle-database-ee-21c-1.0-1.ol8.x86_64.rpm
- HFSHTTP 文件服务器,拉取发布软件到程序即可 dowload
vim /oracle21C_install_rpm.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/05/29
# Install oracle using rpm
ORACLE_ORACLEHOME_CHECK=/opt/oracle
install_oracle (){
if [ ! -d $ORACLE_ORACLEHOME_CHECK ];then
if [ $? -eq 0 ];then
#User name and password for logging in to the oracle database in Linux
oracle_user=oracle
oracle_user_password=oracle@123
echo "Create user and groups for Oracle Database service"
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
useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,racdba -d /opt/oracle $oracle_user
echo "Add oracle users to users and user groups"
echo "$oracle_user_password" | passwd --stdin $oracle_user
echo "create oracle directory"
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app
chmod -R 755 /u01
echo "Dependent environment installation"
yum install -y https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm
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 "install oracle"
yum install -y http://192.168.11.252:9999/ISO/oracle/oracle-database-ee-21c-1.0-1.ol8.x86_64.rpm
#download oracle and install oracle on the local yum
#yum localinstall /root/oracle-database-ee-21c-1.0-1.ol8.x86_64.rpm -y
echo "create listening port for Listener"
cat >>/etc/sysconfig/oracledb_orcl-21c.conf<<EOF
# change default settings if you need
# listening port for Listener
LISTENER_PORT=1521
# data location
ORACLE_DATA_LOCATION=/u01/app/oracle
# EM_EXPRESS_PORT: Oracle EM Express listener
# listening port for Enterprise Manager
EM_EXPRESS_PORT=5500
EOF
echo "create sample Database orcl"
sed -i 's#ORACLE_SID=ORCLCDB#ORACLE_SID=ORCL#' /etc/init.d/oracledb_ORCLCDB-21c
/etc/init.d/oracledb_ORCLCDB-21c configure
su - oracle << EOF
echo 'umask 022' >> ~/.bash_profile
echo 'export ORACLE_SID=ORCL' >> ~/.bash_profile
echo 'export ORACLE_BASE=/u01/app/oracle' >> ~/.bash_profile
echo 'export ORACLE_HOME=/opt/oracle/product/21c/dbhome_1' >> ~/.bash_profile
echo 'export PATH=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/oracle/product/21c/dbhome_1/bin' >> ~/.bash_profile
echo 'export CV_ASSUME_DISTID=RHEL8.0' >> ~/.bash_profile
echo 'export ORA_INVENTORY=/u01/app/oraInventory' >> ~/.bash_profile
echo 'export LD_LIBRARY_PATH=/opt/oracle/product/21c/dbhome_1/lib:/usr/lib' >> ~/.bash_profile
echo 'export DISPLAY=":0.0"' >> ~/.bash_profile
source ~/.bash_profile
EOF
echo "create sys system scott password"
su - oracle << EOF
sqlplus / as sysdba
alter user system identified by Ciasm123;
alter user sys identified by Ciasm123;
alter user scott account Ciasm123;
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;
EOF
echo "Set this parameter in root mode"
sed -i "s#ORCL:/opt/oracle/product/21c/dbhome_1:N#ORCL:/opt/oracle/product/21c/dbhome_1: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=/opt/oracle/product/21c/dbhome_1
Environment=ORACLE_SID=ORCL
ExecStart=/opt/oracle/product/21c/dbhome_1/bin/dbstart /opt/oracle/product/21c/dbhome_1
ExecStart=/opt/oracle/product/21c/dbhome_1/dbstart /opt/oracle/product/21c/dbhome_1
Restart=always
[Install]
WantedBy=multi-user.target
EOF
echo "The startup setting is set after startup"
systemctl daemon-reload && systemctl enable ORCL@oracledb
echo -e "\033[32mThe oralce Install Success...\033[0m"
else
echo -e "\033[31mThe oracle Install Failed...\033[0m"
exit 1
fi
else
echo -e "\033[33mThe oracle Install already...\033[0m"
fi
}
main (){
install_oracle
}
main
执行Oracle21c 一键安装,预计50分钟
- sh /oracle21C_install_rpm.sh 2>&1 | tee /var/log/oracle_install.log #日志输出参考
sh /oracle21C_install_rpm.sh
em 管理系统打开
- https://(servers hostname or IP address):5500/em
- sys/Ciasm123 em登录管理用户名密码
这是Enterprise Manager管理控制台
重启验证是否开机自启动oracle 数据库,监听,em
reboot
netstat -lntp