-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure-node.sh
116 lines (93 loc) · 2.43 KB
/
configure-node.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
#!/bin/bash
#output commands (i.e. turn debug info on/off)
#set -x
#enable fg and bg commands
set -m
#run couchbase in the background so server can be configured
/entrypoint.sh couchbase-server &
sleep 15
echo "initializing cluster..."
couchbase-cli cluster-init -c $CB_HOST \
--cluster-name demo \
--cluster-username $CB_USER \
--cluster-password $CB_PASSWORD \
--cluster-ramsize 512 \
--cluster-index-ramsize 256 \
--cluster-fts-ramsize 256 \
--services data,index,query,fts
sleep 3
couchbase-cli server-list -c $CB_HOST -u $CB_USER -p $CB_PASSWORD
echo "cluster initialized. URL: $CB_URL"
sleep 3
#create bucket
couchbase-cli bucket-create -c $CB_URL \
--username $CB_USER \
--password $CB_PASSWORD \
--bucket $CB_BUCKET \
--bucket-type couchbase \
--bucket-ramsize 256
sleep 3
echo "loading bucket data..."
unzip /opt/couchbase/retailsample_data.zip -d /opt/couchbase
count=1
while [ $count -le 5 ]
do
if [ -f /opt/couchbase/customers.json ]; then
break
fi
sleep 3
((count++))
done
#add customer documents
echo "importing customer documents..."
/opt/couchbase/bin/cbimport json -c couchbase://${CB_HOST} \
-u $CB_USER \
-p $CB_PASSWORD \
-b $CB_BUCKET \
-d file:///opt/couchbase/customers.json \
-f list \
-g customer_%custId% \
-t 4
rm /opt/couchbase/customers.json
#add user documents
echo "importing user documents..."
/opt/couchbase/bin/cbimport json -c couchbase://${CB_HOST} \
-u $CB_USER \
-p $CB_PASSWORD \
-b $CB_BUCKET \
-d file:///opt/couchbase/users.json \
-f list \
-g user_%userId% \
-t 4
rm /opt/couchbase/users.json
#add order documents
echo "importing order documents..."
/opt/couchbase/bin/cbimport json -c couchbase://${CB_HOST} \
-u $CB_USER \
-p $CB_PASSWORD \
-b $CB_BUCKET \
-d file:///opt/couchbase/orders.json \
-f list \
-g order_%orderId% \
-t 4
rm /opt/couchbase/orders.json
#add product documents
echo "importing product documents..."
/opt/couchbase/bin/cbimport json -c couchbase://${CB_HOST} \
-u $CB_USER \
-p $CB_PASSWORD \
-b $CB_BUCKET \
-d file:///opt/couchbase/products.json \
-f list \
-g product_%prodId% \
-t 4
rm /opt/couchbase/products.json
echo "creating indexes..."
cbq -e couchbase://${CB_HOST} \
-u $CB_USER \
-p $CB_PASSWORD \
-f=/opt/couchbase/indexes.txt
echo "creating FTS index..."
curl -u $CB_USER:$CB_PASSWORD -XPUT http://$CB_HOST:8094/api/index/basic-search -H "Content-type:application/json" -d @/opt/couchbase/basic_search_idx.json
#resume couchbase job in the foreground
fg 1