VirtualBox Oracle Scratchpad

Getting shared folders and all that jazz is pretty important if you're going to be using virtualbox reguarly.  These are my EXTREMLY rough notes on this so far.  Expect this to be changed and cleaned up.

------------------------

Installed fedora so my dev env would be similar to our RHEL env.

the oracle install needs over 500 MB in /tmp, this apparantly is calculated from the amount of memory you have 1024 mb of membory = 500 /tmp

user this command to make it through the install

sudo mount -o remount,size=40M tmpfs /tmp/

. To easily share folders between the systems install guest additions.  yum is suppsoed to have this, but a search didn't show much.  from the virtualbox menubar select "insert guest additions cd".  now open up the file browser and run the cd.  if you didn't install fedora with development tools installed you'll get an error message.  read it carefully and install the proper development packages.  

yum -y install kernel-devel kernel-headers dkms gcc gcc-c++
yum install -y kernel-devel-4.2.3-300.fc23.x86_64  //this one the script complained about specifically

 

devices>shared folders add a folder form your hd.  for your account to be able to read from this folder you need to be a member of the vboxsf account which got added during the vbox installed.  

usermod -a -G vboxsf john

groups // to list your current groups

and if you're in a gui mode, you need to log out then log back in.  folders mounted to /media

 

 

omg, more complaining, random errors all over the place, going to try this with centos installation using the knowledge from above...

in settings of the box add bidirecitonal copy option to copy back and forth

 

 

-----

getting oracle database installed.  there's a 2 day quickstart, also a specific install manul.  getting it installed is not a simple task.  recommend using an older version of a supported os (rhel is supported i'm using centos), and an older version of the db.  less compatibility issues.  there are lots of reqs around amount of memory and swap space, even the /tmp directory needs to be big enough.  it's all a major pain in the ass to get right.  recommend just plowing through it and getting all of those resolved, otherwise at the end of the intall it will complain, and might not work.  be gernrous when allocating memory for a virtual machine...

used yum to install pack reqs, then used this guide to increase my swap space.

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-swap-adding.html

also, if you don't go down the list and install all the necessary software, you're going to have a bad time.  i did it like this

yum list installed | grep <thing>
yum search <thing>yum install -y <thing>

over and over and over...

got it installed without any errors, it says visit localhost:1158/em but that is down

emctl start dbconsole
emctl stop dbconsole

none of that will likelye work since env variable dont seem to get properly even when you follow the instructions.

docs will tell you to run a progam called "dbca", run through this to create a "database" not a schema.  if you did the desktop install then it will automatically be run at the end...

if you screwed something up you can do this to list the "listeners", or SID in oracle terms (the databse is the software itself in /app).

lsnrctl status

sqlplus SYSTEM/asdf1234@localhost/jmdb2

create a tablespace and user.

CREATE TABLESPACE SHOPPING_MALL DATAFILE 'SHOPPING_MALL.dbf' size 1024M AUTOEXTEND ON NEXT 500K; 

CREATE USER JOHNNY IDENTIFIED BY P#SSW#RD DEFAULT TABLESPACE SHOPPING_MALL;
GRANT CONNECT, RESOURCE, CREATE SESSION to JOHNNY;
GRANT CREATE DATABASE LINK to JOHNNY; 

then i used sql developer to export and import the entire database on the host machine... google for this. 

--

ok at this point i need an ip to connect to on the client machine.  virtualbox should have setup a "host-only network".  all clients you setup through virtualbox should be able to connect to this.  vitrualbox > preferences> network> host only networks.

edit settings of your shutdown client in virtualbox > network > enable network adapter (a new one)>  host-only adapter> the name of the "host-only network" as we saw above.  start the machie, give it the static ip on the network specified above. 

start that machine, ifconfig to see the new interface (it will not have an ip at this point).  ok so now let's configure it.

$ cat /etc/sysconfig/network-scripts/ifcfg-eth1 
DEVICE=eth1 
BOOTPROTO=static 
ONBOOT=yes 
IPADDR=192.168.33.10
NETMASK=255.255.255.0 
 

make sure the sshd service is up and running

service sshd status
service sshd start
chkconfig sshd on

also disable the firewall

service iptables status
service iptables stop
chkconfig iptables off

Hmm, now I don't have an internet connection.  Ok, let's setup that NAT interface (as seen in virtualbox ui the image> settings> network and appearing as eth0 in the client when running ifconfig).

# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0 
TYPE=Ethernet 
ONBOOT=yes 
NM_CONTROLLED=yes 
BOOTPROTO=dhcp 
DNS2=8.8.8.8 
DNS1=8.8.8.8 
USERCTL=no 
PEERDNS=yes 
IPV6INIT=no

----

fyi, you can see oracle listens on 1521, there is a listener program for that.  this output might be useful in the future.

# netstat -tulpen | grep 1521
tcp        0      0 :::1521                     :::*                        LISTEN      500        23884      2971/tnslsnr        
# ps -aux | grep 2971
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
john      2971  0.0  0.5 212704 12444 ?        Ssl  11:51   0:00 /home/john/app/john/product/11.2.0/dbhome_2/bin/tnslsnr LISTENER -inherit
root      3079  0.0  0.0 103312   864 pts/0    S+   11:57   0:00 grep 2971

-----------

ok, so at this point i went back and installed oracle 12c, used yum to search and install the pre install packages for oracle, had to setup epel repo,there was a bug with that, it needed some kind of key in /etc/asldkfjal-oracle, ran through oracle 12c installation, it said it was missing libjvm12 or something, i found a post about that as well saying copy this libasdfasd.a file to asldfkjalsdf. did that and made it through the installation. 

was able to view the db through localhost:5500/em, created a new table and connected to it. 

wasn't able to connect any of the command line tools, looked at documentation for env variables that need to be setup before connecting to a db here.  you just need ORACLE_HOME and ORACLE_SID.

also don't forget to setup your java home.

#oracle stuff (12c)
export ORACLE_HOME=/home/john/app/john/product/12.1.0/dbhome_1
export ORACLE_SID=jmdb4
export PATH=$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0

to get oracle to start again... make sure env vars are set and lsnrctl status, lsnrctl start, then..

sqlplus "system as sysdba"

STARTUP

Now you should be able to connect to that SID

sqlplus SYSTEM/asdf1234@localhost/jmdb4


you can also automate startup with this automating-database-startup-and-shutdown-on-linux

-------------------

some serious pain in the ass work getting network setup how i wanted...  this is how it eventually ended up working

set first adapter in image setting to host-adapter.  this thing gives me a static ip to always access the machine with.  check your "host adapter" address in the virtualbox overall settings.

set second adapter to NAT.  this guy will basically just piggy back off "whatever" internet connection your host machine has.  apparantly this had to be the second adapter, if set to the first one... then issues as described here... also this didn't work till i set the HWADDR var (get that from ifconfig)

the last one is set to get an ip address of its own from whatever network you're on.  home router or work.  en0 on my mac (whatever that is, will it get a wifi address or a ethernet address if i'm plugged in?).  hmm, i am at home and i do have a network address from my home network. at the office it had an address from my ethernet adatper. 

[root@ec2-52-4-179-143 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.33.10
NETMASK=255.255.255.0
NETWORKDELAY=3
[root@ec2-52-4-179-143 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:49:00:4D
[root@ec2-52-4-179-143 network-scripts]# cat ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=dhcp

Here is what ifconfig looked like at the end of this ordeal.....

 eth0      Link encap:Ethernet  HWaddr 08:00:27:0C:CD:A6  
inet addr:192.168.33.10 Bcast:192.168.33.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe0c:cda6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:80 errors:0 dropped:0 overruns:0 frame:0
TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10253 (10.0 KiB) TX bytes:14726 (14.3 KiB)

eth1 Link encap:Ethernet HWaddr 08:00:27:49:00:4D
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe49:4d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5475 errors:0 dropped:0 overruns:0 frame:0
TX packets:5068 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2638522 (2.5 MiB) TX bytes:559935 (546.8 KiB)

eth2 Link encap:Ethernet HWaddr 08:00:27:9A:75:14
inet6 addr: 2602:306:cfae:fd40:a00:27ff:fe9a:7514/64 Scope:Global
inet6 addr: fe80::a00:27ff:fe9a:7514/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1023 errors:0 dropped:0 overruns:0 frame:0
TX packets:573 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:223719 (218.4 KiB) TX bytes:81437 (79.5 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:488 errors:0 dropped:0 overruns:0 frame:0
TX packets:488 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:44240 (43.2 KiB) TX bytes:44240 (43.2 KiB)

-------

fyi had trouble importing my exported sql, don't export sequences before tables are created...

creating a user like seen above worked, if you don't specify tablespace it uses "USER" tablespace.  creating a user automatically creates a schema for that user.  if you create another user and want that user to be able to read from the first schema, then issue...

grant select, insert, update on JOHNNY.EXAMPLE_TABLE to JOHNNY2;

----------

i should mention the docker image, and oracle linux first

 cp john/product/12.1.0/dbhome_1/javavm/jdk/jdk7/lib/libjavavm12.a john/product/12.1.0/dbhome_1/lib/