El espacio del portátil es un poco reducido, porque la máquina virtual de la base de datos se vuelve más grande debido a los experimentos y, a veces, los apagados anormales conducen a instantáneas de máquinas virtuales heredadas. El entorno experimental de la base de datos Oracle 21c se regeneró hoy.
Proceso de instalación
- Destruya la máquina virtual existente.
vagrant destroy
- Limpiar el directorio de la máquina virtual en VirtualBox
Si es normal, el directorio de la máquina virtual se eliminará en el paso anterior. Pero como dejé la instantánea de la máquina virtual antes, necesito eliminar manualmente el directorio.
Snapshot:2023-02-07T09-21-27-134096000Z.sav 429MB
- Descargue la versión correspondiente del software de la base de datos en el directorio del proyecto vagabundo correspondiente.
Este ejemplo es vagrant-projects\OracleDatabase\21.3.0, el software de la base de datos es LINUX.X64_213000_db_home.zip y el tamaño es de 3 GB. - Tenga en cuenta el espacio en disco actual: 64,8 GB disponibles, incluido el software de base de datos descargado.
- Inicie la instalación. Todo el proceso tomó 18 minutos.
time vagrant up
Aquí está el registro de instalación con cabeza y cola:
Bringing machine 'oracle-21c-vagrant' up with 'virtualbox' provider...
==> oracle-21c-vagrant: Importing base box 'oraclelinux/8'...
==> oracle-21c-vagrant: Matching MAC address for NAT networking...
==> oracle-21c-vagrant: Checking if box 'oraclelinux/8' version '8.7.411' is up to date...
==> oracle-21c-vagrant: Setting the name of the VM: oracle-21c-vagrant
==> oracle-21c-vagrant: Clearing any previously set network interfaces...
==> oracle-21c-vagrant: Preparing network interfaces based on configuration...
oracle-21c-vagrant: Adapter 1: nat
==> oracle-21c-vagrant: Forwarding ports...
oracle-21c-vagrant: 1521 (guest) => 1521 (host) (adapter 1)
oracle-21c-vagrant: 5500 (guest) => 5500 (host) (adapter 1)
oracle-21c-vagrant: 22 (guest) => 2222 (host) (adapter 1)
==> oracle-21c-vagrant: Running 'pre-boot' VM customizations...
==> oracle-21c-vagrant: Booting VM...
==> oracle-21c-vagrant: Waiting for machine to boot. This may take a few minutes...
oracle-21c-vagrant: SSH address: 127.0.0.1:2222
oracle-21c-vagrant: SSH username: vagrant
oracle-21c-vagrant: SSH auth method: private key
oracle-21c-vagrant:
oracle-21c-vagrant: Vagrant insecure key detected. Vagrant will automatically replace
oracle-21c-vagrant: this with a newly generated keypair for better security.
oracle-21c-vagrant:
oracle-21c-vagrant: Inserting generated public key within guest...
oracle-21c-vagrant: Removing insecure key from the guest if it's present...
oracle-21c-vagrant: Key inserted! Disconnecting and reconnecting using new SSH key...
==> oracle-21c-vagrant: Machine booted and ready!
==> oracle-21c-vagrant: Checking for guest additions in VM...
==> oracle-21c-vagrant: Setting hostname...
==> oracle-21c-vagrant: Mounting shared folders...
oracle-21c-vagrant: /vagrant => C:/Users/XiaoYu/Desktop/WORKSPACE/vagrant-projects/OracleDatabase/21.3.0
==> oracle-21c-vagrant: Running provisioner: shell...
oracle-21c-vagrant: Running: C:/Users/XiaoYu/AppData/Local/Temp/vagrant-shell20230301-4796-6x5wqm.sh
oracle-21c-vagrant: INSTALLER: Started up
...
...
oracle-21c-vagrant: SQL> Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
oracle-21c-vagrant: Version 21.3.0.0.0
oracle-21c-vagrant: INSTALLER: Database created
oracle-21c-vagrant: INSTALLER: Oratab configured
oracle-21c-vagrant: Created symlink /etc/systemd/system/multi-user.target.wants/oracle-rdbms.service → /etc/systemd/system/oracle-rdbms.service.
oracle-21c-vagrant: INSTALLER: Created and enabled oracle-rdbms systemd's service
oracle-21c-vagrant: INSTALLER: setPassword.sh file setup
oracle-21c-vagrant: INSTALLER: Running user-defined post-setup scripts
oracle-21c-vagrant: INSTALLER: Done running user-defined post-setup scripts
oracle-21c-vagrant: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: 6j44mKUS4LA=1
oracle-21c-vagrant: INSTALLER: Installation complete, database ready to use!
real 18m10.535s
user 0m0.015s
sys 0m0.031s
Esta es la parte que consume más tiempo de todo el proceso de instalación, y el tiempo depende principalmente de la velocidad de la red (porque se requiere una actualización de Yum) y la E/S del disco (porque es necesario copiar y descomprimir los medios de la base de datos).
- Registre el espacio restante
En este momento, el espacio restante en el disco es de 49,5 GB y, después de eliminar el software de la base de datos, el espacio restante es de 52,4 GB. - Modifique las contraseñas del sistema y del sistema.
La última parte del registro de instalación muestra la contraseña de administrador establecida aleatoriamente. Si no la registró en ese momento, también puede cambiarla:
cd ~oracle
./setPassword.sh Welcome1
- Instale git, el esquema de muestra de Oracle y otro software.
- Deshabilitar archivado (predeterminado), deshabilitar papelera de reciclaje
ALTER SYSTEM SET recyclebin = OFF SCOPE = SPFILE;
STARTUP FORCE;
- Calcular el espacio necesario para la instalación.
Actualmente, el disco tiene 49,3 GB disponibles, en comparación con los 64,8 GB originales, y la instalación completa consume 15,5 GB de espacio:
$ bc <<< "64.8 - 49.3"
15.5
- Configure el entorno de la base de datos
Lo siguiente es ~/.bash_profile:
export SYSPWD='Welcome1'
export USERPWD='Welcome1'
export PDB=PDB1
alias sqlplus='rlwrap sqlplus'
alias sys='sqlplus sys/${SYSPWD}@$PDB as sysdba'
alias eoda='sqlplus eoda/foo@$PDB'
alias scott='sqlplus scott/tiger@$PDB'
export ORACLE_PATH=/home/oracle
El siguiente es ~/login.sql:
define _editor=vi
set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 100
set pagesize 9999
column plan_plus_exp format a80
set sqlprompt '&_user.@&_connect_identifier.> '
Mira el efecto:
$ eoda
SQL*Plus: Release 21.0.0.0.0 - Production on Wed Mar 1 13:50:45 2023
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Last Successful login time: Wed Mar 01 2023 13:12:41 +08:00
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
EODA@ORCLPDB1> connect / as sysdba
Connected.
SYS@ORCLCDB> exit
Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
Puede ver que la versión de la base de datos recién instalada es 21.3.0.
- Cierra la máquina virtual de la base de datos
vagrant halt
- Inicie la máquina virtual de la base de datos
vagrant up
manejo de errores
Al abrir la máquina virtual de la base de datos, encontré el siguiente error:
Bringing machine 'oracle-21c-vagrant' up with 'virtualbox' provider...
==> oracle-21c-vagrant: Checking if box 'oraclelinux/8' version '8.7.411' is up to date...
==> oracle-21c-vagrant: Clearing any previously set forwarded ports...
==> oracle-21c-vagrant: Clearing any previously set network interfaces...
==> oracle-21c-vagrant: Preparing network interfaces based on configuration...
oracle-21c-vagrant: Adapter 1: nat
==> oracle-21c-vagrant: Forwarding ports...
oracle-21c-vagrant: 1521 (guest) => 1521 (host) (adapter 1)
oracle-21c-vagrant: 5500 (guest) => 5500 (host) (adapter 1)
oracle-21c-vagrant: 22 (guest) => 2222 (host) (adapter 1)
==> oracle-21c-vagrant: Running 'pre-boot' VM customizations...
==> oracle-21c-vagrant: Booting VM...
==> oracle-21c-vagrant: Waiting for machine to boot. This may take a few minutes...
oracle-21c-vagrant: SSH address: 127.0.0.1:2222
oracle-21c-vagrant: SSH username: vagrant
oracle-21c-vagrant: SSH auth method: private key
==> oracle-21c-vagrant: Machine booted and ready!
==> oracle-21c-vagrant: Checking for guest additions in VM...
==> oracle-21c-vagrant: Setting hostname...
==> oracle-21c-vagrant: Mounting shared folders...
oracle-21c-vagrant: /vagrant => C:/Users/XiaoYu/Desktop/WORKSPACE/vagrant-projects/OracleDatabase/21.3.0
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
: No such device
De hecho, no hay ningún problema serio, pero el directorio compartido no se puede usar para transferir archivos entre la máquina virtual y el host.
El motivo del problema es que la versión de VirtualBox GuestAddition no es la última, solo modifíquela de acuerdo a este artículo .
Comandos comunes vagabundos
La ayuda es la siguiente:
$ vagrant --help
Usage: vagrant [options] <command> [<args>]
-h, --help Print this help.
Common commands:
autocomplete manages autocomplete installation on host
box manages boxes: installation, removal, etc.
cloud manages everything related to Vagrant Cloud
destroy stops and deletes all traces of the vagrant machine
global-status outputs status Vagrant environments for this user
halt stops the vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a Vagrantfile
login
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
port displays information about guest port mappings
powershell connects to machine via powershell remoting
provision provisions the vagrant machine
push deploys code in this environment to a configured destination
putty
rdp connects to machine via RDP
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
serve start Vagrant server
snapshot manages snapshots: saving, restoring, etc.
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment
upload upload to machine via communicator
validate validates the Vagrantfile
version prints current and latest Vagrant version
winrm executes commands on a machine via WinRM
winrm-config outputs WinRM configuration to connect to the machine
For help on any individual command run `vagrant COMMAND -h`
Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
--[no-]color Enable or disable color output
--machine-readable Enable machine readable output
-v, --version Display Vagrant version
--debug Enable debug output
--timestamp Enable timestamps on log output
--debug-timestamp Enable debug output with timestamps
--no-tty Enable non-interactive output
Algunos de uso común:
## 启动虚机
vagrant up
## 登录虚机
vagrant putty 或 vagrant ssh
## 关闭虚机
vagrant halt
## 重启虚机
vagrant reload
## 查看虚机状态
vagrant status
## 摧毁虚机,慎用
vagrant destroy