Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Reduce Resource Consumption & Clone in Seconds your Oracle Virtual Environment on your Laptop using Linux Containers and BTRFS

847 views

Published on

UKOUG TECH14

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Reduce Resource Consumption & Clone in Seconds your Oracle Virtual Environment on your Laptop using Linux Containers and BTRFS

  1. 1. Reduce resource consumption and clone in seconds your oracle virtual environment on your laptop using linux containers and btrfs Bertrand Drouvot
  2. 2. About Me Oracle DBA since 1999 OCP 9i,10g,11g Rac certified Expert Exadata certified implementation specialist Blogger since 2012 @bertranddrouvot BasketBall fan
  3. 3. Will present Linux containers (LXC) btfrs FileSystem Use case to minimise resource consumption on your laptop From an oracle DBA point of view Use case 1: Clone a database software home to apply cpu october on it Use case 2: Clone a database to apply cpu october on it Use cases 1 and 2: Without and With LXC Use case 3: Clone a PDB Disable COW on a subvolume (Performance reason) and Snap it
  4. 4. Will not present In depth Linux containers (LXC) In depth btfrs FileSystem
  5. 5. LXC 1. Linux Containers (LXC) allow running multiple isolated Linux instances (containers) on the same host. 2. A way to isolate a group of processes from the others on a running Linux system. 3. Resource management and resource isolation features (Cgroups and name spaces). 4. Processes can have their own private view of the operating system with its own process ID (PID) space, file system structure and network interfaces.
  6. 6. LXC (http://www.oracle.com/technetwork/server-storage/ linux/technologies/oracle-linux-containers- 1898044.html)
  7. 7. btrfs 1. Supports large files and file systems. 2. Offers integrated volume management. 3. Has built-in RAID functionality. 4. Keeps data secure using copy-on-write (COW) and checksumming techniques. 5. Provides writable snapshots. 6.COW comes with some advantages, but can negatively affect performance with large files that have small random writes. It is recommended to disable COW for database files and virtual machine images.
  8. 8. Copy on write (COW) snapshot
  9. 9. How does it help? We can clone in seconds (and using few disk space): Linux containers Oracle software Oracle databases (Non CDB, CDB and PDB) Only on playground environment! (btrfs not officially supported by oracle see 236826.1& 1601759.1)
  10. 10. Let’s setup the VM, LXC and btrfs (1/7) Let’s create a OEL 6.5 virtual machine (named lxc) using virtualbox. This virtual machine will host our Linux containers, oracle software and databases Install lxc and btrfs into the virtual machine created previously
  11. 11. Let’s setup the VM, LXC and btrfs (2/7) Install a btrfs file system into the virtual machine (this file system will receive the oracle software and databases). To do so, add a disk to your virtualbox machine, start the machine and launch the fs creation:
  12. 12. Let’s setup the VM, LXC and btrfs (3/7) Add a btrfs file system into the virtual machine (this file system will receive the linux containers). To do so, add a disk to your virtualbox machine, start the machine and launch the fs creation:
  13. 13. Let’s setup the VM, LXC and btrfs (4/7) Create 2 btrfs subvolumes for the database software and databases:
  14. 14. Let’s setup the VM, LXC and btrfs (5/7) Add into /etc/hosts the machine (VM) name (LXC in our case):
  15. 15. Let’s setup the VM, LXC and btrfs (6/7) Install the 12cR1 database software with: Create a simple database with datafiles, redologs and controlfile located into the /btrfs/databases folder:
  16. 16. Let’s setup the VM, LXC and btrfs (7/7) Create a linux container (using oracle template) that will be the source of all our new containers: lxc-create --name cont_source -B btrfs --template oracle -- -- url http://public-yum.oracle.com -R 6.latest -r "perl sudo oracle-rdbms-server-12cR1-preinstall" Look at the “-B btrfs” argument to specify that the linux container is created on a BTRFS file system (and then would be able to use the snapshot capability during LXC clone creation).
  17. 17. Use case 1: clone db software + install CPU October Check FS size: btrfs filesystem df /btrfs Create a snapshot of the /btrfs/u01 subvolume: btrfs su snapshot /btrfs/u01 /btrfs/u01_patch Check FS size: btrfs filesystem df /btrfs Install CPU October 2014 Check FS size: btrfs filesystem df /btrfs
  18. 18. Use case 2: clone database + install CPU October Check FS size: btrfs filesystem df /btrfs Clone the database directory: btrfs su snapshot /btrfs/databases /btrfs/databases_patch Check FS size: btrfs filesystem df /btrfs Apply the CPU on the cloned database BDTDB_CPU: Check FS size: btrfs filesystem df /btrfs
  19. 19. Use cases 1 and 2: with LXC (1/4) Clone the cont_source linux container machine: lxc-clone -s -t btrfs -o cont_source -n cpu_oct Clone the database software: btrfs su snapshot /btrfs/u01 /btrfs/u01_cpu_oct Clone the database directory: btrfs su snapshot /btrfs/databases /btrfs/databases_cpu_oct Link the cloned subvolumes to the cloned linux container FS (so that everything match the source environment)
  20. 20. Use cases 1 and 2: with LXC (2/4) Copy oratab, oraenv, dbhome + create mount point directory into the linux container: cp -p /usr/local/bin/coraenv /usr/local/bin/dbhome /usr/local/bin/oraenv /container/cpu_oct/rootfs/usr/local/bin cp -p /etc/oratab /container/cpu_oct/rootfs/etc/ mkdir -p /container/cpu_oct/rootfs/btrfs/u01 mkdir -p /container/cpu_oct/rootfs/btrfs/databases mkdir -p /container/cpu_oct/rootfs/home/oracle/19121550 Start the cloned linux container: lxc-start -n cpu_oct
  21. 21. Use cases 1 and 2: with LXC (3/4) Patch de database software:
  22. 22. Use cases 1 and 2: with LXC (4/4) Patch the database:
  23. 23. With / without LXC comparison Software cloning: No need to create a new oratab entry with LXC (simply copy the oratab to the LXC directory). No need to update the cloned inventory. Database cloning: No need to create a new oratab entry with LXC (simply copy the oratab to the LXC directory). No need to recreate the control file of the duplicated database with LXC. The config file of the cloned LXC machine just need to ensure that the cloned subvolumes are mounted at the right location.
  24. 24. Use case 3: Duplicate a PDB Put PDB1 in read only mode alter pluggable database PDB1 open read only; Generate the PDB1 xml file alter session set container=PDB1; exec dbms_pdb.describe(pdb_descr_file=>’/home/oracle/pdb1.xml'); Create the btrfs clone btrfs su snapshot /btrfs/databases/oradata/BDTPDB/PDB1 /btrfs/databases/oradata/BDTPDB/PDB2 Create and open the PDB2 PDB create pluggable database PDB2 AS CLONE using '/home/oracle/pdb1.xml' source_file_name_convert=('/btrfs/databases/oradata/BDTPDB/PD B1','/btrfs/databases/oradata/BDTPDB/PDB2') nocopy tempfile reuse; alter pluggable database PDB2 open;
  25. 25. Disable COW on a subvolume (Performance reason) and Snap it (1/2) Create a new subvolume btrfs subvolume create /btrfs/databases_cowoff Disable COW and chown oracle:dba chattr +C /btrfs/databases_cowoff chown oracle:dba /btrfs/databases_cowoff Create a new database (not cloned) Check new database is not COW lsattr /btrfs/databases_cowoff/oradata/COWOFF/datafile/*
  26. 26. Disable COW on a subvolume (Performance reason) and Snap it (2/2) Create a snap btrfs su snapshot /btrfs/databases_cowoff /btrfs/databases_cowoff_snap Create a cloned database Check cloned database is not COW lsattr /btrfs/databases_cowoff_snap/oradata/COWOFF/datafile/*
  27. 27. Questions?

×