Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#verify nodeport service exists
ubuntu@k8s-s1-master:~$ kubectl get svc -n onap | grep mysql
mysql-nodeport NodePort 10.107.197.242 <none> 3306:30031/TCP,3307:30032/TCP 29s
ubuntu@k8s-s1-master:~$
  
#verify the endpoints are assigned for the service
#make a note of Node Port Number to beuse used in step#5
ubuntu@k8s-s1-master:~$ kubectl describe svc mysql-nodeport -n onap
Name:                     mysql-nodeport
Namespace:                onap
Labels:                   statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Annotations:              <none>
Selector:                 statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Type:                     NodePort
IP:                       10.107.197.242
Port:                     sdnc-dbhost-0-port-3306  3306/TCP
TargetPort:               3306/TCP
NodePort:                 sdnc-dbhost-0-port-3306  30231/TCP
Endpoints:                10.44.0.3:3306
Port:                     sdnc-dbhost-0-port-3307  3307/TCP
TargetPort:               3307/TCP
NodePort:                 sdnc-dbhost-0-port-3307  30232/TCP
Endpoints:                10.44.0.3:3307
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
ubuntu@k8s-s1-master:~$


4. Create node port service (optional, need basis).Create NodePort service on both sites in "onap" namespace. Make sure the kubectl version is 1.9x. Use attached - mysql-nodeport.yaml.

Info

You can skip this step if the node port service are verified in step #3 . This step is to be followed on both sites.already exists.

Code Block
ubuntu@k8s-s1-master:~$ cat mysql-nodeport.yaml
apiVersion: v1
kind: Service
metadata:
  name: mysql-nodeport
  namespace: "onap"
  labels:
    statefulset.kubernetes.io/pod-name: sdnc-dbhost-0
spec:
  ports:
  - name: "sdnc-dbhost-0-port-3306"
    port: 3306
    targetPort: 3306
    nodePort: 30231
  - name: "sdnc-dbhost-0-port-3307"
    port: 3307
    targetPort: 3307
    nodePort: 30232
  type: NodePort
  selector:
    statefulset.kubernetes.io/pod-name: sdnc-dbhost-0
ubuntu@k8s-s1-master:~$
 
#create nodeport service
ubuntu@k8s-s1-master:~$ kubectl create -f mysql-nodeport.yaml
service "mysql-nodeport" created
 
#verify created service
ubuntu@k8s-s1-master:~$ kubectl get svc -n onap | grep mysql-nodeport
mysql-nodeport NodePort 10.107.197.242 <none> 3306:30031/TCP,3307:30032/TCP 29s
ubuntu@k8s-s1-master:~$
 
#verify the endpoints are assigned for the service
ubuntu@k8s-s1-master:~$ kubectl describe svc mysql-nodeport -n onap
Name:                     mysql-nodeport
Namespace:                onap
Labels:                   statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Annotations:              <none>
Selector:                 statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Type:                     NodePort
IP:                       10.107.197.242
Port:                     sdnc-dbhost-0-port-3306  3306/TCP
TargetPort:               3306/TCP
NodePort:                 sdnc-dbhost-0-port-3306  30231/TCP
Endpoints:                10.44.0.3:3306
Port:                     sdnc-dbhost-0-port-3307  3307/TCP
TargetPort:               3307/TCP
NodePort:                 sdnc-dbhost-0-port-3307  30232/TCP
Endpoints:                10.44.0.3:3307
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
ubuntu@k8s-s1-master:~$

...

Code Block
#Login to the master db pod
ubuntu@k8s-s1-master:~$ kubectl exec -it sdnc-dbhost-0 -n onap bash
Defaulting container name to sdnc-db-container.
Use 'kubectl describe pod/sdnc-dbhost-0' to see all of the containers in this pod.

#Login to mysql
root@sdnc-dbhost-0:/etc/mysql/conf.d# mysql -u root -popenECOMP1.0 
mysql: [Warning] Using a password on the command line interface can be insecure. 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 46083 Server version: 5.7.21-log MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. 
 
Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql>
 
#find out log bin position
mysql> show master status;
+--------------------------+----------+--------------+------------------+-------------------+
| File                     | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+--------------------------+----------+--------------+------------------+-------------------+
| sdnc-dbhost-0-bin.000004 | 154      | |              |                  |                   |
+--------------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>


#Set: 
# - "master_host" to peer site's 'K8S master node' IP address
# - "master_port" to port number of the NodePort service (from step#3)
# - "master_user" to user name (here 'root')
# - "master_password" to user's password (here 'root' user's default password)
# - "master_log_file" to log_file name from "show master status" commands on the peer site (Primary)
# - "master_log_pos" to log_position from "show master status" commands on the peer site (Primary)
mysql> CHANGE MASTER TO master_host='10.147.112.136', master_port=30231, master_user='root', master_password='openECOMP1.0', master_log_file='sdnc-dbhost-0-bin.000002', master_log_pos=37433012;
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql>

...

Code Block
#Login to the master db pod
ubuntu@k8s-s1-master:~$ kubectl exec -it sdnc-dbhost-0 -n onap bash
Defaulting container name to sdnc-db-container.
Use 'kubectl describe pod/sdnc-dbhost-0' to see all of the containers in this pod.

#Login to mysql
root@sdnc-dbhost-0:/etc/mysql/conf.d# mysql -u root -popenECOMP1.0 
mysql: [Warning] Using a password on the command line interface can be insecure. 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 46083 Server version: 5.7.21-log MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. 
Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
mysql>
 
#find out log bin position
mysql> show master status;
+--------------------------+----------+--------------+------------------+-------------------+
| File                     | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+--------------------------+----------+--------------+------------------+-------------------+
| sdnc-dbhost-0-bin.000003 | 37433012 |              |                  |                   |
+--------------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>


#Set: 
# - "master_host" to peer site's 'K8S master node' IP address
# - "master_port" to port number of the NodePort service (from step#3)
# - "master_user" to user name (here 'root')
# - "master_password" to user's password (here 'root' user's default password)
# - "master_log_file" to log_file name from "show master status" commands on peer site (Seconday)
# - "master_log_pos" to log_position from "show master status" commands on the peer site (Seconday)
mysql> CHANGE MASTER TO master_host='10.147.113.36', master_port=30231, master_user='root', master_password='openECOMP1.0', master_log_file='sdnc-dbhost-0-bin.000004',master_log_pos=154;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql>

...