Skip to content

密码一览

  • linux密码

    • root:root
    • oracle:oracle
  • oracle密码

    • sys:orcl
    • system:orcl
    • pdbadmin:orcl

参考资料

截图将oracle放到oper组

安装

系统要求: 硬盘40G、内存8G

坑1

硬盘设置为40G

坑2

设置swap空间

坑3

安装完成之后sqlplus提示找不到

原因是cat配置环境变量时,美元号解析了,应该转义

坑4

kernel.shmall=...
kernel.shmmax=...
shmmax为实际内存大小
shmall为shmmax / 4k
4k为linux页大小
  1. 上传三个文件至 RHEL 7.9

存放至/tmp目录

  • compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

    下载地址https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/

  • LINUX.X64_193000_db_home.zip

  • oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

  1. 挂载本地仓库
bash
# 确认光盘已经插入
[root@rhel7 ~]# df -h

# 挂载光盘
[root@rhel7 ~]# mount -o ro /dev/sr0 /mnt

# 确认光盘已被挂载
[root@rhel7 ~]# ls /mnt

# 配置仓库
[root@rhel7 ~]# vim /etc/yum.repos.d/local.repo
[BaseOS]
name=BaseOS
baseurl=file:///mnt
enabled=1
gpgcheck=0
  1. 安装
  • rhel7.sh
bash
# 1. 安装依赖包
yum install -y binutils gcc gcc-c++  compat-libstdc++-33 glibc  glibc.i686  glibc-devel  ksh libgcc.i686   libstdc++-devel  libaio  libaio.i686  libaio-devel  libaio-devel.i686  libXtst  libXtst.i686  libX11  libX11.i686 libXau  libXau.i686  libxcb  libxcb.i686  libXi  libXi.i686  make  sysstat  compat-libcap1
yum -y localinstall /tmp/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

# 2. 配置交换空间大小
swapoff /dev/mapper/rhel-swap
##dd if=/dev/zero of=/dev/mapper/rhel-swap bs=1024 count=8388608
dd if=/dev/zero of=/swap bs=1G count=8
mkswap /swap
chmod 0600 /swap
sed -i "s#/dev/mapper/rhel-swap#/swap#g" /etc/fstab
swapon -a

# 3. 配置Linux系统参数
cat >> /etc/sysctl.conf << EOF
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 = 1048576
EOF

# 4. 用root用户执行sysctl -p 使修改生效。
sysctl -p

# 5. 设置 Oracle 用户的 Shell 限制
cat >> /etc/security/limits.conf << EOF
oracle  soft  nproc     2047
oracle  hard  nproc     16384
oracle  soft  nofile    1024
oracle  hard  nofile    65536
oracle  soft  stack     10240
oracle  hard  stack     32768
oracle  soft  memlock   3145728
oracle  hard  memlock   3145728
EOF

# 6. 设置PAM
cat >> /etc/pam.d/login << EOF
session required pam_limits.so
EOF

# 7. 关闭防火墙/SELINUX
systemctl stop firewalld
systemctl disable firewalld
sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config
setenforce 0

# 8. 创建用户和组
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
useradd -u 54321 -g oinstall -G dba,oper oracle
echo "oracle" | passwd --stdin oracle

# 9. 创建目录
mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01/

# 10. 设置环境变量
cat >> /home/oracle/.bash_profile << EOF
ORACLE_SID=orcl;export ORACLE_SID  
ORACLE_UNQNAME=orcl;export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/19.3.0/dbhome_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
export NLS_LANG=AMERICAN_AMERICA.UTF8
TNS_ADMIN=\$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=\$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:\${JAVA_HOME}/bin:\${PATH}:\$HOME/bin:\$ORACLE_HOME/bin:\$ORA_CRS_HOME/bin
PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=\$ORACLE_HOME/lib
LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:\$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=\$ORACLE_HOME/JRE
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
EOF

# 11. 安装数据库软件
yum install -y libXp* libXt* libXtst libXrender-0.9.10
yum localinstall -y /tmp/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
chown oracle:oinstall /tmp/LINUX.X64_193000_db_home.zip
su - oracle -c "unzip -d /u01/app/oracle/product/19.3.0/dbhome_1/ /tmp/LINUX.X64_193000_db_home.zip"

在图形化界面中,切换Oracle登录

bash
# 装Oracle 19c数据库软件
su - oracle -c "source ~/.bash_profile"
/u01/app/oracle/product/19.3.0/dbhome_1/runInstaller

做个快照

示例用户安装

bash
sqlplus / as sysdba

SQL> startup open;
SQL> show con_name
SQL> show pdbs
SQL> alter session set container=ORCLPDB;
SQL> @?/demo/schema/human_resources/hr_main.sql

specify password for HR as parameter 1:
Enter value for 1: hr

specify default tablespeace for HR as parameter 2:
Enter value for 2: users

specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp

specify log path as parameter 4:
Enter value for 4: /tmp

查看hr有哪些表

bash
SELECT TABLE_NAME FROM DBA_TABLES WHERE OWNER='HR';

tns(netca)网络配置

执行netca命令

  • Choose the configuration you would like to do:

    • Local Net Service Name configuration
  • Select what you want to do:

    • Add
  • Service Name

    • orclpdb
  • Select protocols

    • TCP
  • TCP/IP Protocol

    • localhost
    • Use the standard port number of 1521
  • Connecting

    • username: system
    • password: orcl
  • Test

    • Yes, perform a test
  • Net Service Name

    • orclpdb
bash
netca

控制台以hr身份登录

bash
sqlplus hr/hr@orclpdb

sqlplus以hr身份登录

bash
conn hr/hr@orclpdb;

----

RHEL 7.9 安装

注意

两张网卡,需要做相同配置

  1. 开启网卡

  2. 勾选可用时自动链接到这个网络

RHEL 7.9 初次启动

VirtualBox Guest Additions 插件安装

做个快照

关机后创建 RHEL 7.9 快照

安装Oracle 19c

Oracle网络配置