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 18:03] – andonovj | oracle_multitenant_overview [2021/11/13 21:51] (current) – andonovj | ||
---|---|---|---|
Line 11: | Line 11: | ||
* root container - Where the system data resides. Also you can choose if you want the UNDO tablespace in the root to be used for all PDBs, or each PDB to have its own undo, SYSTEM and SYSAUX tablespace, making it completely independent from the root container. | * root container - Where the system data resides. Also you can choose if you want the UNDO tablespace in the root to be used for all PDBs, or each PDB to have its own undo, SYSTEM and SYSAUX tablespace, making it completely independent from the root container. | ||
- | * | + | * 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. |
+ | |||
+ | ===== 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: | ||
+ | |||
+ | |||
+ | ==== Creation === | ||
+ | Actually, the creation of a normal database isn't that hard, you can just type: | ||
+ | |||
+ | < | ||
+ | SQL> Create database; | ||
+ | </ | ||
+ | |||
+ | Simply that, will create us a normal database, well after that you will have to run the catproc and the catalog scripts, but you get the gist. | ||
+ | |||
+ | |||
+ | ==== Create container DB ===== | ||
+ | To create a container, database we NEED to allow it to have PLUGGABLE databases, as follows: | ||
+ | |||
+ | < | ||
+ | SQL> CREATE DATABASE CDB1 ENABLE PLUGGABLE DATABASE SEED FILE_NAME_CONVERT = ('/ | ||
+ | </ | ||
+ | |||
+ | That will create us a container database called CDB1 and a SEED, after that you will have to run script: | ||
+ | |||
+ | @$ORACLE_HOME/ | ||
+ | |||
+ | But other than that, all will be ok. | ||
+ | So we have a container, big deal, what then. | ||
+ | Well, now we can create PLUGGABLE databases as follows: | ||
+ | |||
+ | |||
+ | ==== Create Pluggable DB (PDB) ==== | ||
+ | As I said before, pluggable databases, are totally separate databases from one another. Imagine it having many databases (PDBs) within one big database (CDB). These PDBs, can have separate user totally individual from each other. So let's see how it is done: | ||
+ | |||
+ | |||
+ | < | ||
+ | CREATE PLUGGABLE DATABASE pdb2 ADMIN USER pdb_adm IDENTIFIED BY Password1 | ||
+ | FILE_NAME_CONVERT=('/ | ||
+ | </ | ||
+ | |||
+ | You can use either: | ||
+ | |||
+ | * FILE_NAME_CONVERT, | ||
+ | * CREATE_FILE_DEST, | ||
+ | * PDB_FILE_NAME_CONVERT | ||
+ | |||
+ | Either in the session level or on the CREATE statement, up to you, the result will be the same. | ||
+ | |||
+ | Once created, you can list all PDBs in a certain CDB as follows: | ||
+ | |||
+ | < | ||
+ | COLUMN pdb_name FORMAT A20 | ||
+ | |||
+ | SELECT pdb_name, status | ||
+ | FROM | ||
+ | ORDER BY pdb_name; | ||
+ | |||
+ | PDB_NAME | ||
+ | -------------------- ------------- | ||
+ | PDB$SEED | ||
+ | PDB1 | ||
+ | PDB2 | ||
+ | PDB3 | ||
+ | |||
+ | COLUMN name FORMAT A20 | ||
+ | |||
+ | SELECT name, open_mode | ||
+ | FROM | ||
+ | ORDER BY name; | ||
+ | |||
+ | NAME | ||
+ | ------------------------------ ---------- | ||
+ | PDB$SEED | ||
+ | PDB1 | ||
+ | PDB2 | ||
+ | PDB3 | ||
+ | |||
+ | </ | ||
+ | |||
+ | Remember, 1 PDB can be in only 1 ROOT$CDB, but 1 CDB can have many PDBs. | ||
+ | Furthermore, | ||
+ | |||
+ | ===== Using DBCA ===== | ||
+ | We can use DBCA to create and delete CDB and PDBs as follows: | ||
+ | |||
+ | < | ||
+ | # Local container (cdb1). | ||
+ | dbca -silent -createDatabase \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # Remote container (cdb3) with PDB (pdb5). | ||
+ | dbca -silent -createDatabase \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # Non-CDB instance (db12c). | ||
+ | dbca -silent -createDatabase \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # Delete the instances. | ||
+ | #dbca -silent -deleteDatabase -sourceDB cdb1 -sysDBAUserName sys -sysDBAPassword SysPassword1 | ||
+ | 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 ORACLE_SID=cdb3 | ||
+ | . oraenv | ||
+ | export ORAENV_ASK=YES | ||
+ | |||
+ | sqlplus / as sysdba << | ||
+ | |||
+ | ALTER SYSTEM SET db_create_file_dest = '/ | ||
+ | |||
+ | SHUTDOWN IMMEDIATE; | ||
+ | STARTUP MOUNT; | ||
+ | ALTER DATABASE ARCHIVELOG; | ||
+ | ALTER DATABASE OPEN; | ||
+ | |||
+ | ALTER PLUGGABLE DATABASE pdb5 OPEN; | ||
+ | ALTER PLUGGABLE DATABASE pdb5 SAVE STATE; | ||
+ | |||
+ | EXIT; | ||
+ | EOF | ||
+ | </ | ||
+ | |||
+ | ===== Automation ===== | ||
+ | Using the awesome power, vested to me by Vagrant and Bash, I summon the automation of: | ||
+ | |||
+ | * Virtual Machine | ||
+ | * Oracle 19c database | ||
+ | * 1 CDB | ||
+ | * 1 PDB | ||
+ | |||
+ | All that, twice: | ||
+ | |||
+ | |||
+ | < | ||
+ | $allow_shell = << | ||
+ | sed -i ' | ||
+ | systemctl restart sshd.service | ||
+ | SCRIPT | ||
+ | |||
+ | $edit_hosts_file = << | ||
+ | cat > /etc/hosts << | ||
+ | 127.0.0.1 localhost | ||
+ | 192.168.0.l03 lpar1.example.com | ||
+ | 192.168.0.l04 lpar2.example.com | ||
+ | EOF | ||
+ | SCRIPT | ||
+ | |||
+ | $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 | ||
+ | |||
+ | $install_oracle_19c = << | ||
+ | cd /vagrant | ||
+ | yum -y localinstall oracle-database-ee-19c-1.0-1.x86_64.rpm | ||
+ | |||
+ | SCRIPT | ||
+ | |||
+ | $install_19c_db = << | ||
+ | runuser -l oracle -c '/ | ||
+ | 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 | ||
+ | |||
+ | |||
+ | 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 :) |