forked from tigormanmsft/oravm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cr_oravm.sh
executable file
·943 lines (943 loc) · 43.4 KB
/
cr_oravm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
#!/bin/bash
#================================================================================
# Name: cr_oravm.sh
# Type: bash script
# Date: 23-April 2020
# From: Americas Customer Engineering team (CET) - Microsoft
#
# Copyright and license:
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright (c) 2020 by Microsoft. All rights reserved.
#
# Ownership and responsibility:
#
# This script is offered without warranty by Microsoft Customer Engineering.
# Anyone using this script accepts full responsibility for use, effect,
# and maintenance. Please do not contact Microsoft support unless there
# is a problem with a supported Azure component used in this script,
# such as an "az" command.
#
# Description:
#
# Script to automate the creation of an Oracle database on a marketplace
# Oracle image within Microsoft Azure, using the Azure CLI.
#
# Command-line Parameters:
#
# Usage: ./cr_oravm.sh -G val -H val -N -O val -P val -S val -c val -d val -i val -n val -p val -r val -s val -u val -v -w val -z val
#
# where:
# -G resource-group-name name of the Azure resource group (default: \"{owner}-{project}-rg\")
# -H ORACLE_HOME full path of the ORACLE_HOME software (default: /u01/app/oracle/product/12.2.0/dbhome_1)
# -N skip storage account and network setup i.e. vnet, NSG, NSG rules (default: false)
# -O owner-tag name of the owner to use in Azure tags (default)
# -P project-tag name of the project to use in Azure tags (no default)
# -S subscription name of the Azure subscription (no default)
# -c None|ReadOnly caching of managed disk for data (default: ReadOnly)
# -d domain-name IP domain name (default: internal.cloudapp.net)
# -i instance-type name of the Azure VM instance type (default: Standard_DS11-1_v2)
# -n #data-disks number of data disks to attach to the VM (default: 1)
# -p Oracle-port port number of the Oracle TNS Listener (default: 1521)
# -r region name of Azure region (default: westus)
# -s ORACLE_SID Oracle System ID (SID) value (default: oradb01)
# -u urn Azure URN for the VM from the marketplace (default: Oracle:Oracle-Database-Ee:12.2.0.1:12.2.20180725)
# -v set verbose output is true (default: false)
# -w password clear-text value of initial SYS and SYSTEM password in Oracle database (default: oracleA1)
# -z data-disk-GB size of each attached data-disk in GB (default: 4095)
#
# Expected command-line output:
#
# Please see file "oravm_output.txt" at https://github.com/tigormanmsft/oravm.
#
# Usage notes:
#
# 1) Azure subscription, specify with "-S" switch
#
# 2) Azure owner, default is output of "whoami" command in shell, can be
# specified using "-O" switch on command-line
#
# 3) Azure project, default is "oravm", can be specified using "-P"
# switch on command-line
#
# 4) Azure resource group, specify with "-G" switch or with a
# combination of "-O" (project owner tag) and "-P" (project name)
# values (default: "(project owner tag)-(project name)-rg").
#
# For example, if the project owner tag is "abc" and the project
# name is "beetlejuice", then by default the resource group is
# expected to be named "abc-beetlejuice-rg", unless changes have
# been specified using the "-G", "-O", or "-P" switches
#
# 5) Use the "-v" (verbose) switch to verify that program variables
# have the expected values
#
# 6) For users who are expected to use prebuilt storage accounts
# and networking (i.e. vnet, subnet, network security groups, etc),
# consider using the "-N" switch to accept these as prerequisites
#
# Please be aware that Azure owner (i.e. "-O") and Azure project (i.e. "-P")
# are used to generate names for the Azure resource group, storage
# account, virtual network, subnet, network security group and rules,
# VM, and storage disks. Use the "-v" switch to verify expected naming.
#
# Modifications:
# TGorman 23apr20 written v0.1
# TGorman 15jun20 various bug fixes for v0.2
# TGorman 16jun20 move TEMP to temporary disk for v0.3
# SLuce and TGorman 22jun20 add Azure NetApp Files (ANF) storage for v0.4
#================================================================================
#
#--------------------------------------------------------------------------------
# Set global environment variables with default values...
#--------------------------------------------------------------------------------
_progVersion="0.4"
_outputMode="terse"
_azureOwner="`whoami`"
_azureProject="oravm"
_azureRegion="westus"
_azureSubscription=""
_workDir="`pwd`"
_skipSaVnetSubnetNsg="false"
_vmUrn="Oracle:Oracle-Database-Ee:12.2.0.1:12.2.20180725"
_vmDomain="internal.cloudapp.net"
_vmOsDiskSize="32"
_vmInstanceType="Standard_DS11-1_v2"
_vmDataDiskNbr=0
_vmDataDiskSzGB=4095
_vmDataDiskCaching="ReadOnly"
_vgName="vg_ora01"
_lvName="lv_ora01"
_oraSid="oradb01"
_oraHome="/u01/app/oracle/product/12.2.0/dbhome_1"
_oraInvDir="/u01/app/oraInventory"
_oraOsAcct="oracle"
_oraOsGroup="oinstall"
_oraCharSet="WE8ISO8859P15"
_oraMntDir="/u02"
_oraDataDir="${_oraMntDir}/oradata"
_oraFRADir="${_oraMntDir}/orarecv"
_oraSysPwd=oracleA1
_oraRedoSizeMB=500
_oraLsnrPort=1521
_oraMemPct=70
_oraMemType="AUTO_SGA"
_oraFraSzGB=40960
typeset -i _scsiDevNbr=24
declare -a _scsiDevList=("", "sdc" "sdd" "sde" "sdf" "sdg" "sdh" \
"sdi" "sdj" "sdk" "sdl" "sdm" "sdn" \
"sdo" "sdp" "sdq" "sdr" "sds" "sdt" \
"sdu" "sdv" "sdw" "sdx" "sdy" "sdz")
_saName="${_azureOwner}${_azureProject}sa"
_rgName="${_azureOwner}-${_azureProject}-rg"
_realRgName=""
_vnetName="${_azureOwner}-${_azureProject}-vnet"
_subnetName="${_azureOwner}-${_azureProject}-subnet"
_nsgName="${_azureOwner}-${_azureProject}-nsg"
_nicName="${_azureOwner}-${_azureProject}-nic01"
_pubIpName="${_azureOwner}-${_azureProject}-public-ip01"
_vmName="${_azureOwner}-${_azureProject}-vm01"
_logFile="${_workDir}/${_azureOwner}-${_azureProject}.log"
_ANFaccountName="${_azureOwner}-${_azureProject}-naa"
_ANFpoolName="${_azureOwner}-${_azureProject}-pool"
_ANFvolumeName="${_azureOwner}-${_azureProject}-vol"
_ANFsubnetName="${_azureOwner}-${_azureProject}-anfnet"
#
#--------------------------------------------------------------------------------
# Accept command-line parameter values to override default values (above)..
#--------------------------------------------------------------------------------
typeset -i _parseErrs=0
while getopts ":G:H:NO:P:S:c:d:i:n:p:r:s:u:vw:z:" OPTNAME
do
case "${OPTNAME}" in
G) _realRgName="${OPTARG}" ;;
H) _oraHome="${OPTARG}" ;;
N) _skipSaVnetSubnetNsg="true" ;;
O) _azureOwner="${OPTARG}" ;;
P) _azureProject="${OPTARG}" ;;
S) _azureSubscription="${OPTARG}" ;;
c) _vmDataDiskCaching="${OPTARG}" ;;
d) _vmDomain="${OPTARG}" ;;
i) _vmInstanceType="${OPTARG}" ;;
n) _vmDataDiskNbr="${OPTARG}" ;;
p) _oraLsnrPort="${OPTARG}" ;;
r) _azureRegion="${OPTARG}" ;;
s) _oraSid="${OPTARG}" ;;
u) _vmUrn="${OPTARG}" ;;
v) _outputMode="verbose" ;;
w) _oraSysPwd="${OPTARG}" ;;
z) _vmDataDiskSzGB="${OPTARG}" ;;
:) echo "`date` - FAIL: expected \"${OPTARG}\" value not found"
typeset -i _parseErrs=${_parseErrs}+1
;;
\?) echo "`date` - FAIL: unknown command-line option \"${OPTARG}\""
typeset -i _parseErrs=${_parseErrs}+1
;;
esac
done
shift $((OPTIND-1))
#
#--------------------------------------------------------------------------------
# If any errors occurred while processing the command-line parameters, then display
# a usage message and exit with failure status...
#--------------------------------------------------------------------------------
if (( ${_parseErrs} > 0 ))
then
echo "Usage: $0 -G val -H val -N -O val -P val -S val -c val -d val -i val -n val -p val -r val -s val -u val -v -w val -z val"
echo "where:"
echo " -G resource-group-name name of the Azure resource group (default: \"{owner}-{project}-rg\")"
echo " -H ORACLE_HOME full path of the ORACLE_HOME software (default: /u01/app/oracle/product/12.2.0/dbhome_1)"
echo " -N skip storage account and network setup i.e. vnet, NSG, NSG rules (default: false)"
echo " -O owner-tag name of the owner to use in Azure tags (no default)"
echo " -P project-tag name of the project to use in Azure tags (no default)"
echo " -S subscription name of the Azure subscription (no default)"
echo " -c None|ReadOnly caching of managed disk for data (default: ReadOnly)"
echo " -d domain-name IP domain name (default: internal.cloudapp.net)"
echo " -i instance-type name of the Azure VM instance type (default: Standard_DS11-1_v2)"
echo " -n #data-disks number of data disks to attach to the VM (default: 1)"
echo " -p Oracle-port port number of the Oracle TNS Listener (default: 1521)"
echo " -r region name of Azure region (default: westus)"
echo " -s ORACLE_SID Oracle System ID (SID) value (default: oradb01)"
echo " -u urn Azure URN for the VM from the marketplace (default: Oracle:Oracle-Database-Ee:12.2.0.1:12.2.20180725)"
echo " -v set verbose output is true (default: false)"
echo " -w password clear-text value of initial SYS and SYSTEM password in Oracle database (default: oracleA1)"
echo " -z data-disk-GB size of each attached data-disk in GB (default: 4095)"
exit 1
fi
#
#--------------------------------------------------------------------------------
# Set script variables based on owner and project values...
#--------------------------------------------------------------------------------
if [[ "${_realRgName}" != "" ]]
then
_rgName="${_realRgName}"
else
_rgName="${_azureOwner}-${_azureProject}-rg"
fi
_saName="${_azureOwner}${_azureProject}sa"
_vnetName="${_azureOwner}-${_azureProject}-vnet"
_subnetName="${_azureOwner}-${_azureProject}-subnet"
_nsgName="${_azureOwner}-${_azureProject}-nsg"
_nicName="${_azureOwner}-${_azureProject}-nic01"
_pubIpName="${_azureOwner}-${_azureProject}-public-ip01"
_vmName="${_azureOwner}-${_azureProject}-vm01"
_logFile="${_workDir}/${_azureOwner}-${_azureProject}.log"
_ANFaccountName="${_azureOwner}-${_azureProject}-naa"
_ANFpoolName="${_azureOwner}-${_azureProject}-pool"
_ANFvolumeName="${_azureOwner}-${_azureProject}-vol"
_ANFsubnetName="${_azureOwner}-${_azureProject}-anfnet"
#
#--------------------------------------------------------------------------------
# Display variable values when output is set to "verbose"...
#--------------------------------------------------------------------------------
if [[ "${_outputMode}" = "verbose" ]]
then
echo "`date` - DBUG: parameter _rgName is \"${_rgName}\""
echo "`date` - DBUG: parameter _skipSaVnetSubnetNsg is \"${_skipSaVnetSubnetNsg}\""
echo "`date` - DBUG: parameter _azureOwner is \"${_azureOwner}\""
echo "`date` - DBUG: parameter _azureProject is \"${_azureProject}\""
echo "`date` - DBUG: parameter _azureSubscription is \"${_azureSubscription}\""
echo "`date` - DBUG: parameter _vmDataDiskCaching is \"${_vmDataDiskCaching}\""
echo "`date` - DBUG: parameter _vmDomain is \"${_vmDomain}\""
echo "`date` - DBUG: parameter _oraHome is \"${_oraHome}\""
echo "`date` - DBUG: parameter _vmInstanceType is \"${_vmInstanceType}\""
echo "`date` - DBUG: parameter _vmDataDiskNbr is \"${_vmDataDiskNbr}\""
echo "`date` - DBUG: parameter _oraLsnrPort is \"${_oraLsnrPort}\""
echo "`date` - DBUG: parameter _azureRegion is \"${_azureRegion}\""
echo "`date` - DBUG: parameter _oraSid is \"${_oraSid}\""
echo "`date` - DBUG: parameter _vmUrn is \"${_vmUrn}\""
echo "`date` - DBUG: parameter _vmDataDiskSzGB is \"${_vmDataDiskSzGB}\""
echo "`date` - DBUG: variable _progVersion is \"${_progVersion}\""
echo "`date` - DBUG: variable _workDir is \"${_workDir}\""
echo "`date` - DBUG: variable _logFile is \"${_logFile}\""
echo "`date` - DBUG: variable _saName is \"${_saName}\""
echo "`date` - DBUG: variable _vnetName is \"${_vnetName}\""
echo "`date` - DBUG: variable _subnetName is \"${_subnetName}\""
echo "`date` - DBUG: variable _nsgName is \"${_nsgName}\""
echo "`date` - DBUG: variable _nicName is \"${_nicName}\""
echo "`date` - DBUG: variable _pubIpName is \"${_pubIpName}\""
echo "`date` - DBUG: variable _vmName is \"${_vmName}\""
echo "`date` - DBUG: variable _vmOsDiskSize is \"${_vmOsDiskSize}\""
echo "`date` - DBUG: variable _vgName is \"${_vgName}\""
echo "`date` - DBUG: variable _lvName is \"${_lvName}\""
echo "`date` - DBUG: variable _oraInvDir is \"${_oraInvDir}\""
echo "`date` - DBUG: variable _oraOsAcct is \"${_oraOsAcct}\""
echo "`date` - DBUG: variable _oraOsGroup is \"${_oraOsGroup}\""
echo "`date` - DBUG: variable _oraCharSet is \"${_oraCharSet}\""
echo "`date` - DBUG: variable _oraMntDir is \"${_oraMntDir}\""
echo "`date` - DBUG: variable _oraDataDir is \"${_oraDataDir}\""
echo "`date` - DBUG: variable _oraFRADir is \"${_oraFRADir}\""
echo "`date` - DBUG: variable _oraRedoSizeMB is \"${_oraRedoSizeMB}\""
echo "`date` - DBUG: variable _oraMemPct is \"${_oraMemPct}\""
echo "`date` - DBUG: variable _oraMemType is \"${_oraMemType}\""
echo "`date` - DBUG: variable _oraFraSzGB is \"${_oraFraSzGB}\""
echo "`date` - DBUG: variable _ANFaccountName is \"${_ANFaccountName}\""
echo "`date` - DBUG: variable _ANFpoolName is \"${_ANFpoolName}\""
echo "`date` - DBUG: variable _ANFvolumeName is \"${_ANFvolumeName}\""
echo "`date` - DBUG: variable _ANFsubnetName is \"${_ANFsubnetName}\""
fi
#
#--------------------------------------------------------------------------------
# Verify that the requested number of data disks is less than the script's max...
#--------------------------------------------------------------------------------
if (( ${_vmDataDiskNbr} > ${_scsiDevNbr} )); then
echo "`date` - FAIL: number of data disks must be <= ${_scsiDevNbr}" | tail -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Remove any existing logfile...
#--------------------------------------------------------------------------------
rm -f ${_logFile}
#
#--------------------------------------------------------------------------------
# Verify that the resource group exists...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az group exists -n ${_rgName}..." | tee -a ${_logFile}
if [[ "`az group exists -n ${_rgName}`" != "true" ]]; then
echo "`date` - FAIL: resource group \"${_rgName}\" does not exist" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Set the default Azure subscription...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az account set..." | tee -a ${_logFile}
az account set -s "${_azureSubscription}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: ${_azureProject} - az account set" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Set the default Azure resource group and region/location...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az configure --defaults group location..." | tee -a ${_logFile}
az configure --defaults group=${_rgName} location=${_azureRegion} >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: ${_azureProject} - az configure --defaults group location" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# If the user elected to skip the creation of vnet, the NIC, the NSG, and the
# rules...
#--------------------------------------------------------------------------------
if [[ "${_skipSaVnetSubnetNsg}" = "false" ]]; then
#
#------------------------------------------------------------------------
# Create an Azure storage account for this project...
#------------------------------------------------------------------------
echo "`date` - INFO: az storage account create ${_saName}..." | tee -a ${_logFile}
az storage account create \
--name ${_saName} \
--sku Standard_LRS \
--access-tier Hot \
--tags owner=${_azureOwner} project=${_azureProject} \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: ${_azureProject} - az storage account create ${_saName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# Create an Azure virtual network for this project...
#------------------------------------------------------------------------
echo "`date` - INFO: az network vnet create ${_vnetName}..." | tee -a ${_logFile}
az network vnet create \
--name ${_vnetName} \
--address-prefixes 10.0.0.0/16 \
--subnet-name ${_subnetName} \
--tags owner=${_azureOwner} project=${_azureProject} \
--subnet-prefixes 10.0.0.0/24 \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network vnet create ${_vnetName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# Create an Azure network security group for this project...
#------------------------------------------------------------------------
echo "`date` - INFO: az network nsg create ${_nsgName}..." | tee -a ${_logFile}
az network nsg create \
--name ${_nsgName} \
--tags owner=${_azureOwner} project=${_azureProject} \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network nsg create ${_nsgName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# Create a custom Azure network security group rule to permit SSH access...
#------------------------------------------------------------------------
echo "`date` - INFO: az network nsg rule create default-all-ssh..." | tee -a ${_logFile}
az network nsg rule create \
--name default-all-ssh \
--nsg-name ${_nsgName} \
--priority 1000 \
--direction Inbound \
--protocol TCP \
--source-address-prefixes \* \
--source-port-ranges \* \
--destination-address-prefixes \* \
--destination-port-ranges 22 \
--access Allow \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network nsg rule create default-all-ssh" | tee -a ${_logFile}
exit 1
fi
#
fi
#
#--------------------------------------------------------------------------------
# Create an Azure public IP address object for use with the first VM...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az network public-ip create ${_pubIpName}..." | tee -a ${_logFile}
az network public-ip create \
--name ${_pubIpName} \
--tags owner=${_azureOwner} project=${_azureProject} \
--allocation-method Static \
--sku Basic \
--version IPv4 \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network public-ip create ${_pubIpName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Create an Azure network interface (NIC) object for use with the first VM...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az network nic create ${_nicName}..." | tee -a ${_logFile}
az network nic create \
--name ${_nicName} \
--vnet-name ${_vnetName} \
--subnet ${_subnetName} \
--network-security-group ${_nsgName} \
--public-ip-address ${_pubIpName} \
--tags owner=${_azureOwner} project=${_azureProject} \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network nic create ${_nicName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Create the first Azure virtual machine (VM), intended to be used as the primary
# Oracle database server/host...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az vm create ${_vmName}..." | tee -a ${_logFile}
az vm create \
--name ${_vmName} \
--image ${_vmUrn}:latest \
--admin-username ${_azureOwner} \
--size ${_vmInstanceType} \
--nics ${_nicName} \
--os-disk-name ${_vmName}-osdisk \
--os-disk-size-gb ${_vmOsDiskSize} \
--os-disk-caching ${_vmDataDiskCaching} \
--tags owner=${_azureOwner} project=${_azureProject} \
--generate-ssh-keys \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az vm create ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Obtain the public IP addresses for future use within the script...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az network public-ip show ${_pubIpName}..." | tee -a ${_logFile}
_ipAddr=`az network public-ip show --name ${_pubIpName} | \
jq '. | {ipaddr: .ipAddress}' | \
grep ipaddr | \
awk '{print $2}' | \
sed 's/"//g'`
if (( $? != 0 )); then
echo "`date` - FAIL: az network public-ip show ${_pubIpName}" | tee -a ${_logFile}
exit 1
fi
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R ${_ipAddr} >> ${_logFile} 2>&1
echo "`date` - INFO: public IP ${_ipAddr} for ${_vmName}..." | tee -a ${_logFile}
#
#--------------------------------------------------------------------------------
# SSH into the first VM to create a directory mount-point for the soon-to-be-created
# filesystem in which Oracle database files will reside...
#--------------------------------------------------------------------------------
echo "`date` - INFO: mkdir ${_oraMntDir} on ${_vmName}..." | tee -a ${_logFile}
ssh -o StrictHostKeyChecking=no ${_azureOwner}@${_ipAddr} "sudo mkdir -p ${_oraMntDir}"
if (( $? != 0 )); then
echo "`date` - FAIL: sudo mkdir -p ${_oraMntDir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the first VM to set the OS account:group ownership of the
# directory mount-point...
#--------------------------------------------------------------------------------
echo "`date` - INFO: chown ${_oraMntDir} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo chown ${_oraOsAcct}:${_oraOsGroup} ${_oraMntDir}"
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chown ${_oraMntDir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# If no data disks are requested on the VM, then deploy Azure NetApp Files...
#--------------------------------------------------------------------------------
if (( ${_vmDataDiskNbr} <= 0 )); then
echo "`date` - INFO: no data disks requested, Azure NetApp Files it is!" | tee -a ${_logFile}
#
#--------------------------------------------------------------------------------
# Obtain the private IP address of the VM for future use within the script...
#--------------------------------------------------------------------------------
echo "`date` - INFO: az network nic ip-config show ${_nicName}..." | tee -a ${_logFile}
_privateipAddr=`az network nic ip-config show --nic-name ${_nicName} --name ipconfig1 | \
jq '. | {ipaddr: .privateIpAddress}' | \
grep ipaddr | \
awk '{print $2}' | \
sed 's/"//g'`
if (( $? != 0 )); then
echo "`date` - FAIL: az network nic ip-config show ${_nicName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Create Azure NetApp Files Delegated Subnet
#--------------------------------------------------------------------------------
echo "`date` - INFO: az network vnet subnet create ${_ANFsubnetName}..." | tee -a ${_logFile}
az network vnet subnet create \
--name ${_ANFsubnetName} \
--vnet-name ${_vnetName} \
--delegation Microsoft.Netapp/volumes \
--address-prefixes 10.0.1.0/24 \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az network vnet subnet create ${_ANFsubnetName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Create the Azure NetApp Files (ANF) NetApp Account
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles account create ${_ANFaccountName}..." | tee -a ${_logFile}
az netappfiles account create \
--account-name ${_ANFaccountName} \
--tags owner=${_azureOwner} project=${_azureProject} \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles account create ${_ANFaccountName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Create the ANF Capacity Pool
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles pool create ${_ANFpoolName}..." | tee -a ${_logFile}
az netappfiles pool create \
--account-name ${_ANFaccountName} \
--pool-name ${_ANFpoolName} \
--service-level Premium \
--size 4 \
--tags owner=${_azureOwner} project=${_azureProject} \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles pool create ${_ANFpoolName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Create the ANF Volume
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles volume create ${_ANFvolumeName}..." | tee -a ${_logFile}
az netappfiles volume create \
--account-name ${_ANFaccountName} \
--pool-name ${_ANFpoolName} \
--volume-name ${_ANFvolumeName} \
--file-path ${_ANFvolumeName}\
--usage-threshold 500 \
--vnet ${_vnetName} \
--subnet ${_ANFsubnetName} \
--protocol-types NFSv3 \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles volume create ${_ANFvolumeName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Add a rule to the NFS export policy for our VM at index 2
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles volume export-policy create for ${_privateipAddr}..." | tee -a ${_logFile}
az netappfiles volume export-policy add \
--account-name ${_ANFaccountName} \
--pool-name ${_ANFpoolName} \
--volume-name ${_ANFvolumeName} \
--allowed-clients ${_privateipAddr} \
--rule-index 2 \
--nfsv41 false \
--nfsv3 true \
--cifs false \
--unix-read-only false \
--unix-read-write true \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles volume export-policy create for ${_privateipAddr}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Remove the default rule from the volume export policy at index 1
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles volume export-policy remove for 0.0.0.0/0..." | tee -a ${_logFile}
az netappfiles volume export-policy remove \
--account-name ${_ANFaccountName} \
--pool-name ${_ANFpoolName} \
--volume-name ${_ANFvolumeName} \
--rule-index 1 \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles volume export-policy remove for 0.0.0.0/0" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
## Get the Azure NetApp Files endpoint IP address
#--------------------------------------------------------------------------------
echo "`date` - INFO: az netappfiles volume show ${_ANFvolumeName}..." | tee -a ${_logFile}
_ANFipAddr=`az netappfiles volume show \
--account-name ${_ANFaccountName} \
--pool-name ${_ANFpoolName} \
--volume-name ${_ANFvolumeName} | \
jq '.mountTargets[0].ipAddress' | \
sed 's/"//g'`
if (( $? != 0 )); then
echo "`date` - FAIL: az netappfiles volume show ${_ANFvolumeName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the first VM to mount the newly created Azure NetApp Files
# NFS volume in which the Oracle database files will reside...
#--------------------------------------------------------------------------------
echo "`date` - INFO: mount ${_ANFvolumeName} on ${_vmName}..." | tee -a ${_logFile}
ssh -o StrictHostKeyChecking=no ${_azureOwner}@${_ipAddr} "\
sudo mount -t nfs \
-o rw,bg,hard,vers=3,proto=tcp,timeo=600,rsize=65536,wsize=65536 \
${_ANFipAddr}:/${_ANFvolumeName} ${_oraMntDir}"
if (( $? != 0 )); then
echo "`date` - FAIL: mount ${_ANFvolumeName} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#--------------------------------------------------------------------------------
# SSH into the first VM to set the OS account:group ownership of the
# directory mount-point...
#--------------------------------------------------------------------------------
echo "`date` - INFO: chown ${_oraMntDir} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo chown ${_oraOsAcct}:${_oraOsGroup} ${_oraMntDir}"
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chown ${_oraMntDir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
else # ...else if _nbrDataDisks > 0, then use managed disks for database storage...
#
#--------------------------------------------------------------------------------
# SSH into the first VM to install the "LVM2" package using the Linux "yum"
# utility...
#--------------------------------------------------------------------------------
echo "`date` - INFO: yum install lvm2 on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo yum install -y lvm2" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: yum install lvm2 on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Loop to attach the specified number of data disks...
#--------------------------------------------------------------------------------
typeset -i _diskAttached=0
_pvList=""
while (( ${_diskAttached} < ${_vmDataDiskNbr} )); do
#
#------------------------------------------------------------------------
# Increment the counter of attached data disks...
#------------------------------------------------------------------------
typeset -i _diskAttached=${_diskAttached}+1
_diskNbr="`echo ${_diskAttached} | awk '{printf("%02d\n",$1)}'`"
#
#------------------------------------------------------------------------
# Create and attach a data disk to the VM...
#------------------------------------------------------------------------
echo "`date` - INFO: az vm disk attach (${_vmName}-datadisk${_diskNbr})..." | tee -a ${_logFile}
az vm disk attach \
--new \
--name ${_vmName}-datadisk${_diskNbr} \
--vm-name ${_vmName} \
--caching ReadOnly \
--size-gb ${_vmDataDiskSzGB} \
--sku Premium_LRS \
--verbose >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: az vm disk create ${_vmName} (${_diskAttached})" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# Identify the name of the SCSI device from the array initialized at the
# beginning of the script, and derive the name of the single partition on
# the SCSI device, then add to the list of SCSI partitions for later use...
#------------------------------------------------------------------------
_scsiDev="/dev/${_scsiDevList[${_diskAttached}]}"
_pvName="${_scsiDev}1"
_pvList="${_pvList}${_pvName} "
#
#------------------------------------------------------------------------
# SSH into the VM to create a GPT label on the SCSI device...
#------------------------------------------------------------------------
echo "`date` - INFO: parted ${_scsiDev} mklabel on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo parted ${_scsiDev} mklabel gpt" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: parted ${_scsiDev} mklabel gpt on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# SSH into the VM to create a single primary partitition consuming the
# entire SCSI device...
#------------------------------------------------------------------------
echo "`date` - INFO: parted ${_scsiDev} mkpart primary on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo parted -a opt ${_scsiDev} mkpart primary ext4 0% 100%" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: yum parted mkpart -a opt ${_scsiDev} primary ext4 0% 100% on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# SSH into the VM to create a physical partition from the SCSI partition...
#------------------------------------------------------------------------
echo "`date` - INFO: pvcreate ${_pvName} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo pvcreate ${_pvName}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: pvcreate ${_pvName} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
done
#
#--------------------------------------------------------------------------------
# Create a volume group from the list of physcial volumes...
#--------------------------------------------------------------------------------
echo "`date` - INFO: vgcreate ${_vgName} ${_pvList} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo vgcreate ${_vgName} ${_pvList}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: vgcreate ${_vgName} ${_pvList} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Obtain the PE Size and Total # of PEs in the volume group, to obtain the size
# (in MiB) of all the physical volumes in the volume group, which will be the
# size of the soon-to-be-created logical volume...
#--------------------------------------------------------------------------------
echo "`date` - INFO: vgdisplay ${_vgName} on ${_vmName}..." | tee -a ${_logFile}
_peTotal=`ssh ${_azureOwner}@${_ipAddr} "sudo vgdisplay ${_vgName} | grep 'Total PE' | awk '{print \\\$3}'"`
if (( $? != 0 )); then
echo "`date` - FAIL: vgdisplay ${_vgName} | grep 'Total PE' on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
_peSize=`ssh ${_azureOwner}@${_ipAddr} "sudo vgdisplay ${_vgName} | grep 'PE Size' | awk '{print \\\$3}'"`
if (( $? != 0 )); then
echo "`date` - FAIL: vgdisplay ${_vgName} | grep 'PE Size' on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
typeset -i _lvSize=`echo ${_peTotal} ${_peSize} | awk '{printf("%d\n",$1*$2)}'`
if (( $? != 0 )); then
echo "`date` - FAIL: awk '{printf(${_peTotal} * ${_peSize})" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the VM to create a logical volume from the allocated data disks...
#--------------------------------------------------------------------------------
echo "`date` - INFO: lvcreate ${_vgName} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo lvcreate -n ${_lvName} -i ${_vmDataDiskNbr} -I 1024k -L ${_lvSize}m ${_vgName} ${_pvList}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: lvcreate -n ${_lvName} -i ${_vmDataDiskNbr} -I 1024k -L ${_lvSize}m ${_vgName} ${_pvList} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the VM to create an EXT4 filesystem on the logical volume...
#--------------------------------------------------------------------------------
echo "`date` - INFO: mkfs.ext4 /dev/${_vgName}/${_lvName} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo mkfs.ext4 /dev/${_vgName}/${_lvName}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: mkfs.ext4 /dev/${_vgName}/${_lvName} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the VM to mount the filesystem on "/u02"...
#--------------------------------------------------------------------------------
echo "`date` - INFO: mount /dev/${_vgName}/${_lvName} ${_oraMntDir} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo mount /dev/${_vgName}/${_lvName} ${_oraMntDir}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: mount /dev/${_vgName}/${_lvName} ${_oraMntDir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
fi
#
#------------------------------------------------------------------------
# SSH into first VM to create sub-directories for the Oracle database
# files and for the Oracle Flash Recovery Area (FRA) files...
#------------------------------------------------------------------------
echo "`date` - INFO: mkdir ${_oraDataDir} ${_oraFRADir} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo mkdir -p ${_oraDataDir} ${_oraFRADir}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo mkdir -p ${_oraDataDir} ${_oraFRADir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#------------------------------------------------------------------------
# SSH into the VM to set the OS account:group ownership of the sub-directories
# within the newly-created filesystem...
#------------------------------------------------------------------------
echo "`date` - INFO: chown ${_oraDataDir} ${_oraFRADir} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo chown ${_oraOsAcct}:${_oraOsGroup} ${_oraDataDir} ${_oraFRADir}" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chown ${_oraDataDir} ${_oraFRADir} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the first VM to copy the file "oraInst.loc" from the current Oracle
# Inventory default location into the "/etc" system directory, where it can be
# easily found by any Oracle programs accessing the host. Set the ownership and
# permissions appropriately for the copied file...
#--------------------------------------------------------------------------------
echo "`date` - INFO: copy oraInst.loc file on ${_vmName}" | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo cp ${_oraInvDir}/oraInst.loc /etc" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo cp ${_azureOwner}@${_ipAddr}:${_oraInvDir}/oraInst.loc /etc" | tee -a ${_logFile}
exit 1
fi
ssh ${_azureOwner}@${_ipAddr} "sudo chown ${_oraOsAcct}:${_oraOsGroup} /etc/oraInst.loc" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chown ${_oraOsAcct}:${_oraOsGroup} /etc/oraInst.loc" | tee -a ${_logFile}
exit 1
fi
ssh ${_azureOwner}@${_ipAddr} "sudo chmod 644 /etc/oraInst.loc" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chmod 644 /etc/oraInst.loc" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# SSH into the first VM to run the Oracle Database Creation Assistant (DBCA)
# program to create a new primary Oracle database...
#--------------------------------------------------------------------------------
echo "`date` - INFO: sudo su - ${_oraOsAcct} dbca -createDatabase ${_oraSid} on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo su - ${_oraOsAcct} -c \"\
export ORACLE_SID=${_oraSid}
export ORACLE_HOME=${_oraHome}
export PATH=${_oraHome}/bin:\${PATH}
unset TNS_ADMIN
dbca -silent -createDatabase \
-gdbName ${_oraSid} \
-templateName ${_oraHome}/assistants/dbca/templates/General_Purpose.dbc \
-sid ${_oraSid} \
-sysPassword ${_oraSysPwd} \
-systemPassword ${_oraSysPwd} \
-characterSet ${_oraCharSet} \
-createListener LISTENER:${_oraLsnrPort} \
-storageType FS \
-datafileDestination ${_oraDataDir} \
-enableArchive TRUE \
-memoryMgmtType ${_oraMemType} \
-memoryPercentage ${_oraMemPct} \
-initParams db_create_online_log_dest_1=${_oraFRADir} \
-recoveryAreaDestination ${_oraFRADir} \
-recoveryAreaSize ${_oraFraSzGB} \
-redoLogFileSize ${_oraRedoSizeMB}\"" | tee -a ${_logFile}
if (( $? != 0 )); then
echo "`date` - FAIL: sudo su - ${_oraOsAcct} dbca -createDatabase ${_oraSid} on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Create the "oradata" subdirectory on the temporary disk within the "/mnt/resource"
# directory of the Linux VM, owned by the Oracle OS account...
#--------------------------------------------------------------------------------
echo "`date` - INFO: mkdir /mnt/resource/oradata on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo mkdir /mnt/resource/oradata" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo mkdir /mnt/resource/oradata on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
echo "`date` - INFO: chown ${_oraOsAcct}:${_oraOsGroup} /mnt/resource/oradata on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo chown ${_oraOsAcct}:${_oraOsGroup} /mnt/resource/oradata" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo chown ${_oraOsAcct}:${_oraOsGroup} /mnt/resource/oradata on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
echo "`date` - INFO: mkdir -p /mnt/resource/oradata on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo mkdir -p /mnt/resource/oradata" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: sudo mkdir -p /mnt/resource/oradata on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Create a "temporary use" temporary tablespace (named TEMPTMPTEMP), make it
# default, then drop and recreate the TEMP tablespace on the VM temporary disk,
# then make TEMP the default and clean up the "temporary use" TEMPTMPTEMP
# tablespace...
#--------------------------------------------------------------------------------
echo "`date` - INFO: move TEMP tablespace to temporary disk on ${_vmName}..." | tee -a ${_logFile}
ssh ${_azureOwner}@${_ipAddr} "sudo su - ${_oraOsAcct} -c \"
export ORACLE_SID=${_oraSid}
export ORACLE_HOME=${_oraHome}
export PATH=${_oraHome}/bin:\${PATH}
unset TNS_ADMIN
sqlplus -S -L / as sysdba << __EOF__
whenever oserror exit failure
whenever sqlerror exit failure
alter session set db_create_file_dest='/mnt/resource/oradata';
create temporary tablespace temptmptemp tempfile size 10M;
alter database default temporary tablespace temptmptemp;
drop tablespace temp including contents and datafiles;
create temporary tablespace temp
tempfile size 512M autoextend on next 512M maxsize unlimited
extent management local uniform size 1M;
alter database default temporary tablespace temp;
drop tablespace temptmptemp including contents and datafiles;
exit success
__EOF__\"" >> ${_logFile} 2>&1
if (( $? != 0 )); then
echo "`date` - FAIL: move TEMP tablespace to temporary disk on ${_vmName}" | tee -a ${_logFile}
exit 1
fi
#
#--------------------------------------------------------------------------------
# Completed the setup successfully! End of program...
#--------------------------------------------------------------------------------
echo "`date` - INFO: completed successfully!" | tee -a ${_logFile}
exit 0