forked from rhtconsulting/redis-sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Implementation Guide
115 lines (80 loc) · 3.63 KB
/
Implementation Guide
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
Creating image and pushing to openshift registry.
Execute from image directory:
```bash
# chmod 777 run.sh
# docker build -t redis2 .
# docker build -t redis-sentinel .
```
From Project File directory:
```bash
# oc login -u system:admin
# oc project default
# oc get service
# docker tag redis2 172.30.176.178:5000/openshift/redis2
# docker tag redis-sentinel 172.30.176.178:5000/openshift/redis-sentinel
# oc create -f image_stream.json -n openshift
# oc create -f image_stream-sentinel.json -n openshift
# oadm policy add-role-to-user system:image-builder shah -n openshift
# oadm policy add-role-to-user system:image-puller shah -n openshift
# oadm policy add-role-to-user system:deployer shah -n openshift
# oc login -u shah
# oc whoami -t
# docker login -u shah -e a@b.com -p pqycDOetHoVU8IybkTrezS1_jh2dt8Dx2oS-_ALtw98 172.30.176.178:5000
# docker push 172.30.176.178:5000/openshift/redis2
# docker push 172.30.176.178:5000/openshift/redis-sentinel
# oc login -u system:admin
# oc get images | grep redis
```
In nfs:
```bash
#mkdir /opt/nfs/red
#chown nfsnobody.nfsnobody /opt/nfs/red
#chown -R nfsnobody.nfsnobody /opt/nfs/red
#chmod 775 /opt/nfs/red
#mkdir /opt/nfs/redis-sentinel
#chown nfsnobody.nfsnobody /opt/nfs/redis-sentinel
#chown -R nfsnobody.nfsnobody /opt/nfs/redis-sentinel
#chmod 775 /opt/nfs/redis-sentinel
#vi /etc/exports:
/opt/nfs/red infranode00-640a.oslab.opentlc.com(all_squash,rw,sync) infranode01-640a.oslab.opentlc.com(all_squash,rw,sync)
/opt/nfs/red node00-640a.oslab.opentlc.com(all_squash,rw,sync) node01-640a.oslab.opentlc.com(all_squash,rw,sync)
/opt/nfs/redis-sentinel infranode00-640a.oslab.opentlc.com(all_squash,rw,sync) infranode01-640a.oslab.opentlc.com(all_squash,rw,sync)
/opt/nfs/redis-sentinel node00-640a.oslab.opentlc.com(all_squash,rw,sync) node01-640a.oslab.opentlc.com(all_squash,rw,sync)
#exportfs -a
```
Creating project,pods and services
```bash
#oc login -u shah
#oc delete project redis
#oc new-project redis --display-name="Redis Sentinal Cluster" --description="This is the project of Redis Assignment"
#oc create -f redis-master-new.yaml
#oc create -f redis-sentinel-service.yaml
#oc create -f redis-service.yaml
#oc create -f redis-controller-new.yaml
#oc create -f redis-sentinel-controller-new.yaml
#oc create -f deploymentconfig-new.json
#oc login -u system:admin
#oc create -f volume_red.yaml
#oc create -f claim_red.yaml
#oc volume deploymentconfigs/redis --add --overwrite --name=myclaim2 --mount-path=/redis-master-data --source='{"nfs": { "server": "nfs00-640a", "path": "/opt/nfs/red" }}'
#oc create -f volume_redis-sentinel.yaml
#oc create -f claim_redis-sentinel.yaml
#oc volume deploymentconfigs/redis --add --overwrite --name=myclaim3 --mount-path=/redis-sentinel-data --source='{"nfs": { "server": "nfs00-640a", "path": "/opt/nfs/redis-sentinel" }}'
#oc login -u shah
#oc get pods
#oc expose service redis --hostname=redis.cloudapps-640a.oslab.opentlc.com
#oc expose service redis-sentinel --hostname=sentinel.cloudapps-640a.oslab.opentlc.com
#oc logs redis -c redis
#oc logs redis -c sentinel
#oc scale rc redis --replicas=3
#oc scale rc redis-sentinel --replicas=3
#oc delete pod redis
#oc get pods
########### TESTING ###########
#oc exec -it redis-XXXX /bin/bash
#oc exec -it redis-sentinel-XXXX /bin/bash
#oc logs redis-sentinel-XXXX [Check all, anyone of them will hold master]
#redis-cli -h ${REDIS_SENTINEL_SERVICE_HOST} -p ${REDIS_SENTINEL_SERVICE_PORT} --csv SENTINEL get-master-addr-by-name mymaster | tr ',' ' ' | cut -d' ' -f1
############# REPLACING
#sed -i 's/redis2/redis_rhel/g' redis-master-new.yaml
#sed -i 's/redis-sentinel:latest/redis-sentinel_rhel:latest/g' redis-master-new.yaml