This topic describes how to use obshell-sdk-go to query tenant system variables, including specifying and fuzzy matching.
Note
We recommend that you first read obshell-sdk-go quick start to learn how to use obshell-sdk-go.
Query a specified tenant system variable
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 of '10.10.10.1' and port 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
value, err := client.V1().GetTenantVariable("t1", "recyclebin")
if err != nil {
fmt.Print(err)
return
}
fmt.Print(value)
}
Fuzzy match tenant system variables
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 of '10.10.10.1' and port 2886.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
if err != nil {
fmt.Print(err)
return
}
vars, err := client.V1().GetTenantVariables("t1", "max_connect%")
if err != nil {
fmt.Print(err)
return
}
fmt.Print(vars)
}
References
For more information about the API for specifying a tenant system variable, see Query a specified tenant system variable.
For more information about the API for fuzzy matching tenant system variables, see Fuzzy match tenant system variables.
For information about how to request API methods by using obshell-sdk-python, see Query tenant system variables.