Git Product home page Git Product logo

obshell-sdk-go's Introduction

license English doc Chinese doc

English | Chinese

OBShell-SDK-GO is an SDK provided by theOceanBase Community to facilitate developers with quick access to OBShell services, allowing them to conveniently call OBShell interfaces using this SDK.

Install

go get github.com/oceanbase/obshell-sdk-go

Quick Start

Please ensure that OBShell is running when using it.

Creating a Client

You can choose to create a single-version client.

package main

import (
	"github.com/obshell-sdk-go/services/v1"
)

func main() {
	client, err := v1.NewClientWithPassword("11.11.11.1", 2886, "***")
	if err != nil {
        // Handle exceptions
		panic(err)
	}
}

Or create a multi-version client set.

package main

import (
	"github.com/obshell-sdk-go/services"
)

func main() {
	clientset, err := services.NewClientWithPassword("11.11.11.1", 2886, "****")
	if err != nil {
        // Handle exceptions
		panic(err)
	}
}

Deploying Cluster

package main

import (
    "fmt"
	"github.com/obshell-sdk-go/services/v1"
)

func main() {
	client, err := v1.NewClientWithPassword("11.11.11.1", 2886, "****")
	if err != nil {
		panic(err)
	}
	joinReqeust1 := client.NewJoinRequest("11.11.11.1", 2886, "zone1")
	if _, err := client.JoinSyncWithRequest(joinReqeust1); err != nil {
		panic(err)
	}

	joinReqeust2 := client.NewJoinRequest("11.111.11.2", 2886, "zone2")
	if _, err := client.JoinSyncWithRequest(joinReqeust2); err != nil {
		panic(err)
	}

	joinReqeust3 := client.NewJoinRequest("11.11.11.3", 2886, "zone3")
	if _, err := client.JoinSyncWithRequest(joinReqeust3); err != nil {
		panic(err)
	}

	// config server
	for _, ip := range []string{"11.11.11.1", "11.11.11.2", "11.11.11.3"} {
		// OBShell prior to 4.2.3.0 should use mysqlPort(rpcPort) instead of mysql_port(rpc_port).
		configs := map[string]string{
			"mysql_port": "2881", "rpc_port": "2882", "datafile_size": "24G", "cpu_count": "16", "memory_limit": "16G", "system_memory": "8G", "log_disk_size": "24G",
		}
		configObserverReq := client.NewConfigObserverRequest(configs, v1.SCOPE_SERVER, fmt.Sprintf("%s:2886", ip))
		if _, err := client.ConfigObserverSyncWithRequest(configObserverReq); err != nil {
			panic(err)
		}
	}

	// config obcluster
	configObclusterReq := client.NewConfigObclusterRequest("obshell-sdk-test", 12358).SetRootPwd("****")
	if _, err := client.ConfigObclusterSyncWithRequest(configObclusterReq); err != nil {
		panic(err)
	}

	// init
	initReq := client.NewInitRequest()
	if _, err := client.InitSyncWithRequest(initReq); err != nil {
		panic(err)
	}
}

Scale out

package main

import (
	"github.com/obshell-sdk-go/services/v1"
)

func main() {
	client, err := v1.NewClientWithPassword("11.11.11.1", 2886, "****")
	if err != nil {
		panic(err)
	}

	// OBShell prior to 4.2.3.0 should use mysqlPort(rpcPort) instead of mysql_port(rpc_port).
	configs := map[string]string{
		"mysql_port": "2881", "rpc_port": "2882", "datafile_size": "24G", "cpu_count": "16", "memory_limit": "16G", "system_memory": "8G", "log_disk_size": "24G",
	}

	// scale-out
	scaleOutReq := client.NewScaleOutRequest("11.11.11.3", 2886, "zone3", configs)
	if _, err := client.ScaleOutSyncWithRequest(scaleOutReq); err != nil {
		panic(err)
	}
}

obshell-sdk-go's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.