Produced by Araxis Merge on 10/2/2017 1:40:11 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | chef-repo.zip\chef-repo\third_party_cookbooks\oracle\recipes | createdb.rb | Wed Jan 6 20:08:55 2016 UTC |
| 2 | chef-repo.zip\chef-repo\third_party_cookbooks\oracle\recipes | createdb.rb | Mon Oct 2 15:40:19 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 474 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | # | |
| 2 | # Cookbook Name:: or acle | |
| 3 | # Recipe:: createdb | |
| 4 | # | |
| 5 | # Licensed under the Apache Li cense, Ver sion 2.0 ( the "Licen se"); | |
| 6 | # you may not use th is file ex cept in co mpliance w ith the Li cense. | |
| 7 | # You may obtain a c opy of the License a t | |
| 8 | # | |
| 9 | # http ://www.apa che.org/li censes/LIC ENSE-2.0 | |
| 10 | # | |
| 11 | # Unless r equired by applicabl e law or a greed to i n writing, software | |
| 12 | # distribu ted under the Licens e is distr ibuted on an "AS IS" BASIS, | |
| 13 | # WITHOUT WARRANTIES OR CONDIT IONS OF AN Y KIND, ei ther expre ss or impl ied. | |
| 14 | # See the License fo r the spec ific langu age govern ing permis sions and | |
| 15 | # limitati ons under the Licens e. | |
| 16 | # | |
| 17 | ## Create Oracle dat abases. | |
| 18 | # | |
| 19 | ||
| 20 | directory node[:orac le][:rdbms ][:dbs_roo t] do | |
| 21 | owner 'o racle' | |
| 22 | group 'o install' | |
| 23 | mode '07 55' | |
| 24 | end | |
| 25 | ||
| 26 | # createdb .rb uses t his databa se templat e. | |
| 27 | template " #{node[:or acle][:rdb ms][:ora_h ome]}/assi stants/dbc a/template s/default_ template.d bt" do | |
| 28 | owner 'o racle' | |
| 29 | group 'o install' | |
| 30 | mode '06 44' | |
| 31 | end | |
| 32 | ||
| 33 | # Optional database template w ith more d b options. | |
| 34 | template " #{node[:or acle][:rdb ms][:ora_h ome]}/assi stants/dbc a/template s/midrange _template. dbt" do | |
| 35 | owner 'o racle' | |
| 36 | group 'o install' | |
| 37 | mode '06 44' | |
| 38 | end | |
| 39 | ||
| 40 | # Iterate over :orac le[:rdbms] [:dbs]'s k eys, Initi alizing db ca to | |
| 41 | # create a database named afte r the key for each k ey whose a ssociated | |
| 42 | # value is false, an d flipping the value afterward s. | |
| 43 | # If :orac le[:rdbms] [:dbs] is empty, we print a wa rning to S TDOUT. | |
| 44 | ruby_block "print_em pty_db_has h_warning" do | |
| 45 | block do | |
| 46 | Chef:: Log.warn(" :oracle[:r dbms][:dbs ] is empty ; no datab ase will b e created. ") | |
| 47 | end | |
| 48 | action : create | |
| 49 | only_if {node[:ora cle][:rdbm s][:dbs].e mpty?} | |
| 50 | end | |
| 51 | ||
| 52 | node[:orac le][:rdbms ][:dbs].ea ch_key do |db| | |
| 53 | if node[ :oracle][: rdbms][:db s][db] | |
| 54 | ruby_b lock "prin t_#{db}_sk ipped_msg" do | |
| 55 | bloc k do | |
| 56 | Ch ef::Log.in fo("Databa se #{db} h as already been crea ted on thi s node- sk ipping it. ") | |
| 57 | end | |
| 58 | acti on :create | |
| 59 | end | |
| 60 | ||
| 61 | next | |
| 62 | end | |
| 63 | ||
| 64 | ## Creat e database . | |
| 65 | if node[ :oracle][: rdbms][:db bin_versio n] == "12c " | |
| 66 | # 12c | |
| 67 | bash " dbca_creat edb_#{db}" do | |
| 68 | user "oracle" | |
| 69 | grou p "oinstal l" | |
| 70 | envi ronment (n ode[:oracl e][:rdbms] [:env]) | |
| 71 | code "dbca -si lent -crea teDatabase -emConfig uration DB EXPRESS -t emplateNam e #{node[: oracle][:r dbms][:db_ create_tem plate]} -g dbname #{d b} -sid #{ db} -sysPa ssword #{n ode[:oracl e][:rdbms] [:sys_pw]} -systemPa ssword #{n ode[:oracl e][:rdbms] [:system_p w]}" | |
| 72 | end | |
| 73 | ||
| 74 | else | |
| 75 | # 11g | |
| 76 | bash " dbca_creat edb_#{db}" do | |
| 77 | user "oracle" | |
| 78 | grou p "oinstal l" | |
| 79 | envi ronment (n ode[:oracl e][:rdbms] [:env]) | |
| 80 | code "dbca -si lent -crea teDatabase -template Name #{nod e[:oracle] [:rdbms][: db_create_ template]} -gdbname #{db} -sid #{db} -sy sPassword #{node[:or acle][:rdb ms][:sys_p w]} -syste mPassword #{node[:or acle][:rdb ms][:syste m_pw]}" | |
| 81 | end | |
| 82 | ||
| 83 | # Add to listene r.ora a st anza descr ibing the new DB. | |
| 84 | ruby_b lock "appe nd_#{db}_s tanza_to_l snr_conf" do | |
| 85 | bloc k do | |
| 86 | ls nr_conf = "#{node[:o racle][:rd bms][:ora_ home]}/net work/admin /listener. ora" | |
| 87 | si d_desc_bod y = "(SID_ DESC=(GLOB AL_DBNAME= #{db})(ORA CLE_HOME=# {node[:ora cle][:rdbm s][:ora_ho me]})(SID_ NAME=#{db} )))" | |
| 88 | ab ort("Could not back up #{lsnr_ conf}; bai ling out") unless sy stem "cp - -preserve= mode,owner ship #{lsn r_conf} #{ lsnr_conf} .bak-$(dat e +%Y-%m-% d-%H%M%S)" | |
| 89 | Fi le.open ls nr_conf, ' r+' do |f| | |
| 90 | content = f.readline s | |
| 91 | last_line = content[ -1] | |
| 92 | sid_desc_h eader = (l ast_line = ~ /^SID/) ? '' : 'SI D_LIST_LIS TENER=(SID _LIST=' | |
| 93 | sid_desc = sid_desc_ header + s id_desc_bo dy | |
| 94 | content[-1 ] = last_l ine.sub(/[ )\s]$/, si d_desc) | |
| 95 | f.rewind | |
| 96 | f.truncate (f.pos) | |
| 97 | f.write co ntent.join | |
| 98 | en d | |
| 99 | end | |
| 100 | acti on :create | |
| 101 | end | |
| 102 | ||
| 103 | # Conf igure dbco ntrol. | |
| 104 | if nod e[:oracle] [:rdbms][: dbconsole] [:emconfig ] | |
| 105 | # Cr eating em. rsp file f or dbcontr ol. | |
| 106 | temp late "#{no de[:oracle ][:rdbms][ :ora_home] }/em.rsp" do | |
| 107 | ow ner 'oracl e' | |
| 108 | gr oup 'oinst all' | |
| 109 | mo de '0644' | |
| 110 | end | |
| 111 | # Pr eparing DB SNMP user. | |
| 112 | bash "prepare_ dbsnmp_use r_#{db}" d o | |
| 113 | us er "oracle " | |
| 114 | gr oup "oinst all" | |
| 115 | en vironment (node[:ora cle][:rdbm s][:env]) | |
| 116 | co de <<-EOH2 | |
| 117 | export ORA CLE_SID=#{ db} | |
| 118 | sqlplus / as sysdba <<-EOL1 | |
| 119 | ALTER USER DBSNMP AC COUNT UNLO CK; | |
| 120 | ALTER USER DBSNMP ID ENTIFIED B Y #{node[: oracle][:r dbms][:dbs nmp_pw]}; | |
| 121 | exit | |
| 122 | EOL1 | |
| 123 | EO H2 | |
| 124 | end | |
| 125 | # Ch ange sid o n em.rsp. | |
| 126 | exec ute "set_s id_to_em-r sp_#{db}" do | |
| 127 | co mmand "sed -i '2s/.* /SID=#{db} /' #{node[ :oracle][: rdbms][:or a_home]}/e m.rsp" | |
| 128 | us er 'oracle ' | |
| 129 | gr oup 'oinst all' | |
| 130 | end | |
| 131 | # Re loading th e listener 's configu ration. | |
| 132 | exec ute "reloa d_listener _to_regist er_#{db}" do | |
| 133 | co mmand "#{n ode[:oracl e][:rdbms] [:ora_home ]}/bin/lsn rctl reloa d" | |
| 134 | us er 'oracle ' | |
| 135 | gr oup 'oinst all' | |
| 136 | en vironment (node[:ora cle][:rdbm s][:env]) | |
| 137 | end | |
| 138 | # Ru nning emca . | |
| 139 | exec ute "conf_ dbcontrol_ #{db}" do | |
| 140 | co mmand "exp ort ORACLE _HOME=#{no de[:oracle ][:rdbms][ :ora_home] }; emca -c onfig dbco ntrol db - repos crea te -respFi le #{node[ :oracle][: rdbms][:or a_home]}/e m.rsp" | |
| 141 | us er 'oracle ' | |
| 142 | gr oup 'oinst all' | |
| 143 | en vironment (node[:ora cle][:rdbm s][:env]) | |
| 144 | end | |
| 145 | end | |
| 146 | ||
| 147 | # Maki ng sure sh red is ava ilable | |
| 148 | yum_pa ckage "cor eutils" do | |
| 149 | acti on :instal l | |
| 150 | arch 'x86_64' | |
| 151 | end | |
| 152 | ||
| 153 | # Shre ding the e m.rsp to g et rid of the passwo rds. | |
| 154 | execut e "shred_e m_rsp_#{db }" do | |
| 155 | comm and "/usr/ bin/shred -zu #{node [:oracle][ :rdbms][:o ra_home]}/ em.rsp" | |
| 156 | user 'root' | |
| 157 | grou p 'root' | |
| 158 | end | |
| 159 | ||
| 160 | end # of create da tabase. | |
| 161 | ||
| 162 | # Settin gi a flag to indicat e, that th e database has been created. | |
| 163 | ruby_blo ck "set_#{ db}_instal l_flag" do | |
| 164 | block do | |
| 165 | node .set[:orac le][:rdbms ][:dbs][db ] = true | |
| 166 | end | |
| 167 | action :create | |
| 168 | end | |
| 169 | ||
| 170 | # Append to tnsnam es.ora a s tanza desc ribing the new DB | |
| 171 | execute "append_#{ db}_to_tns names.ora" do | |
| 172 | command "e cho '#{db} =\n (DESCRIPTI ON =\n (ADDRESS_L IST =\n (ADDRESS = (PROTOCOL = TCP)(HO ST = #{nod e[:fqdn]}) (PORT = PORT ))\n )\n (CONNECT_D ATA =\n (SERVICE_N AME = #{db })\n )\n )\n\n' >> #{node[:or acle][:rdb ms][:ora_h ome]}/netw ork/admin/ tnsnames.o ra" | |
| 173 | not_if "grep #{d b} #{node[ :oracle][: rdbms][:or a_home]}/n etwork/adm in/tnsname s.ora > /d ev/null 2> &1" | |
| 174 | end | |
| 175 | ||
| 176 | # Modify the new D B's config uration in /etc/orat ab. | |
| 177 | execute "edit_orat abs_#{db}_ config" do | |
| 178 | comman d "sed -i. old '/^#{d b}/s/N$/Y/ ' /etc/ora tab" | |
| 179 | cwd '/ etc' | |
| 180 | end | |
| 181 | ||
| 182 | # Reload ing the li stener's c onfigurati on. | |
| 183 | execute "reload_li stener_to_ register_# {db}" do | |
| 184 | comman d "#{node[ :oracle][: rdbms][:or a_home]}/b in/lsnrctl reload" | |
| 185 | user ' oracle' | |
| 186 | group 'oinstall' | |
| 187 | enviro nment (nod e[:oracle] [:rdbms][: env]) | |
| 188 | end | |
| 189 | ||
| 190 | # Creati ng a direc tory for E XPORTS dir ectory obj ect. | |
| 191 | director y "#{node[ :oracle][: rdbms][:db s_root]}/# {db}/expor t" do | |
| 192 | owner 'oracle' | |
| 193 | group 'dba' | |
| 194 | mode ' 0755' | |
| 195 | end | |
| 196 | ||
| 197 | # Enable block cha nge tracki ng. | |
| 198 | # A bloc k change t racking fi le for the DB is add ed to incr ease RMAN backup | |
| 199 | # perfor mance duri ng increme ntal backu ps. Instea d of RMAN going thro ugh the ch anged | |
| 200 | # blocks for the w hole DB, i t picks th em up from this file . | |
| 201 | bash "bl ock_change _tracking_ #{db}" do | |
| 202 | user " oracle" | |
| 203 | group "oinstall" | |
| 204 | enviro nment (nod e[:oracle] [:rdbms][: env]) | |
| 205 | code < <-EOH3 | |
| 206 | exp ort ORACLE _SID=#{db} | |
| 207 | sql plus / as sysdba <<- EOL2 | |
| 208 | ALT ER DATABAS E ENABLE B LOCK CHANG E TRACKING USING FIL E '#{node[ :oracle][: rdbms][:db s_root]}/# {db}/data1 /#{db}_blo ck_change_ tracking.t rk'; | |
| 209 | CRE ATE DIRECT ORY "EXPOR T" AS '#{n ode[:oracl e][:rdbms] [:dbs_root ]}/#{db}/e xport'; | |
| 210 | exi t | |
| 211 | EOL 2 | |
| 212 | EOH3 | |
| 213 | end | |
| 214 | ||
| 215 | # Creati ng a direc tory for R MAN backup s. | |
| 216 | director y "#{node[ :oracle][: rdbms][:db s_root]}/# {db}/backu p1" do | |
| 217 | owner 'oracle' | |
| 218 | group 'oinstall' | |
| 219 | mode ' 0755' | |
| 220 | end | |
| 221 | ||
| 222 | # Set th e ORACLE_S ID correct ly in orac le's .prof ile. | |
| 223 | execute "set_oracl e_sid_to_o racle_prof ile_#{db}" do | |
| 224 | comman d "sed -i 's/ORACLE_ SID=.*/ORA CLE_SID=#{ db}/g' /ho me/oracle/ .profile" | |
| 225 | user ' oracle' | |
| 226 | group 'oinstall' | |
| 227 | enviro nment (nod e[:oracle] [:rdbms][: env]) | |
| 228 | end | |
| 229 | ||
| 230 | # Set th e ORACLE_U NQNAME cor rectly in oracle's . profile. | |
| 231 | execute "set_oracl e_unqname_ to_oracle_ profile_#{ db}" do | |
| 232 | comman d "sed -i 's/ORACLE_ UNQNAME=.* /ORACLE_UN QNAME=#{db }/g' /home /oracle/.p rofile" | |
| 233 | user ' oracle' | |
| 234 | group 'oinstall' | |
| 235 | enviro nment (nod e[:oracle] [:rdbms][: env]) | |
| 236 | end | |
| 237 | ||
| 238 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.