Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
oracle_multitenant_overview [2021/11/11 20:49] – andonovj | oracle_multitenant_overview [2021/11/13 21:51] (current) – andonovj | ||
---|---|---|---|
Line 13: | Line 13: | ||
* Application Container - Container which consist of 1 or many PDBs which host a specific application. We are able to assign versions and name to such container, furthermore we can initiate installation and upgrade modes. | * Application Container - Container which consist of 1 or many PDBs which host a specific application. We are able to assign versions and name to such container, furthermore we can initiate installation and upgrade modes. | ||
- | =====Creation===== | + | ===== Using SQL ===== |
Firstly, we need to create our container. From 12c, we can create a database to be either as it always has been, a normal database, OR we can create it to allow other databases as well. So it will be a container, let's see how we can do both: | Firstly, we need to create our container. From 12c, we can create a database to be either as it always has been, a normal database, OR we can create it to allow other databases as well. So it will be a container, let's see how we can do both: | ||
- | ==== Create Normal DB === | + | ==== Creation |
Actually, the creation of a normal database isn't that hard, you can just type: | Actually, the creation of a normal database isn't that hard, you can just type: | ||
Line 94: | Line 94: | ||
Furthermore, | Furthermore, | ||
- | ===== Management | + | ===== Using DBCA ===== |
- | We can perform several actions with a PDB: | + | We can use DBCA to create and delete CDB and PDBs as follows: |
- | * OPEN | + | < |
- | * Plug & Unplig | + | # Local container (cdb1). |
- | * Close | + | dbca -silent -createDatabase \ |
- | * Restore | + | -templateName General_Purpose.dbc \ |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | ==== Open ==== | + | # Remote container (cdb3) with PDB (pdb5). |
- | After we create a CDB, we need to open it, as follows: | + | dbca -silent -createDatabase \ |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | -ignorePreReqs | ||
- | < | + | # Non-CDB instance (db12c). |
- | SQL> ALTER PLUGGABLE DATABASE pdb2 OPEN; | + | dbca -silent -createDatabase \ |
- | </ | + | -templateName General_Purpose.dbc \ |
- | + | -gdbname db12c -sid db12c -responseFile NO_VALUE \ | |
- | That command, will open us a database and it will become available to the users. | + | -characterSet AL32UTF8 \ |
- | We can also close a pluggable database as follows: | + | -sysPassword SysPassword1 \ |
- | + | -systemPassword SysPassword1 \ | |
- | < | + | -createAsContainerDatabase false \ |
- | ALTER PLUGGABLE DATABASE pdb2 CLOSE; | + | -databaseType MULTIPURPOSE \ |
- | </Code> | + | -memoryMgmtType auto_sga \ |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | ==== Unplug a PDB ==== | + | # Delete |
- | In 12.1 we could unplug a PDB into .xml file and the migration of the PDB, would be the migration of that XML file AND the relevant database files. | + | #dbca -silent -deleteDatabase -sourceDB cdb1 -sysDBAUserName sys -sysDBAPassword SysPassword1 |
- | From 12.2 we can also unplug the PDB into a .pdb archive file, which contains information about the PDB AND the relevant database files. That will ease our migration. | + | dbca -silent -deleteDatabase -sourceDB cdb3 -sysDBAUserName sys -sysDBAPassword SysPassword1 |
+ | dbca -silent -deleteDatabase -sourceDB db12c -sysDBAUserName sys -sysDBAPassword SysPassword1 | ||
- | < | + | #Configure OMF |
export ORAENV_ASK=NO | export ORAENV_ASK=NO | ||
export ORACLE_SID=cdb3 | export ORACLE_SID=cdb3 | ||
Line 126: | Line 169: | ||
export ORAENV_ASK=YES | export ORAENV_ASK=YES | ||
- | sqlplus / as sysdba | + | sqlplus / as sysdba <<EOF |
- | ALTER PLUGGABLE DATABASE pdb5 CLOSE; | + | |
- | ALTER PLUGGABLE DATABASE pdb5 UNPLUG INTO '/ | + | |
- | </Code> | + | |
- | That assumes, you are using OMF file. The resulting file contains all the necessary data: | + | ALTER SYSTEM SET db_create_file_dest = '/ |
- | < | + | SHUTDOWN IMMEDIATE; |
- | HOST ls -al / | + | STARTUP MOUNT; |
- | -rw-r--r--. 1 oracle oinstall 161702502 Jan 7 21:01 / | + | ALTER DATABASE ARCHIVELOG; |
+ | ALTER DATABASE OPEN; | ||
- | SQL> | + | ALTER PLUGGABLE DATABASE pdb5 OPEN; |
+ | ALTER PLUGGABLE DATABASE pdb5 SAVE STATE; | ||
+ | |||
+ | EXIT; | ||
+ | EOF | ||
</ | </ | ||
- | ====Plug a PDB==== | + | ===== Automation ===== |
- | To plug a database, we need the file from above and we need to verify | + | Using the awesome power, vested to me by Vagrant |
- | < | + | |
- | SET SERVEROUTPUT ON | + | |
- | DECLARE | + | |
- | l_result BOOLEAN; | + | |
- | BEGIN | + | |
- | l_result := DBMS_PDB.check_plug_compatibility( | + | |
- | pdb_descr_file => '/ | + | |
- | pdb_name | + | |
- | | + | |
- | | + | * Oracle 19c database |
- | | + | |
- | DBMS_OUTPUT.PUT_LINE(' | + | |
- | | + | |
- | END; | + | |
- | / | + | |
- | compatible | + | |
- | PL/SQL procedure successfully completed. | + | All that, twice: |
- | SQL> | ||
- | </ | ||
- | === Create a PDB using the source file === | + | < |
- | Then we can create a PDB using the .pdb file as follows: | + | $allow_shell |
+ | sed -i ' | ||
+ | systemctl restart sshd.service | ||
+ | SCRIPT | ||
- | <Code: | + | $edit_hosts_file = <<SCRIPT |
- | CREATE PLUGGABLE DATABASE pdb5 USING '/u01/pdb5.pdb'; | + | cat > /etc/hosts << |
+ | 127.0.0.1 localhost | ||
+ | 192.168.0.l03 lpar1.example.com | ||
+ | 192.168.0.l04 lpar2.example.com | ||
+ | EOF | ||
+ | SCRIPT | ||
- | ALTER PLUGGABLE DATABASE pdb5 OPEN READ WRITE; | + | $install_oracle_preinstall = << |
+ | curl -o oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm https:// | ||
+ | yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm | ||
+ | SCRIPT | ||
- | SELECT name, open_mode | + | $install_oracle_19c = << |
- | FROM v$pdbs | + | cd /vagrant |
- | ORDER BY name; | + | yum -y localinstall oracle-database-ee-19c-1.0-1.x86_64.rpm |
- | NAME | + | SCRIPT |
- | ------------------------------ ---------- | + | |
- | PDB$SEED | + | $install_19c_db = << |
- | PDB5 | + | runuser |
+ | SCRIPT | ||
+ | |||
+ | $install_vnc_server = << | ||
+ | yum -y install vnc-server | ||
+ | yum -y install tigervnc-server | ||
+ | yum -y install xterm | ||
+ | yum -y install net-tools | ||
+ | yum -y install unzip | ||
+ | yum -y install curl | ||
+ | SCRIPT | ||
- | SQL> | + | |
+ | Vagrant.configure(" | ||
+ | | ||
+ | config.vm.provision :shell, inline: " | ||
+ | config.vm.define " | ||
+ | lpar.vm.box = " | ||
+ | lpar.vm.hostname = " | ||
+ | lpar.vm.synced_folder " | ||
+ | lpar.vm.network " | ||
+ | lpar.vm.network " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provision " | ||
+ | lpar.vm.provider :virtualbox do |v| | ||
+ | v.customize [" | ||
+ | v.customize [" | ||
+ | v.customize [" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
</ | </ | ||
+ | |||
+ | |||
+ | Just make sure, you have the Oracle 19c RPM in folder called: " | ||
+ | |||
+ | < | ||
+ | responseFileVersion=/ | ||
+ | gdbName=orcl.example.com | ||
+ | sid=orcl | ||
+ | databaseConfigType=SI | ||
+ | policyManaged=false | ||
+ | createServerPool=false | ||
+ | force=false | ||
+ | createAsContainerDatabase=true | ||
+ | numberOfPDBs=1 | ||
+ | pdbName=pdb1 | ||
+ | useLocalUndoForPDBs=true | ||
+ | pdbAdminPassword=Oracle123 | ||
+ | templateName=/ | ||
+ | sysPassword=Oracle123 | ||
+ | systemPassword= Oracle123 | ||
+ | emExpressPort=0 | ||
+ | runCVUChecks=FALSE | ||
+ | dvConfiguration=false | ||
+ | olsConfiguration=false | ||
+ | datafileJarLocation={ORACLE_HOME}/ | ||
+ | datafileDestination={ORACLE_BASE}/ | ||
+ | recoveryAreaDestination={ORACLE_BASE}/ | ||
+ | storageType=FS | ||
+ | characterSet=AL32UTF8 | ||
+ | registerWithDirService=false | ||
+ | variables=ORACLE_BASE_HOME=/ | ||
+ | initParams=undo_tablespace=UNDOTBS1, | ||
+ | sampleSchema=false | ||
+ | memoryPercentage=40 | ||
+ | databaseType=MULTIPURPOSE | ||
+ | automaticMemoryManagement=true | ||
+ | totalMemory=0 | ||
+ | </ | ||
+ | |||
+ | Of course feel free to add / remove or modify any parameter which you wish. Just bare in mind that some are mandatory :) |