-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstep_1_master_prep.sh
executable file
·119 lines (103 loc) · 5.3 KB
/
step_1_master_prep.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
echo "Installing Files"
apt-get install rsync -y
echo "Generating SSH keys"
mkdir /root/.ssh
cat >/root/.ssh/id_rsa <<EOL
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAwAHi2lgn5e3qVb5HyldOLk+loqqiGU6ebGYQnucNdA/dme3Z
L8/jugOAlTJ72rP3QP5u4WuxWiixMasevYT8xoiSdOM7VKjBoBMaD51+5DAMtXHA
T6jPG5Bxd2yTjlCXKx91Anju3bnTi63RWN2+ALe33T6mx3l8M8JaYjC0XR37hDjf
Agmp1Ucu/gSnNS8geo3lTHu+QfUDLlrcHB4FKQMj1KRUiZL55LMBChDRAb6Hg2P0
fzeTZH0F9tlvAsG3Q6ayyVH5H9KkEpEm3zZNHOTkmHiWmt5XXiPbuEPF74NBTInd
WMEwku+5DKXKTxcI49ru+sxAQrdmCp45NF7ptwIDAQABAoIBAQCsMkTX2s3VaJyL
Tz4lGk1UPTvn+a2skpSD1Lk9OSwYlY4A2Y25UnECRtfPdlobVuD9GfIpGiMRH4Ni
bvv/rb/g8WSfjZaNI1ebDuaFcJL3ZJxRMXXuOw+awdzw5KAktuQL2Ydfs0NN+LTf
BQDF+P/ItvsfYWvDY5Fe/gN/IfzvsD5MaTZdGOcVAyTZKzgNHkEUo6KOYQeD1BqS
2ZRb1wmEyuIZkGwgQDEMWwYJ2xuX1kiw+E8ajDtcIqV/S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AADAQABAAABAQDAAeLaWCfl7epVvkfKV04uT6WiqqIZTp5sZhCe5w10D92Z7dkvz+O6A4CVMnvas/dA/m7ha7FaKLExqx69hPzGiJJ04ztUqMGgExoPnX7kMAy1ccBPqM8bkHF3bJOOUJcrH3UCeO7dudOLrdFY3b4At7fdPqbHeXwzwlpiMLRdHfuEON8CCanVRy7+BKc1LyB6jeVMe75B9QMuWtwcHgUpAyPUpFSJkvnkswEKENEBvoeDY/R/N5NkfQX22W8CwbdDprLJUfkf0qQSkSbfNk0c5OSYeJaa3ldeI9u4Q8Xvg0FMid1YwTCS77kMpcpPFwjj2u76zEBCt2YKnjk0Xum3 oracle@ada530e07737
EOL
chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa
chmod 644 /root/.ssh/id_rsa.pub
chown -R oracle:dba /u01/app/oracle/.ssh
chmod 700 /u01/app/oracle/.ssh
chmod 600 /u01/app/oracle/.ssh/id_rsa
chmod 644 /u01/app/oracle/.ssh/id_rsa.pub
echo "Enable archivelog mode"
sqlplus sys/oracle as sysdba << EOL
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
EOL
echo "Pointing database to new archivelog location"
mkdir /archivelog
chown oracle:dba /archivelog/
sqlplus sys/oracle as sysdba << EOL
alter system set db_recovery_file_dest='/archivelog' scope=both;
EOL
echo "Taking cold backup"
sqlplus sys/oracle as sysdba << EOL
shutdown immediate;
create pfile='/archivelog/initXE.ora' from spfile;
EOL
pushd /u01/app/oracle/oradata/XE/
tar zcvf masterdata.tgz *.dbf
mv masterdata.tgz /archivelog/
popd
echo "Create standby controlfile"
sqlplus sys/oracle as sysdba << EOL
startup;
alter database create standby controlfile as '/archivelog/stbycf.ctl';
EOL