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 数据库安装目录
- /etc/sysctl.d/50-oracle.conf 内核配置
- /etc/security/limits.d/50-oracle.conf 添加以下行来在文件中设置用户oracle的shell限制
- ~/.bash_profile 环境变量信息,目录
- oracle_SID: orcl #数据库名称
- /usr/oracle/database #oracle解压安装目录
- /u01/app/oraInventory 指定存放库存文件的位置
- /usr/oracle/database/runInstaller --help 获取安装参数的支持,版本不同参数不同
- root下切换oracle用户不需要输入密码,因为root是老大
- 监听端口 1521,监听文件位置/usr/oracle/database/netca.rsp
- characterSet 字符集 AL32UTF8 ,以下支持的字符集,可以根据实际需求更改
- 重启验证是否开机自启动oracle,开机稍微等待3分钟左右oralce 监听,库,em都会启动
- netstat -lntp 查看端口是否全部启动,1521,5500
- em https管理数据库https://YOU_IP:5500/em {用户名密码sys/Ciasm123}
- oracle_database 下载地址,以下是我自己内网的下载,官网下载需要oralce 账号,文档前有官方和百度云地址更改此处即可http://192.168.11.252:9999/ISO/oracle/LINUX.X64_213000_db_home.zip
- HFSHTTP 文件服务器,拉取发布软件到程序即可 dowload
vim /oracle21c_install.zip.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/05/29
# The oracle database is installed in zip mode
ORACLE_ORACLEHOME_CHECK=/u01/app/oracle/homes/OraDB21Home1
install_oracle (){
if [ ! -d $ORACLE_ORACLEHOME_CHECK ];then
if [ $? -eq 0 ];then
oracle_user=oracle
oracle_user_password=oracle@123
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
useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,racdba -d /usr/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 "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 "oracle environment variable"
su - oracle << EOF
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=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/oracle/database/bin' >> ~/.bash_profile
echo 'export CV_ASSUME_DISTID=RHEL8.0' >> ~/.bash_profile
echo 'export ORA_INVENTORY=/u01/app/oraInventory' >> ~/.bash_profile
echo 'export DISPLAY=":0.0"' >> ~/.bash_profile
source ~/.bash_profile
echo "download oracle"
mkdir -p /usr/oracle/database
wget -N -P /usr/oracle/database http://192.168.11.252:9999/ISO/oracle/LINUX.X64_213000_db_home.zip
chmod 777 /usr/oracle/database/LINUX.X64_213000_db_home.zip
unzip -q /usr/oracle/database/LINUX.X64_213000_db_home.zip -d /usr/oracle/database
echo "Install Oracle Database"
cd /usr/oracle/database
./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile /usr/oracle/database/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
ORACLE_HOME=/usr/oracle/database \
ORACLE_BASE=/u01/app/oracle \
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
EOF
echo "I got warnings about swap memory but it’s ignorebale error,you are asked to run two scripts as user root. Once it’s done binaries are installed"
sh /u01/app/oraInventory/orainstRoot.sh
sh /usr/oracle/database/root.sh
echo "creation netca.rsp"
su - oracle sh -c cat >>/usr/oracle/database/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"
su - oracle <<EOF
netca -silent -responsefile /usr/oracle/database/netca.rsp
echo "Login with Oracle user and Create Database with [dbca] command."
dbca -silent -createDatabase \
-databaseConfigType SINGLE \
-templateName General_Purpose.dbc \
-gdbname orcl.host \
-sid orcl \
-listeners LISTENER \
-responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword Ciasm123 \
-systemPassword Ciasm123 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName orclpdb \
-pdbAdminPassword Ciasm123 \
-databaseType MULTIPURPOSE \
-memoryPercentage 30 \
-storageType FS \
-datafileDestination "/u01/app/oracle/oradata/orcl" \
-emConfiguration DBEXPRESS \
-emExpressPort 5500
EOF
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
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.zip.sh 2>&1 | tee /var/log/oracle_install.log #日志输出参考
sh /oracle21c_install.zip.sh
em 管理系统打开
- https://(servers hostname or IP address):5500/em
- sys/Ciasm123 em登录管理用户名密码
这是Enterprise Manager管理控制台
重启验证是否开机自启动oracle 数据库,监听,em
reboot
netstat -lntp