This topic describes how to delete a specified tenant replica by using obshell-sdk-go. You can delete multiple tenant replicas at a time.
Note
We recommend that you first read obshell-sdk-go quick start to learn how to use obshell-sdk-go.
Considerations
Make sure that obshell is running.
Make sure that the tenant exists and is in the NORMAL state.
The node corresponding to the client in the request must be in an initialized cluster.
Sample code
package main
import (
"fmt"
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// Create a client instance with the node address set to '10.10.10.1' and the port set to 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
req := client.V1().NewScaleInReplicasRequest("t1", []string{"zone3"})
if _, err := client.V1().ScaleInReplicasSyncWithRequest(req); err != nil {
fmt.Print(err)
return
}
}
package main
import (
"fmt"
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// Create a client instance with the node address set to '10.10.10.1' and the port set to 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
req := client.V1().NewScaleInReplicasRequest("t1", []string{"zone3"})
dag, err := client.V1().ScaleInReplicasWithRequest(req)
if err != nil {
fmt.Print(err)
return
}
// Wait for the task to succeed.
if _, err = client.V1().WaitDagSucceed(dag.GenericID); err != nil {
fmt.Print(err)
return
}
}
References
For more information about the API for deleting a tenant replica, see Delete a tenant replica.
For more information about how to request API methods by using obshell-sdk-python, see Delete a tenant replica.