<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Buvanesh M on Medium]]></title>
        <description><![CDATA[Stories by Buvanesh M on Medium]]></description>
        <link>https://medium.com/@buvanesh.m?source=rss-9276434cf58d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xaBXrRD4V-HpW3qmvdhG9A.jpeg</url>
            <title>Stories by Buvanesh M on Medium</title>
            <link>https://medium.com/@buvanesh.m?source=rss-9276434cf58d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:25:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@buvanesh.m/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running ProxySQL in Kubernetes in GKE]]></title>
            <link>https://blog.searce.com/running-proxysql-in-kubernetes-in-gke-c5b919e45859?source=rss-9276434cf58d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5b919e45859</guid>
            <category><![CDATA[gke]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[proxysql]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Buvanesh M]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 11:03:38 GMT</pubDate>
            <atom:updated>2023-08-07T11:23:56.918Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>ProxySQL is an open-source high-performance proxy for MySQL and MariaDB databases. It acts as an intermediary between client applications and database servers, providing advanced features such as connection pooling, query caching, load balancing, and traffic routing.</p><p>When it comes to running ProxySQL in Google Kubernetes Engine (GKE), you can leverage the flexibility and scalability of GKE to deploy and manage your ProxySQL service efficiently. Here’s an introduction to setting up ProxySQL in GKE:</p><p><strong>1. Provisioning a GKE Cluster:</strong> First, you need to create a GKE cluster to host your ProxySQL service. Use the Google Cloud Console or the command-line tool (such as `gcloud`) to create a new cluster or use an existing one.</p><p><strong>2. Configuring Kubernetes Deployment:</strong> Create a Kubernetes Deployment manifest to define the desired state of your ProxySQL instances. Specify the container image, resource requirements, environment variables, and other configuration parameters as per your needs.</p><p><strong>3. Service Discovery:</strong> ProxySQL needs to discover and connect to your MySQL or MariaDB instances. There are several ways to achieve service discovery, such as Kubernetes Services, ConfigMaps, or external service discovery mechanisms. Choose the appropriate method based on your infrastructure and requirements.</p><p><strong>4. Load Balancing: ProxySQL</strong> excels at load-balancing database traffic across multiple backend servers. Utilize Kubernetes Services to expose the ProxySQL deployment internally or externally. You can also use an Ingress controller to manage external traffic and load balancing if needed.</p><p><strong>5. Configuration Management </strong>ProxySQL offers various configuration options, including query rules, host group definitions, and connection pool settings. Consider utilizing ConfigMaps in Kubernetes to store the ProxySQL configuration file and manage it dynamically.</p><p><strong>6. Scaling and High Availability:</strong> GKE provides easy scalability and high availability options for your ProxySQL service. You can horizontally scale the ProxySQL Deployment by adjusting the replica count or use GKE’s auto-scaling capabilities. Additionally, consider using Pod Anti-Affinity rules to distribute ProxySQL instances across different nodes for improved resilience.</p><p><strong>7. Monitoring and Logging:</strong> Set up monitoring and logging solutions to gain visibility into the performance and health of your ProxySQL deployment. You can use Kubernetes-native monitoring tools like Prometheus and Grafana or integrate with external monitoring systems.</p><p><strong>8. Security Considerations</strong>: Ensure proper security measures for your ProxySQL service. Use Kubernetes secrets to store sensitive information such as database credentials. Configure network policies to control inbound and outbound traffic. Implement SSL/TLS encryption for secure connections between ProxySQL and backend servers.</p><p>By following these steps, you can deploy and manage ProxySQL efficiently in GKE, benefiting from the scalability, reliability, and automation capabilities of Kubernetes. Remember to consult the official documentation for ProxySQL and GKE for detailed implementation guidelines and best practices.</p><p><strong>Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*umaLLe6jK4ZVPkaovDOjRw.png" /><figcaption>ProxySQL in GKE load balancing the W/R traffic</figcaption></figure><h3>Preparing the Database</h3><p>Create the WordPress database and user on the master and assign with correct privilege:</p><pre>mysql-master&gt; CREATE DATABASE wordpress;<br>mysql-master&gt; CREATE USER wordpress@&#39;%&#39; IDENTIFIED BY &#39;YourStrongPassword&#39;;<br>mysql-master&gt; GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@&#39;%&#39;;</pre><p>Also, create the ProxySQL monitoring user:</p><pre>mysql-master&gt; CREATE USER proxysql@&#39;%&#39; IDENTIFIED BY &#39;YourStrongproxysqlpassw0rd&#39;;</pre><p>Then, reload the grant table:</p><pre>mysql-master&gt; FLUSH PRIVILEGES;</pre><h3>ProxySQL Pod and Service Definition</h3><p>To deploy ProxySQL as a Kubernetes Pod and expose it using a Service, you can use the following YAML definitions as a starting point. Adjust the configurations based on your specific requirements.</p><pre>apiVersion: v1<br>kind: Deployment<br>metadata:<br>  name: proxysql<br>  labels:<br>    app: proxysql<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: proxysql<br>      tier: frontend<br>  strategy:<br>    type: RollingUpdate<br>  template:<br>    metadata:<br>      labels:<br>        app: proxysql<br>        tier: frontend<br>    spec:<br>      restartPolicy: Always<br>      containers:<br>      - image: severalnines/proxysql:1.4.12<br>        name: proxysql<br>        volumeMounts:<br>        - name: proxysql-config<br>          mountPath: /etc/proxysql.cnf<br>          subPath: proxysql.cnf<br>        ports:<br>        - containerPort: 6033<br>          name: proxysql-mysql<br>        - containerPort: 6032<br>          name: proxysql-admin<br>      volumes:<br>      - name: proxysql-config<br>        configMap:<br>          name: proxysql-configmap<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: proxysql<br>  labels:<br>    app: proxysql<br>    tier: frontend<br>spec:<br>  type: NodePort<br>  ports:<br>  - nodePort: 30033<br>    port: 6033<br>    name: proxysql-mysql<br>  - nodePort: 30032<br>    port: 6032<br>    name: proxysql-admin<br>  selector:<br>    app: proxysql<br>    tier: frontend</pre><p>Let’s see what those definitions are all about. The YAML consists of two resources combined in a file, separated by “ — ” delimiter. The first resource is the Deployment, which we define the following specification:</p><pre>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: proxysql<br>      tier: frontend<br>  strategy:<br>    type: RollingUpdate</pre><p>The above means we would like to deploy two ProxySQL pods as a ReplicaSet that matches containers labelled with “app=proxysql,tier=frontend”. The deployment strategy specifies the strategy used to replace old pods with new ones. In this deployment, we picked RollingUpdate which means the pods will be updated in a rolling update fashion, one pod at a time.</p><p>The next part is the container’s template:</p><pre>- image: severalnines/proxysql:1.4.12<br>        name: proxysql<br>        volumeMounts:<br>        - name: proxysql-config<br>          mountPath: /etc/proxysql.cnf<br>          subPath: proxysql.cnf<br>        ports:<br>        - containerPort: 6033<br>          name: proxysql-mysql<br>        - containerPort: 6032<br>          name: proxysql-admin<br>      volumes:<br>      - name: proxysql-config<br>        configMap:<br>          name: proxysql-configmap</pre><p>In the <em>spec.templates.spec.containers.*</em> section, we are telling Kubernetes to deploy ProxySQL using <em>severalnines/proxysql</em> image version 1.4.12. We also want Kubernetes to mount our custom, pre-configured configuration file and map it to /etc/proxysql.cnf inside the container. The running pods will publish two ports – 6033 and 6032. We also define the “volumes” section, where we instruct Kubernetes to mount the ConfigMap as a volume inside the ProxySQL pods to be mounted by volumeMounts.</p><p>The second resource is the service. A Kubernetes service is an abstraction layer which defines the logical set of pods and a policy by which to access them. In this section, we define the following:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: proxysql<br>  labels:<br>    app: proxysql<br>    tier: frontend<br>spec:<br>  type: NodePort<br>  ports:<br>  - nodePort: 30033<br>    port: 6033<br>    name: proxysql-mysql<br>  - nodePort: 30032<br>    port: 6032<br>    name: proxysql-admin<br>  selector:<br>    app: proxysql<br>    tier: frontend</pre><p>In this case, we want our ProxySQL to be accessed from the external network thus NodePort type is the chosen type. This will publish the nodePort on every Kubernetes nodes in the cluster. The range of valid ports for NodePort resource is 30000-32767. We chose port 30033 for MySQL-load balanced connections which is mapped to port 6033 of the ProxySQL pods and port 30032 for ProxySQL Administration port mapped to 6032.</p><p>Therefore, based on our YAML definition above, we have to prepare the following Kubernetes resource before we can begin to deploy the “proxysql” pod:</p><ul><li>ConfigMap – To store ProxySQL configuration file as a volume so it can be mounted to multiple pods and can be remounted again if the pod is being rescheduled to the other Kubernetes node.</li></ul><h3>Preparing ConfigMap for ProxySQL</h3><p>To prepare a ConfigMap for ProxySQL in Kubernetes, you can follow these steps:</p><ol><li>Create a file called proxysql.cnf with the desired ProxySQL configuration. This file contains the configuration options for ProxySQL, such as hostgroup definitions, query rules, connection pool settings, and other parameters. Customize it according to your specific requirements.</li><li>Ensure you have the kubectl command-line tool installed and configured to interact with your Kubernetes cluster.</li></ol><pre>datadir=&quot;/var/lib/proxysql&quot;<br>admin_variables=<br>{<br>        admin_credentials=&quot;proxysql-admin:adminpassw0rd&quot;<br>        mysql_ifaces=&quot;0.0.0.0:6032&quot;<br>        refresh_interval=2000<br>}<br>mysql_variables=<br>{<br>        threads=4<br>        max_connections=2048<br>        default_query_delay=0<br>        default_query_timeout=36000000<br>        have_compress=true<br>        poll_timeout=2000<br>        interfaces=&quot;0.0.0.0:6033;/tmp/proxysql.sock&quot;<br>        default_schema=&quot;information_schema&quot;<br>        stacksize=1048576<br>        server_version=&quot;5.1.30&quot;<br>        connect_timeout_server=10000<br>        monitor_history=60000<br>        monitor_connect_interval=200000<br>        monitor_ping_interval=200000<br>        ping_interval_server_msec=10000<br>        ping_timeout_server=200<br>        commands_stats=true<br>        sessions_sort=true<br>        monitor_username=&quot;proxysql&quot;<br>        monitor_password=&quot;proxysqlpassw0rd&quot;<br>}<br>mysql_replication_hostgroups =<br>(<br>        { writer_hostgroup=10, reader_hostgroup=20, comment=&quot;MySQL Replication 5.7&quot; }<br>)<br>mysql_servers =<br>(<br>        { address=&quot;WriterIP&quot; , port=3306 , hostgroup=10, max_connections=100 },<br>        { address=&quot;ReaderIP&quot; , port=3306 , hostgroup=20, max_connections=100 }<br>)<br>mysql_users =<br>(<br>        { username = &quot;wordpress&quot; , password = &quot;passw0rd&quot; , default_hostgroup = 10 , active = 1 }<br>)<br>mysql_query_rules =<br>(<br>        {<br>                rule_id=100<br>                active=1<br>                match_pattern=&quot;^SELECT .* FOR UPDATE&quot;<br>                destination_hostgroup=10<br>                apply=1<br>        },<br>        {<br>                rule_id=200<br>                active=1<br>                match_pattern=&quot;^SELECT .*&quot;<br>                destination_hostgroup=20<br>                apply=1<br>        },<br>        {<br>                rule_id=300<br>                active=1<br>                match_pattern=&quot;.*&quot;<br>                destination_hostgroup=10<br>                apply=1<br>        }<br>)</pre><p>Then, import the configuration file into ConfigMap:</p><pre>$ kubectl create configmap proxysql-configmap --from-file=proxysql.cnf<br>configmap/proxysql-configmap created</pre><p>Verify if the ConfigMap is loaded into Kubernetes:</p><pre>$ kubectl get configmap<br>NAME                 DATA   AGE<br>proxysql-configmap   1      45s</pre><h3>Deploying ProxySQL .</h3><p>Finally, we can begin the deployment. Deploy ProxySQL first, followed by WordPress:</p><pre>$ kubectl create -f proxysql-rs-svc.yml</pre><p>We can then list out all pods and services that have been created under “frontend” tier :</p><pre>$ kubectl get pods,services -l tier=frontend -o wide<br>NAME                             READY   STATUS    RESTARTS   AGE   IP          NODE          NOMINATED NODE<br>pod/proxysql-95b8d8446-qfbf2     1/1     Running   0          12m   10.36.*.*   kube2.local   <br>pod/proxysql-95b8d8446-vljlr     1/1     Running   0          12m   10.44.*.*   kube3.local   </pre><pre>NAME                TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)                         AGE   SELECTOR<br>service/proxysql    NodePort   10.108.*.*           6033:30033/TCP,6032:30032/TCP   10m   app=proxysql,tier=frontend<br>service/wordpress   NodePort   10.109.*.*           80:30088/TCP                    37m   app=wordpress,tier=frontend<br>  kube2.local</pre><p>The above output verifies our deployment architecture where we are currently having three WordPress pods, exposed on port 30088 publicly as well as our ProxySQL instance which is exposed on port 30033 and 30032 externally plus 6033 and 6032 internally.</p><p>Port 80 published by the WordPress pods is now mapped to the outside world via port 30088. We can access our blog post at <a href="http://{any_kubernetes_host}:30088/">http://{any_kubernetes_host}:30088/</a> and should be redirected to the WordPress installation page. If we proceed with the installation, it would skip the database connection part and directly show this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*WQrIltUPgKpow6ak.jpg" /></figure><p>It indicates that our MySQL and ProxySQL configuration is correctly configured inside wp-config.php file. Otherwise, you would be redirected to the database configuration page.</p><p>Our deployment is now complete.</p><h3>ProxySQL Pods and Service Management</h3><p>Failover and recovery are expected to be handled automatically by Kubernetes. For example, if a Kubernetes worker goes down, the pod will be recreated in the next available node after –pod-eviction-timeout (default to 5 minutes). If the container crashes or is killed, Kubernetes will replace it almost instantly.</p><p>Some common management tasks are expected to be different when running within Kubernetes, as shown in the next sections.</p><h3>Connecting to ProxySQL</h3><p>While ProxySQL is exposed externally on port 30033 (MySQL) and 30032 (Admin), it is also accessible internally via the published ports, 6033 and 6032 respectively. Thus, to access the ProxySQL instances within the Kubernetes network, use the CLUSTER-IP, or the service name “proxysql” as the host value. For example, within WordPress pod, you may access the ProxySQL admin console by using the following command:</p><pre>$ mysql -uproxysql-admin -p -hproxysql -P6032</pre><p>If you want to connect externally, use the port defined under nodePort value he service YAML and pick any of the Kubernetes node as the host value:</p><pre>$ mysql -uproxysql-admin -p -hkube3.local -P30032</pre><p>The same applies to the MySQL load-balanced connection on port 30033 (external) and 6033 (internal).</p><h3>Scaling Up and Down</h3><p>Scaling up is easy with Kubernetes:</p><pre>$ kubectl scale deployment proxysql --replicas=5<br>deployment.extensions/proxysql scaled</pre><p>Verify the rollout status:</p><pre>$ kubectl rollout status deployment proxysql<br>deployment &quot;proxysql&quot; successfully rolled out</pre><p>Scaling down is also similar. Here we want to revert back from 5 to 2 replicas:</p><pre>$ kubectl scale deployment proxysql --replicas=2<br>deployment.extensions/proxysql scaled</pre><p>We can also look at the deployment events for ProxySQL to get a better picture of what has happened for this deployment by using the “describe” option:</p><pre>$ kubectl describe deployment proxysql<br>...<br>Events:<br>  Type    Reason             Age    From                   Message<br>  ----    ------             ----   ----                   -------<br>  Normal  ScalingReplicaSet  20m    deployment-controller  Scaled up replica set proxysql-769895fbf7 to 1<br>  Normal  ScalingReplicaSet  20m    deployment-controller  Scaled down replica set proxysql-95b8d8446 to 1<br>  Normal  ScalingReplicaSet  20m    deployment-controller  Scaled up replica set proxysql-769895fbf7 to 2<br>  Normal  ScalingReplicaSet  20m    deployment-controller  Scaled down replica set proxysql-95b8d8446 to 0<br>  Normal  ScalingReplicaSet  7m10s  deployment-controller  Scaled up replica set proxysql-6c55f647cb to 1<br>  Normal  ScalingReplicaSet  7m     deployment-controller  Scaled down replica set proxysql-769895fbf7 to 1<br>  Normal  ScalingReplicaSet  7m     deployment-controller  Scaled up replica set proxysql-6c55f647cb to 2<br>  Normal  ScalingReplicaSet  6m53s  deployment-controller  Scaled down replica set proxysql-769895fbf7 to 0<br>  Normal  ScalingReplicaSet  54s    deployment-controller  Scaled up replica set proxysql-6c55f647cb to 5<br>  Normal  ScalingReplicaSet  21s    deployment-controller  Scaled down replica set proxysql-6c55f647cb to 2</pre><p>The connections to the pods will be load balanced automatically by Kubernetes.</p><h3>Configuration Changes</h3><p>One way to make configuration changes on our ProxySQL pods is by versioning our configuration using another ConfigMap name. Firstly, modify our configuration file directly via your favourite text editor:</p><pre>$ vim /root/proxysql.cnf</pre><p>Then, load it up into Kubernetes ConfigMap with a different name. In this example, we append “-v2” in the resource name:</p><pre>$ kubectl create configmap proxysql-configmap-v2 --from-file=proxysql.cnf</pre><p>Verify if the ConfigMap is loaded correctly:</p><pre>$ kubectl get configmap<br>NAME                    DATA   AGE<br>proxysql-configmap      1      3d15h<br>proxysql-configmap-v2   1      19m</pre><p>Open the ProxySQL deployment file, <em>proxysql-rs-svc.yml</em> and change the following line under configMap section to the new version:</p><pre>volumes:<br>      - name: proxysql-config<br>        configMap:<br>          name: proxysql-configmap-v2 #change this line</pre><p>Then, apply the changes to our ProxySQL deployment:</p><pre>$ kubectl apply -f proxysql-rs-svc.yml<br>deployment.apps/proxysql configured<br>service/proxysql configured</pre><p>Verify the rollout by using looking at the ReplicaSet event using the “describe” flag:</p><pre>$ kubectl describe proxysql<br>...<br>Pod Template:<br>  Labels:  app=proxysql<br>           tier=frontend<br>  Containers:<br>   proxysql:<br>    Image:        severalnines/proxysql:1.4.12<br>    Ports:        6033/TCP, 6032/TCP<br>    Host Ports:   0/TCP, 0/TCP<br>    Environment:  <br>    Mounts:<br>      /etc/proxysql.cnf from proxysql-config (rw)<br>  Volumes:<br>   proxysql-config:<br>    Type:      ConfigMap (a volume populated by a ConfigMap)<br>    Name:      proxysql-configmap-v2<br>    Optional:  false<br>Conditions:<br>  Type           Status  Reason<br>  ----           ------  ------<br>  Available      True    MinimumReplicasAvailable<br>  Progressing    True    NewReplicaSetAvailable<br>OldReplicaSets:  <br>NewReplicaSet:   proxysql-769895fbf7 (2/2 replicas created)<br>Events:<br>  Type    Reason             Age   From                   Message<br>  ----    ------             ----  ----                   -------<br>  Normal  ScalingReplicaSet  53s   deployment-controller  Scaled up replica set proxysql-769895fbf7 to 1<br>  Normal  ScalingReplicaSet  46s   deployment-controller  Scaled down replica set proxysql-95b8d8446 to 1<br>  Normal  ScalingReplicaSet  46s   deployment-controller  Scaled up replica set proxysql-769895fbf7 to 2<br>  Normal  ScalingReplicaSet  41s   deployment-controller  Scaled down replica set proxysql-95b8d8446 to 0</pre><p>Pay attention to the “Volumes” section with the new ConfigMap name. You can also see the deployment events at the bottom of the output. At this point, our new configuration has been loaded into all ProxySQL pods, where Kubernetes scaled down the ProxySQL ReplicaSet to 0 (obeying RollingUpdate strategy) and bring them back to the desired state of 2 replicas.</p><p><strong>Conclusion :</strong></p><p>Our business needs 24*7 rely on the Database. So if we use a Load balancer like ProxySQL and ProxySQL Cluster. ProxySQL running in GKE or K8S is really helpful to maintain the HA and reduce other Compute resources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5b919e45859" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/running-proxysql-in-kubernetes-in-gke-c5b919e45859">Running ProxySQL in Kubernetes in GKE</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migration From AWS ElasticSearch to Elastic Cloud.]]></title>
            <link>https://blog.searce.com/migration-from-aws-opensearch-to-elastic-cloud-91982badc6b3?source=rss-9276434cf58d------2</link>
            <guid isPermaLink="false">https://medium.com/p/91982badc6b3</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[snapshot]]></category>
            <category><![CDATA[opensearch]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Buvanesh M]]></dc:creator>
            <pubDate>Thu, 29 Jun 2023 10:35:17 GMT</pubDate>
            <atom:updated>2023-08-07T13:46:25.763Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Introduction</strong></blockquote><blockquote>This article describes the Migration strategy and step by step to Migrate OpenSearch to Elastic Cloud using Snapshot and restore method. Let&#39;s Explore this in detail.<br><strong>OpenSearch: </strong>OpenSearch is an open-source search engine forked from Elasticsearch, designed for scalable and performant search and analytics. It offers a distributed architecture, powerful search capabilities, and extensibility, making it an attractive option for organizations seeking a self-hosted, open-source search solution.</blockquote><blockquote><strong>ElasticCloud: </strong>Elastic Cloud is a managed Elasticsearch and Kibana service provided by Elastic. It offers a hosted and fully-managed environment for deploying, scaling, and monitoring Elasticsearch clusters, providing a convenient and hassle-free way to utilize Elasticsearch’s search and analytics capabilities without the need for self-hosting or infrastructure management.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*jKhhnodmOAzI4r5XC9tdkg.png" /></figure><p>Please find the reference <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/managedomains-snapshots.html"><strong>link</strong></a> document for taking Manual Snapshot on AWS Open search.</p><p><strong>Steps to take a Manual snapshot of OpenSearch :</strong></p><p>Step 1: Create an S3 bucket to store an Elasticsearch snapshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*gIW1_VzpPijDc5oUBK95jA.png" /></figure><p>Step 2: Attach the following policy to TheSnapshotRole to allow access to the S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*I0FSF0VEAPbaYqrCz-FqQw.png" /></figure><p>Step 3: Edit the trust relationship of TheSnapshotRole to specify OpenSearch Service in the Principal statement as shown in the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2Q08vtERk4xnpSHrCNlAQ.png" /></figure><p>Step 4: Update the trust policy of TheSnapshotRole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*W4Kzk2Eygdp8o4-LMY0Dsw.png" /></figure><p>Step 5: In order to register the snapshot repository, you need to be able to pass TheSnapshotRole to OpenSearch Service. Replace the arn with your OpenSearch Domain’s arn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*ufHlZeCNZRtQT77Q1fKLXw.png" /></figure><p>Step 6: Map the users and Arns of the domain in the OpenSearch Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*mPXGBFKFr3EJdxwlX6JD8Q.png" /></figure><p>Step 7: To register a repository with Python Client. Please follow the official Document <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/managedomains-snapshots.html#managedomains-snapshot-registerdirectory">here</a>.<br>Once you get the status code 200, wait for the snapshot to be completed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*R3q4e2K7wi8si6y2cQ7E-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6DQmQTOoh4l_v4Hj9Uu3w.png" /></figure><p>Next Step, Here we can use Google Cloud <a href="https://cloud.google.com/architecture/transferring-data-from-amazon-s3-to-cloud-storage-using-vpc-service-controls-and-storage-transfer-service"><strong>Data Transfer Service</strong></a> to transfer files from AWS S3 to GCS.</p><p><strong>Restoration on GCP Marketplace in Elastic Cloud :</strong></p><p>Elastic Cloud provides a managed Elasticsearch and Kibana service, which means that the infrastructure, maintenance, and monitoring tasks are handled by Elastic. This can free up your team’s time and resources that would otherwise be spent on managing the infrastructure and allow them to focus more on the application and business needs.</p><p>To restore an OpenSearch backup to Elastic Cloud, you can follow these steps:</p><p><strong>1. Prepare the Backup:</strong> Ensure that you have a valid backup of your OpenSearch data. The backup should be in a compatible format, such as a snapshot taken using the OpenSearch Snapshot and Restore API or a compatible backup tool.</p><p><strong>2. Set up a Self-Managed Elasticsearch Cluster in Elastic Cloud:</strong> If you haven’t already, set up a self-managed Elasticsearch cluster in Elastic Cloud. This requires an active Elastic Cloud account.</p><p><strong>3. Prepare the Restoration Environment:</strong> Make sure you have the necessary access credentials and permissions to perform the restoration in Elastic Cloud. You will need the Elasticsearch endpoint, username, and password for your Elastic Cloud cluster.</p><p><strong>4. Transfer the Backup:</strong> Transfer the backup files to a location accessible from the machine where you will execute the restoration. You can use tools like `scp` or cloud storage solutions to upload the backup files to a suitable location. Here we can use Google Cloud <a href="https://cloud.google.com/architecture/transferring-data-from-amazon-s3-to-cloud-storage-using-vpc-service-controls-and-storage-transfer-service"><strong>Data Transfer Service</strong></a> to transfer files from AWS S3 to GCS.</p><p><strong>5. Restore the Backup:</strong> Use the OpenSearch Snapshot and Restore API or a compatible tool to restore the backup to your Elasticsearch cluster in Elastic Cloud. The exact steps will depend on the backup tool and format you are using.</p><p>Here we can use Elastic search GUI to restore the OpenSearch backup. Let&#39;s explore in step by step</p><p><strong>Prerequisites</strong></p><blockquote>We can subscribe to the Elastic Cloud on GCP Marketplace.</blockquote><blockquote>Create the deployment as per our business requirements. Once it’s done we can restore the OpenSearch snapshot.</blockquote><blockquote>Service Account with Storage admin permission.</blockquote><blockquote>Get the key from the Service Account, open it in a text editor, and copy it.</blockquote><p><strong>Step 1 :</strong><br>Open the Elastic Cloud console and open the security section, choose the add security options, and paste the key we copied from the service account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*N_f5y5ErYzSE0WaIevalYw.png" /></figure><p><strong>Step 2 :<br></strong>Create the repository<br>For deployments with <strong>Elastic Stack version 7.2 and higher</strong>:</p><ol><li>Open Kibana and go to <strong>Management</strong> &gt; <strong>Snapshot and Restore</strong>.</li><li>On the <strong>Repositories</strong> tab, select <strong>Register a Repository</strong>.</li><li>Provide a name for your repository and select the type <strong>Google Cloud Storage</strong>.</li><li>Provide the following settings: Client: Secondary</li></ol><ul><li>Bucket: Your GCS bucket name</li><li>Base path: A directory to contain the snapshots</li><li>This setting is optional. Include a base_path if you have multiple clusters writing to the same GCS repository. This ensures that a snapshot won’t overwrite the snapshot metadata for another cluster.</li></ul><p>5. Add any other settings that you wish to configure.</p><p>6. Select <strong>Register</strong>.</p><p>7. Select <strong>Verify</strong> to confirm that your settings are correct and the deployment can connect to your repository.</p><p>8. Your snapshot repository is now set up using GCS! You can use Kibana to manage your snapshots and begin sending Elasticsearch snapshots to your bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*yZ20vJgL8wKjU328_CWcYg.png" /></figure><p>Once it’s connected we can see the repositories under the repositories sections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*iOwrJiDnovXnkEYfnTURyw.png" /></figure><p>Use these restore options to restore the snapshot of the open search and wait for the snapshot to successfully restore into Elastic search.</p><p>6. <strong>Monitor the Restoration:</strong> Monitor the restoration process to ensure it completes successfully. We can check the active shard&#39;s status above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*v11c3JJnVii_Mi_U1jvJIg.png" /></figure><p><strong>7. Verify the Restoration: </strong>Once the restoration is complete, verify that the data is successfully restored in your Elastic Cloud Elasticsearch cluster. You can perform search queries or access your indices to confirm the presence and correctness of the restored data.</p><p>It’s important to note that the specifics of the restoration process may vary depending on your backup tool, backup format, and the version of Elasticsearch used in Elastic Cloud. Make sure to consult the Elastic Cloud documentation and any relevant tool documentation for detailed instructions tailored to your setup.</p><blockquote><strong>Note: </strong>If you are facing any index issues in restoring the backup in Elastic Search. Try to change index settings as recommended.</blockquote><p>Thanks for reading and Feel free to post your queries and claps.</p><p><strong>References :</strong></p><p><a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/managedomains-snapshots.html">https://docs.aws.amazon.com/opensearch/service/latest/developerguide/managedomains-snapshots.html</a></p><p><a href="https://www.elastic.co/guide/en/cloud/current/ec-gcs-snapshotting.html#ec-create-gcs-repository">https://www.elastic.co/guide/en/cloud/current/ec-gcs-snapshotting.html#ec-create-gcs-repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91982badc6b3" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/migration-from-aws-opensearch-to-elastic-cloud-91982badc6b3">Migration From AWS ElasticSearch to Elastic Cloud.</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate MySQL Databases from AWS RDS/Aurora or On-prem to CloudSQL using GCP DMS]]></title>
            <link>https://blog.searce.com/best-practices-to-migrate-your-databases-from-read-replicas-as-source-using-gcp-dms-19ad83c6d1c?source=rss-9276434cf58d------2</link>
            <guid isPermaLink="false">https://medium.com/p/19ad83c6d1c</guid>
            <dc:creator><![CDATA[Buvanesh M]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 13:27:19 GMT</pubDate>
            <atom:updated>2022-03-30T14:53:53.524Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we are going to see how to migrate the databases from AWS RDS read replica /Aurora cross-region read replica /On-prem read replica to GCP CloudSQL using GCP DMS(Database Migration Service)</p><blockquote>Using the GCP Database Migration Service(DMS), it is convenient and easier to migrate your Databases from On-prem or Cloud Managed services like RDS and Aurora to GCP CloudSQL(Mysql and Postgresql).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*_RvyA5aOCal0degJuQ6z3g.png" /></figure><blockquote><strong>Reasons for using Read replica as a source</strong></blockquote><blockquote>GCP DMS consists of two jobs</blockquote><blockquote>i. Loading the existing Data ( full Dump of the existing data)</blockquote><blockquote>ii. Replicating the ongoing changes(delta data)</blockquote><blockquote>To take the initial dump during the migration job on the source master database requires writes should be stopped for approximately <strong>20 seconds. </strong>You can stop writes either by migrating from a read replica or by stopping writes directly on the source master database.</blockquote><blockquote>To avoid the downtime on the primary instance you can make use of the read replica of RDS /Cross-region read replica of Aurora or slave server in case of an on-prem setup</blockquote><blockquote>We need to make sure that we enable binary logs on the respective source instances.</blockquote><blockquote>Incase of RDS read replica /Aurora cross-region read replica, We can enable binary log using parameter group /cluster parameter group</blockquote><blockquote>The following parameters need to be modified on the parameter group</blockquote><ol><li>Enable automatic backup on the RDS read replica</li><li>binlog_format=ROW</li><li>log_slave_updates(Incase of on-prem servers)</li></ol><p><strong>Prerequisites</strong></p><ol><li>Create one additional read replica on AWS exclusively for the migration process.</li><li>Enable automatic backup on the newly created read replica for 7days.</li><li>Configure the <strong>s</strong><a href="https://cloud.google.com/database-migration/docs/mysql/configure-source-database"><strong>ource</strong></a><strong> </strong>instances such as binlog retention period, Replication users and its grants, binlog format.</li><li>You can create and attach a new parameter group to the newly created read replica and modify the parameters mentioned above (Changing the binlog_format in the parameter group would require a restart ).</li><li>Make sure that we have the connectivity between Source(AWS/On-prem) and GCP environment.</li><li>Necessary privileges to create the DMS job in GCP.</li></ol><h3>Steps to perform on the source instance(RDS read replica)</h3><p>Step 1: Create one additional read replica exclusively for a migration purpose.</p><p>Step 2: Enable automatic backup on the read replica with retention for 7 days and modify the following parameter in the parameter group.</p><blockquote><strong>binlog_format=ROW</strong></blockquote><p>Step 3: Create a replication user on the primary instance with the following privileges.</p><blockquote>mysql&gt;CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;</blockquote><blockquote>mysql&gt;GRANT SELECT, LOCK TABLES, SHOW VIEW, EVENT, TRIGGER, RELOAD,EXECUTE,REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO ‘username’@’%’;</blockquote><p>Step 4: Execute the following command on the read replica to increase the binlog retention hours.</p><blockquote>mysql&gt;call mysql.rds_set_configuration(‘binlog retention hours’, 168);</blockquote><h3>Steps to perform on the source instance(Aurora cross-region read replica)</h3><p>Step 1: Create the cross-region read replica of the Aurora cluster exclusively for migration purposes.</p><p>Step 2: Enable automatic backup on the Aurora cross-region read replica with retention for 7 days and modify the following parameter in the cluster parameter group.</p><p><strong>binlog_format=ROW</strong></p><p>Step 3: Create a replication user on the Aurora cross-region read replica instance with the following privileges.</p><blockquote>mysql&gt;CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;</blockquote><blockquote>mysql&gt;GRANT SELECT, LOCK TABLES, SHOW VIEW, EVENT, TRIGGER, RELOAD,EXECUTE,REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO ‘username’@’%’;</blockquote><p>Step 4: Execute the following command on the aurora cross-region read replica to increase the binlog retention hours.</p><blockquote>mysql&gt;call mysql.rds_set_configuration(‘binlog retention hours’, 168);</blockquote><h3>Steps to create a DMS job on GCP</h3><ol><li>Create the connection profile on GCP to communicate with the RDS replica/Aurora Cross-region replica instance by giving its IP, username, and password.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*r-4dtKO-a5-79K-fvq0y1g.png" /></figure><p>2. Now get started by entering the details such as job name, job ID, source database engine(RDS/On-prem) of the source instance, and select the migration job type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*OtsQnziHIUWwoCIMobKGMA.png" /></figure><p>3. In this section, select the connection profile which was created in step 1. For MySQL, we have an option of providing our dump file in place of GCP DMS performing the initial dump(However this is not recommended).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*90r3But8DhwrYa6V-YVq8A.png" /></figure><p>4. Now create the destination CloudSQL instance in the required region and zone, as per your source instance size. Make sure to enable <strong>automatic storage increase.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*2Tz3Mr00QsZwuP5uSyD-BQ.png" /></figure><p>5. Please wait for a few minutes as the destination cloud SQL instance is getting created. Once the instance is created we would get an <strong>outgoing IP address</strong> of the destination cloud SQL instance.</p><p>Copy the outgoing IP address and whitelist the same in the AWS/On-prem server.</p><p>6. We can connect the source instance using IP allowlist, VPC peering, or Reverse SSH tunnel for now we are using IP allowlist.<br>Now it’s time to test the migration job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*hHHQlqWfC_DrOWX6vPFq5Q.png" /></figure><p>7. If the test of the migration job was successful, You can create and start the migration job. If the test of the migration job is unsuccessful, it will show you the reason for the failure and you can <a href="https://cloud.google.com/database-migration/docs/mysql/diagnose-issues"><strong>troubleshoot </strong></a>accordingly.</p><p>Now go to the DMS console and check for the status of the DMS job. You will see one of the following status</p><ol><li><strong>Waiting for the source to stop writes: </strong>In this case<strong>, </strong>we need to stop the replication on the read replica for the initial dump to be taken for approximately 20 seconds using the below command.</li></ol><blockquote>mysql&gt;CALL mysql.rds_stop_replication;</blockquote><p><strong>2. Full dump in progress: </strong>In this case, the initial dump is in progress which would take some time to complete based on your source database size. Now we can start the resume the replication on the read replica using the below command.</p><blockquote>mysql&gt;CALL mysql.rds_start_replication;</blockquote><p><strong>3. CDC is in Progress: </strong>In this case, the DMS job is replicating data from the source instance in a near real-time fashion. You can validate the lag between the source and destination cloud SQL by logging into the destination cloud SQL instance and executing the below command.</p><blockquote>mysql&gt;show slave status;</blockquote><p>Look out for the <strong>seconds behind the master</strong> value in the output.</p><p>Once both source and destination lag is zero, We can promote the destination cloud SQL instance as the new primary and move your application traffic to GCP :)</p><p><strong>Summary:</strong></p><p>In this article, we have used a read-replica as a source instance to avoid the brief downtime of 20 seconds which is required for the initial dump to be started and migrate the database from AWS RDS/Aurora MySQL or On-premise to GCP CloudSQL MySQL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19ad83c6d1c" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/best-practices-to-migrate-your-databases-from-read-replicas-as-source-using-gcp-dms-19ad83c6d1c">Migrate MySQL Databases from AWS RDS/Aurora or On-prem to CloudSQL using GCP DMS</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>