oracle_client_installer 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.oracle_client_installer.json +0 -1
- data/CHANGES +3 -0
- data/README.md +176 -6
- data/lib/oracle_client_installer/oracle_client_installer.rb +1 -7
- data/lib/oracle_client_installer/version.rb +1 -1
- data/thor/oracle_client.thor +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTY2MWYzZTBkNWFjMzA3YzVmZWU5MWJkYWNiMmQwOGI1MDJjZjM5Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWEwMTllMjg0Y2E3M2Y4OWVjYjYwYjRiNThlMDBhMjQyNWQ0ODk1MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDFiYjg4NzhmYjc0Mjg2MmY3YTk3ZjcwY2EwOWNjMDkzZjgxN2Y3OWNlOTZl
|
10
|
+
Mzk0MGZmMjVhMDQ1YjNjM2MxNWFhMjhlNGMxMzc1MTNkOGY2MGVkNjhjN2Qz
|
11
|
+
OTRjYTExOTllYTY0Nzk3ZTA1NTdmMGQwZjRjN2I2N2NhMzk0MjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWIwMDhlNzJjN2Y3MWI4YmQ5YzU5MzUyOTNhNDliNDg1YTUzNmU0NTk5Zjg4
|
14
|
+
OWFmNWVkMzM2YTUyNjRjYWJlYTRjODY3ODllZDY4MGRlYWU2OWQzZjZiYmJl
|
15
|
+
NjhmMTUxZThjMjkxMmY0NzVkMmI2Mzk4YTAzMzc0YTlmOGI0YTQ=
|
data/CHANGES
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,187 @@
|
|
1
|
-
|
2
|
-
=======================
|
1
|
+
# Oracle Instant Client Installer - thor-based tasks for facilitating oracle client installation
|
3
2
|
|
4
|
-
|
3
|
+
## Introduction
|
5
4
|
|
5
|
+
Installing database driver for Oracle (activerecord-oracle_enhanced-adapter) is not a simple process.
|
6
|
+
First, you need to install Instant Client. Second, you have to install ruby wrapper around Instant Client
|
7
|
+
(ruby-oci8 gem). On some platforms second step requires compiling source code. Only after that
|
8
|
+
you can install oracle database driver. Here we discuss how to do it for OSX10 operating system.
|
9
|
+
|
10
|
+
## Create new gem group
|
11
|
+
|
12
|
+
Create separate group (e.g. "oracle") in Gemfile for oracle ruby-oci8 client wrapper. You have to keep
|
13
|
+
this gem in separate group because it requires special steps done before it can be installed.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# Gemfile
|
17
|
+
|
18
|
+
group :oracle do
|
19
|
+
gem "ruby-oci8", "2.1.7"
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Install gems for the project (except ruby-oci8 gem)
|
24
|
+
|
25
|
+
Install ruby gems for your project with bundler tool. You have to bypass oracle client wrapper installation:
|
6
26
|
|
7
27
|
```bash
|
8
|
-
bundle install --without=
|
28
|
+
bundle install --without=oracle
|
29
|
+
```
|
9
30
|
|
10
|
-
|
31
|
+
Check that you don't have ruby-oci8 installed yet:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
gem list
|
35
|
+
```
|
36
|
+
|
37
|
+
## Download Oracle Instant Client
|
38
|
+
|
39
|
+
Download Oracle Instant Client packages and save tem locally (e.g. in "downloads" folder). You can find
|
40
|
+
installation packages on **www.oracle.com** web site (you have to be registered user though).
|
41
|
+
|
42
|
+
## Configuration file
|
43
|
+
|
44
|
+
Create configuration file for the installation (.oracle_client_installer.json) in the root of your project.
|
45
|
+
It will tell where have you downloaded files and some other parameters:
|
46
|
+
|
47
|
+
```json
|
48
|
+
{
|
49
|
+
"user": "ENV['USER']",
|
50
|
+
"home": "ENV['HOME']",
|
51
|
+
"ruby_home": "ENV['MY_RUBY_HOME']",
|
52
|
+
|
53
|
+
"oracle_base": "/usr/local/oracle",
|
54
|
+
"oracle_version": "11.2.0.4.0",
|
55
|
+
"ruby_oci_version": "2.1.7",
|
56
|
+
"tns_admin_dir": "#{oracle_base}/network/admin",
|
57
|
+
|
58
|
+
"src_dir": "downloads",
|
59
|
+
"dest_dir": "#{oracle_base}/instantclient_11_2",
|
60
|
+
|
61
|
+
"basic_zip": "#{src_dir}/instantclient-basic-macos.x64-#{oracle_version}.zip",
|
62
|
+
"sdk_zip": "#{src_dir}/instantclient-sdk-macos.x64-#{oracle_version}.zip",
|
63
|
+
"sqlplus_zip": "#{src_dir}/instantclient-sqlplus-macos.x64-#{oracle_version}.zip"
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
We are going to run ruby from **ruby_home** on behalf of **user** and use specific versions of
|
68
|
+
**oracle** and **ruby-oci8** gem. We also specify where to look for installation packages (src_dir)
|
69
|
+
and where to install Instant Client (dest_dir). Also, as you can see, we are using **macos** as platform
|
70
|
+
and **x64** as architecture.
|
71
|
+
|
72
|
+
## Provide execution script
|
73
|
+
|
74
|
+
Library itself if written in ruby, but for launching you can use **rake** or **thor** tools. I provide
|
75
|
+
thor script here:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
require 'thor'
|
79
|
+
require 'oracle_client_installer'
|
80
|
+
|
81
|
+
class OracleClient < Thor
|
82
|
+
def initialize *params
|
83
|
+
@installer = OracleClientInstaller.new ".oracle_client_installer.json"
|
84
|
+
|
85
|
+
super *params
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "install", "Installs Oracle Instant Client"
|
89
|
+
def install
|
90
|
+
@installer.install
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "uninstall", "Uninstalls Oracle Instant Client"
|
94
|
+
def uninstall
|
95
|
+
@installer.uninstall
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "verify", "Verifies Oracle Instant Client connection"
|
99
|
+
def verify
|
100
|
+
username = "scott"
|
101
|
+
password = "tiger"
|
102
|
+
schema = "ORCL"
|
103
|
+
sql = "SELECT * FROM emp where rownum <= 10"
|
104
|
+
|
105
|
+
@installer.verify do
|
106
|
+
"require 'oci8'; OCI8.new('#{username}','#{password}','#{schema}').exec('#{sql}') do |r| puts r.join(','); end"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
## Install Oracle Instant Client
|
114
|
+
|
115
|
+
Run this thor command:
|
11
116
|
|
117
|
+
```bash
|
12
118
|
thor oracle_client:install
|
13
119
|
```
|
14
120
|
|
121
|
+
After execution all packages will be installed at right location on your computer.
|
122
|
+
|
123
|
+
## Again: install gems for the project (now with ruby-oci8 gem)
|
124
|
+
|
125
|
+
Remove .bundle in order to include "oracle" group into bundle execution and
|
126
|
+
then run bundler with "oracle" group:
|
127
|
+
|
128
|
+
```bash
|
129
|
+
rm -rf .bundle
|
130
|
+
|
131
|
+
bundle
|
132
|
+
```
|
133
|
+
|
134
|
+
## Verify the Installation:
|
135
|
+
|
136
|
+
If you have Oracle installed locally with **scott/tiger/ORCL**, you can test it now:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
thor oracle_client:verify
|
140
|
+
```
|
141
|
+
|
142
|
+
# General notes
|
143
|
+
|
144
|
+
If you have oracle installed somewhere on network, you can add TNS names inside your
|
145
|
+
**tnsnames.ora** file located inside **/usr/local/oracle/network/admin** folder. You can set up
|
146
|
+
this location via **tns_admin_dir** property on your configuration file:
|
147
|
+
|
148
|
+
```
|
149
|
+
MY_ORCL=
|
150
|
+
(DESCRIPTION=
|
151
|
+
(ADDRESS=
|
152
|
+
(PROTOCOL=TCP)
|
153
|
+
(HOST=db.your_host.com)
|
154
|
+
(PORT=1521)
|
155
|
+
)
|
156
|
+
(CONNECT_DATA=
|
157
|
+
(SID=MY_ORCL)
|
158
|
+
)
|
159
|
+
)
|
160
|
+
```
|
161
|
+
|
162
|
+
In order to use oracle driver inside rails application, you have to include it into Gemfile:
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
# Gemfile
|
166
|
+
|
167
|
+
group :oracle do
|
168
|
+
...
|
169
|
+
gem 'activerecord-oracle_enhanced-adapter', '1.5.3'
|
170
|
+
end
|
171
|
+
```
|
172
|
+
|
173
|
+
# Summary: all steps together
|
174
|
+
|
15
175
|
```bash
|
176
|
+
bundle install --without=oracle
|
177
|
+
|
178
|
+
thor oracle_client:install
|
179
|
+
|
180
|
+
rm -rf .bundle
|
181
|
+
|
182
|
+
bundle
|
183
|
+
|
16
184
|
thor oracle_client:verify
|
17
|
-
```
|
185
|
+
```
|
186
|
+
|
187
|
+
|
@@ -22,8 +22,6 @@ class OracleClientInstaller
|
|
22
22
|
|
23
23
|
def install
|
24
24
|
run({:sudo => true, :capture_output => true}, "install", env)
|
25
|
-
|
26
|
-
run({}, "install-ruby-oci8", env)
|
27
25
|
end
|
28
26
|
|
29
27
|
def uninstall
|
@@ -43,11 +41,7 @@ class OracleClientInstaller
|
|
43
41
|
end
|
44
42
|
|
45
43
|
def run server_info, script_name, env
|
46
|
-
execute(server_info) { evaluate_script_body(script_list[script_name], env) }
|
47
|
-
end
|
48
|
-
|
49
|
-
def evaluate_script_body content, env
|
50
|
-
interpolator.interpolate content, env
|
44
|
+
execute(server_info) { evaluate_script_body(script_list[script_name], env, :string) }
|
51
45
|
end
|
52
46
|
|
53
47
|
end
|
data/thor/oracle_client.thor
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
2
|
|
3
|
-
require 'oracle_client_installer
|
3
|
+
require 'oracle_client_installer'
|
4
4
|
|
5
5
|
class OracleClient < Thor
|
6
|
+
attr_reader :installer
|
7
|
+
|
6
8
|
def initialize *params
|
7
9
|
@installer = OracleClientInstaller.new ".oracle_client_installer.json"
|
8
10
|
|
@@ -11,22 +13,22 @@ class OracleClient < Thor
|
|
11
13
|
|
12
14
|
desc "install", "Installs Oracle Instant Client"
|
13
15
|
def install
|
14
|
-
|
16
|
+
installer.install
|
15
17
|
end
|
16
18
|
|
17
|
-
desc "uninstall", "Uninstalls
|
19
|
+
desc "uninstall", "Uninstalls Oracle Instant Client"
|
18
20
|
def uninstall
|
19
|
-
|
21
|
+
installer.uninstall
|
20
22
|
end
|
21
23
|
|
22
|
-
desc "verify", "Verifies
|
24
|
+
desc "verify", "Verifies Oracle Instant Client connection"
|
23
25
|
def verify
|
24
26
|
username = "scott"
|
25
27
|
password = "tiger"
|
26
28
|
schema = "ORCL"
|
27
29
|
sql = "SELECT * FROM emp where rownum <= 10"
|
28
30
|
|
29
|
-
|
31
|
+
installer.verify do
|
30
32
|
"require 'oci8'; OCI8.new('#{username}','#{password}','#{schema}').exec('#{sql}') do |r| puts r.join(','); end"
|
31
33
|
end
|
32
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oracle_client_installer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Shvets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: text-interpolator
|