-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·195 lines (170 loc) · 8.64 KB
/
install.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
#!/QOpenSys/pkgs/bin/bash
PATH=/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:$PATH
export PATH
export WLP_SKIP_UMASK=true
cd $(dirname $0)
echo "Using source directory $SRCDIR"
export JAVA_HOME="/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit"
: ${INSTALLDIR="/QOpenSys/OCPDT_demo/"}
: ${INSTALLSCHEMA="OCPDT"}
INSTALLSCHEMA=$(echo $INSTALLSCHEMA | tr -cd '[:alnum:]' | tr '[:lower:]' '[:upper:]'| head -c 10)
LIBERTY_SERVER="dt7server"
USRPRF_PW=$(cat /dev/urandom | tr -cd '[A-Z0-9]' | head -c 10)
: ${INSTALLUSER="$INSTALLSCHEMA"}
#INSTALLUSER=$(echo $INSTALLUSER | tr -cd '[:alnum:]' | tr '[:lower:]' '[:upper:]')
INSTALLUSER=$INSTALLSCHEMA
set -e
echo "==============================================="
echo " Installing to directory $INSTALLDIR..."
echo " Installing to schema $INSTALLSCHEMA..."
echo " Creating user profile $INSTALLUSER... "
echo "==============================================="
sleep 4
mkdir -p $INSTALLDIR
cd $INSTALLDIR
echo "==============================================="
echo " Installing requisite open source packages..."
echo "==============================================="
#OFFLINE_COPY_HERE
yum install ca-certificates-mozilla
yum install wget unzip gzip git tar-gnu openjdk-11 maven coreutils-gnu sed-gnu grep-gnu https://github.com/ThePrez/ServiceCommander-IBMi/releases/download/v0.3.4/sc-0.4.1-0.ibmi7.2.ppc64.rpm
hash -r
echo "==============================================="
echo " Fetching AI Sample Code..."
echo "==============================================="
rm -rf Kafka-DayTrader-AI-example* example.zip
curl -L https://github.com/ThePrez/Kafka-DayTrader-AI-example/archive/refs/heads/main.zip -o example.zip
unzip example.zip
mv Kafka-DayTrader-AI-example-main Kafka-DayTrader-AI-example
echo "==============================================="
echo " Creating $INSTALLUSER user..."
echo "==============================================="
[ -e /qsys.lib/$INSTALLUSER.usrprf ] || system -i "crtusrprf USRPRF($INSTALLUSER) PASSWORD($USRPRF_PW)"
system -i "chgusrprf USRPRF($INSTALLUSER) PASSWORD($USRPRF_PW)"
echo "==============================================="
echo " Downloading Apache JMeter..."
echo "==============================================="
wget -c https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.0.tgz -O jmeter.tgz
echo "==============================================="
echo " Installing Apache JMeter..."
echo "==============================================="
[ -e jmeter ] || mkdir jmeter
tar xzf jmeter.tgz --strip-components 1 -C jmeter
sed -i "s|-server||g" jmeter/bin/jmeter
cp Kafka-DayTrader-AI-example/jmeter/jmeter.properties jmeter/bin
echo "==============================================="
echo " Downloading Apache JMeter extensions..."
echo "==============================================="
wget -c https://github.com/kawasima/jmeter-websocket/archive/refs/heads/master.zip -O jmeter-websocket.zip
echo "==============================================="
echo " Building+installing Apache JMeter extensions..."
echo "==============================================="
wget -c https://github.com/kawasima/jmeter-websocket/archive/refs/heads/master.zip -O jmeter-websocket.zip
unzip -uoq jmeter-websocket.zip
pushd jmeter-websocket-master
mvn validate compile package
popd
cp jmeter-websocket-master/target/ApacheJmeter_websocket-dist-0.1.0-SNAPSHOT.jar jmeter/lib/ext
echo "==============================================="
echo " Downloading Liberty..."
echo "==============================================="
wget -c https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/release/2021-07-27_1323/openliberty-javaee8-21.0.0.8.zip -O openliberty.zip
echo "==============================================="
echo " Installing Liberty..."
echo "==============================================="
rm -fr wlp
unzip -uoq openliberty.zip
echo "==============================================="
echo " Building DayTrader..."
echo "==============================================="
[ -d dt7_build ] || mkdir -p dt7_build
wget -c https://github.com/jdmcclur/sample.daytrader7/archive/refs/heads/stock-dataset.zip -O sample.daytrader7.zip
pushd dt7_build
[ -d sample.daytrader7 ] || unzip -uoq ../sample.daytrader7.zip
[ -d sample.daytrader7 ] || mv sample.daytrader7-stock-dataset sample.daytrader7
pushd sample.daytrader7
mvn package
cp daytrader-ee7/target/daytrader-ee7.ear $INSTALLDIR
cp jmeter_files/*.jmx $INSTALLDIR
popd
popd
cp Kafka-DayTrader-AI-example/jmeter/*.jmx .
echo "==============================================="
echo " Creating DayTrader Server..."
echo "==============================================="
rm -fr $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER
wlp/bin/server create $LIBERTY_SERVER
echo "==============================================="
echo " Installing DayTrader application..."
echo "==============================================="
mkdir -p $INSTALLDIR/wlp/usr/shared/apps/
mv daytrader-ee7.ear $INSTALLDIR/wlp/usr/shared/apps/
echo "==============================================="
echo " Configuring DayTrader application..."
echo "==============================================="
cp Kafka-DayTrader-AI-example/daytrader/server.xml $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER
sed -i "s|/home/OCPDT/|$INSTALLDIR/|gi" $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER/server.xml
sed -i -E "s|libraries=\"[^\"]+\"|libraries=\"$INSTALLSCHEMA\"|gi" $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER/server.xml
sed -i -E "s|user=\"[^\"]+\"|user=\"$INSTALLUSER\"|gi" $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER/server.xml
sed -i -E "s|password=\"[^\"]+\"|password=\"$USRPRF_PW\"|gi" $INSTALLDIR/wlp/usr/servers/$LIBERTY_SERVER/server.xml
$INSTALLDIR/wlp/bin/featureUtility installServerFeatures $LIBERTY_SERVER
echo "==============================================="
echo " Installing Service Commander files..."
echo "==============================================="
mkdir -p $HOME/.sc/services
cp Kafka-DayTrader-AI-example/sc/*.y*ml $HOME/.sc/services
find $HOME/.sc/services -name \*.yaml -print -exec sed -i "s|/home/OCPDT/|$INSTALLDIR/|gi" {} \;
echo "==============================================="
echo " Initializing Daytrader database..."
echo "==============================================="
[ -e /qsys.lib/$INSTALLSCHEMA.lib ] || system "RUNSQL SQL('create schema $INSTALLSCHEMA') COMMIT(*NONE)"
system -i "CHGOWN OBJ('/qsys.lib/$INSTALLSCHEMA.lib') NEWOWN($INSTALLUSER) RVKOLDAUT(*NO) SUBTREE(*ALL)" || true
echo "==============================================="
echo " Starting Daytrader application..."
echo "==============================================="
sc restart daytrader
echo "==============================================="
echo " Setting up DayTrader database..."
echo "==============================================="
sleep 12
curl http://localhost:10200/daytrader/config?action=buildDBTables
curl http://localhost:10200/daytrader/config?action=buildDB
echo "==============================================="
echo " Stopping Daytrader aplication..."
echo "==============================================="
sc stop daytrader
echo "==============================================="
echo " Downloading Kafka and Zookeeper..."
echo "==============================================="
wget -c https://downloads.apache.org/kafka/3.3.1/kafka_2.13-3.3.1.tgz -O kafka.tgz
echo "==============================================="
echo " Installing Kafka and Zookeeper..."
echo "==============================================="
[ -e kafka ] || mkdir kafka
tar xzf kafka.tgz --strip-components 1 -C kafka
echo "==============================================="
echo " Creating DTAQ+trigger in $INSTALLSCHEMA..."
echo "==============================================="
[ -e /qsys.lib/$INSTALLSCHEMA.lib/AI.DTAQ ] || system "CRTDTAQ DTAQ($INSTALLSCHEMA/AI) MAXLEN(64512) SIZE(*MAX2GB)" || true
sed -i "s|OCPDT|$INSTALLSCHEMA|gi" Kafka-DayTrader-AI-example/trigger/create_trigger.sql
system "RUNSQLSTM SRCSTMF('Kafka-DayTrader-AI-example/trigger/create_trigger.sql')"
echo "==============================================="
echo " Building Camel application..."
echo "==============================================="
pushd Kafka-DayTrader-AI-example/camel
sed -i "s|OCPDT|$INSTALLSCHEMA|gi" src/main/resources/config.properties
mvn compile
popd
echo ''
echo 'DONE!!'
echo ' Demo has been installed to:'
echo " Schema '$INSTALLSCHEMA'"
echo " Directory '$INSTALLDIR'"
echo ""
echo " To start the demo, sign in as $(id -un) and run:"
echo ' /QOpenSys/pkgs/bin/sc start group:aikafka'
echo " To stop the demo, sign in as $(id -un) and run:"
echo ' /QOpenSys/pkgs/bin/sc stop group:aikafka'
echo ' To stress test with Apache JMeter:'
echo " $INSTALLDIR/jmeter/bin/jmeter -n -t $INSTALLDIR/daytrader7.jmx -JHOST=127.0.0.1 -JPORT=10200 -JTHREADS=10 -JDURATION=120 -l jmeter_log.txt"
echo ''