Last active
September 28, 2017 10:43
-
-
Save yahonda/d4936bd065db9aa421f3ea95b5473a2e to your computer and use it in GitHub Desktop.
Create Oracle enhanced adapter development environment on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0. Environment | |
macOS High Sierra | |
Xcode | |
Ruby 2.4.2 installed by rbenv using Homebrew | |
Docker | |
1. Download "Oracle Instant Client" | |
http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html?ssSourceSiteId=otnjp | |
Version 12.1.0.2 (64-bit) | |
-> Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications | |
-> Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client | |
-> Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client | |
2. Install Oracle Instant Client | |
``` | |
$ ls | |
instantclient-basic-macos.x64-12.1.0.2.0.zip | |
instantclient-sdk-macos.x64-12.1.0.2.0.zip | |
instantclient-sqlplus-macos.x64-12.1.0.2.0.zip | |
$ pwd | |
/Users/yahonda/Downloads | |
$ mv instantclient-*.zip ~/. | |
$ cd ~ | |
$ pwd | |
/Users/yahonda | |
$ unzip instantclient-basic-macos.x64-12.1.0.2.0.zip | |
$ unzip instantclient-sqlplus-macos.x64-12.1.0.2.0.zip | |
$ unzip instantclient-sdk-macos.x64-12.1.0.2.0.zip | |
$ cd ~/instantclient_12_1 | |
$ ln -s libclntsh.dylib.12.1 libclntsh.dylib | |
$ mkdir ~/lib | |
$ ln -s ~/instantclient_12_1/libclntsh.dylib ~/lib | |
3. Add These environment variables | |
``` | |
$ more ~/.bash_profile | |
export PATH=~/instantclient_12_1:$PATH | |
export OCI_DIR=~/instantclient_12_1 | |
export RC_ARCHS=x86_64 | |
export TNS_ADMIN=$HOME/network/admin | |
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 | |
export TWO_TASK=ORCLPDB1 | |
export DATABASE_NAME=${TWO_TASK} | |
export DATABASE_VERSION=12.2.0.2 | |
``` | |
4. Download "Oracle Database 12c Release 2 (12.2.0.1.0)" Enterprise Edition | |
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-linux-12201-3608234.html | |
-> Oracle Database 12c Release 2 (12.2.0.1.0) for Linux x86-64 | |
5. Clone `docker-images` repository and move "linuxx64_12201_database.zip" file | |
``` | |
$ cd ~/git | |
$ git clone -b runs_oracle_enhanced https://github.com/yahonda/docker-images.git | |
$ mv ~/Downloads/linuxx64_12201_database.zip ~/git/docker-images/OracleDatabase/dockerfiles/12.2.0.1/. | |
``` | |
6. Build Docker Images to run Oracle Database | |
``` | |
$ cd ~/git/docker-images/OracleDatabase/dockerfiles/ | |
$ ./buildDockerImage.sh -v 12.2.0.1 -e | |
... | |
7. Startup Oracle Database Container | |
``` | |
$ sudo docker run -d -p 1521:1521 -e ORACLE_PWD=admin --name oracle-container oracle/database:12.2.0.1-ee | |
``` | |
8. docker logs -f until `DATABASE IS READY TO USE!` message appears | |
``` | |
$ sudo docker logs -f oracle-container | |
``` | |
9. Validate you can connect to Oracle Database using Oracle instanct client | |
``` | |
$ sqlplus sys/admin@//localhost:1521/ORCLPDB1 as sysdba | |
``` | |
10. Clone Oracle enhanced adapter repository | |
``` | |
$ cd ~/git (or anywhere you want) | |
$ git clone https://github.com/rsim/oracle-enhanced.git | |
``` | |
11. Create database users for Oracle enhanced adapter unit testing | |
``` | |
$ cd oracle-enhanced | |
$ sqlplus sys/admin@//localhost:1521/ORCLPDB1 as sysdba | |
SQL> @spec/support/alter_system_set_open_cursors.sql | |
SQL> @spec/support/create_oracle_enhanced_users.sql | |
SQL> quit | |
``` | |
12. Add tnsnames.ora to point to | |
``` | |
$ mkdir -p $TNS_ADMIN | |
$ vi $TNS_ADMIN/tnsnames.ora | |
----------- | |
ORCLPDB1 = | |
(DESCRIPTION = | |
(ADDRESS = (PROTOCOL=TCP)(HOST = localhost)(PORT = 1521)) | |
(CONNECT_DATA = | |
(SERVICE_NAME=ORCLPDB1) | |
) | |
) | |
----------- | |
12. bundle install and bundle exec rake spec | |
``` | |
$ bundle install | |
$ bundle exec rake spec | |
``` | |
It may get these two failures if your macOS runs on non ETC timezone | |
rspec ./spec/active_record/oracle_enhanced/type/timestamp_spec.rb:45 # OracleEnhancedAdapter timestamp with timezone support / TIMESTAMP WITH TIME ZONE values from ActiveRecord model should return Time value from TIMESTAMP columns | |
rspec ./spec/active_record/oracle_enhanced/type/timestamp_spec.rb:59 # OracleEnhancedAdapter timestamp with timezone support / TIMESTAMP WITH TIME ZONE values from ActiveRecord model should return Time value with fractional seconds from TIMESTAMP columns | |
Here are additional steps to run ActiveRecord unit tests with Oracle enhanced adapter
- Add these two environment variables to .bash_profile
export ARUNIT_DB_NAME=$TWO_TASK
export ORACLE_ENHANCED=true
$ git clone https://github.com/rails/rails.git
$ cd rails/activerecord
$ bundle
$ ARCONN=oracle bin/test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kamipo This is the step how to create Oracle enhanced adapter development environment on macOS.