實踐練習三(可選):使用OBD 部署一個 三副本OceanBase 集群
練習目的
本次練習目的掌握 OceanBase 集群的自動化部署(OBD工具)技術,能自動部署OB集群,包含 OBProxy,以及部署 OBAgent 等。
練習條件
- 有 服務器,內存資源至少 12G*3台 或者 32G*1台
練習內容
請記錄並分享下列內容:
- (必選)部署 OBD 軟件,離線或者在線都可以。
- (必選)使用 OBD 部署一套三副本集群(單機3節點或者3節點都可以),部署至少1個 OBProxy。
- (必選)部署至少一個 OBAgent 。
- (可選)部署 Promethues ,能查看采集的 OB 性能或狀態數據。
- (可選)部署 Grafana,能使用 OB 的性能模板查看 OB性能數據。
具體實現
架構規划
組件 | 節點 | 說明 | 軟件目錄 | 端口 |
---|---|---|---|---|
obd | 192.168.10.201 | 中控機,自動化部署軟件 | ||
observer | 192.168.10.201 | OceanBase 數據庫 zone1 | home_path: /ups/app/oceanbase/cluster data_dir: /obdata/data/201 redo_dir: /obdata/redo/201 |
2881/2882 |
192.168.10.202 | OceanBase 數據庫 zone2 | home_path: /ups/app/oceanbase/cluster data_dir: /obdata/data/202 redo_dir: /obdata/redo/202 |
||
192.168.10.203 | OceanBase 數據庫 zone3 | home_path: /ups/app/oceanbase/cluster data_dir: /obdata/data/203 redo_dir: /obdata/redo/203 |
||
obproxy | 192.168.10.221 | OceanBase 訪問反向代理 | /ups/app/oceanbase/obproxy | 2883/2884 |
192.168.10.222 | ||||
192.168.10.223 | ||||
obagent | 192.168.10.211 | 監控采集 | /ups/app/oceanbase/obagent | 8088/8089 |
192.168.10.212 | ||||
192.168.10.213 | ||||
obclient | 192.168.10.201 | OceanBase 命令行客戶端 |
安裝OBD軟件
# 下載
curl https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/ob-deploy-1.1.2-1.el7.x86_64.rpm
# 安裝
sudo rpm -ivh ob-deploy-1.1.2-1.el7.x86_64.rpm
# 加載環境變量
source /etc/profile.d/obd.sh
# 查看可執行文件的安裝路徑
rpm -ql `rpm -qa|grep ob-deploy`
配置本地鏡像倉庫
# 1. 首先要刪除遠程倉庫
mv ~/.obd/mirror/remote/OceanBase.repo ~/.obd/mirror/remote/OceanBase.repo.bak
# 2. 將所需的軟件上傳到指定目錄,如:/ups/app/obrpm/
# 3. 離線倉庫
obd mirror clone /ups/app/obrpm/*.rpm
# 4. 輸出本地倉庫中rpm包列表
obd mirror list local
配置集群部署yaml文件
## Only need to configure when remote login is required
user:
username: ober # your os username
# password: your password if need
key_file: /ups/app/oceanbase/.ssh/id_rsa.pub # your ssh-key file path if need
# port: your ssh port, default 22
# timeout: ssh connection timeout (second), default 30
oceanbase-ce:
servers:
- name: server1
# Please don't use hostname, only IP can be supported
ip: 192.168.10.201
- name: server2
ip: 192.168.10.202
- name: server3
ip: 192.168.10.203
global:
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: ens32
# if current hardware's memory capacity is smaller than 50G, please use the setting of "mini-single-example.yaml" and do a small adjustment.
memory_limit: 8G # The maximum running memory for an observer
# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
system_memory: 4G
datafile_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
syslog_level: INFO # System log level. The default value is INFO.
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
# observer cluster name, consistent with obproxy's cluster_name
appname: obce
# root_password: # root user password, can be empty
# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
# In this example , support multiple ob process in single node, so different process use different ports.
# If deploy ob cluster in multiple nodes, the port and path setting can be same.
server1:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /ups/app/oceanbase/cluster
# The directory for data storage. The default value is $home_path/store.
data_dir: /obdata/data/201
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /obdata/redo/201
zone: zone1
server2:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /ups/app/oceanbase/cluster
# The directory for data storage. The default value is $home_path/store.
data_dir: /obdata/data/202
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /obdata/redo/202
zone: zone2
server3:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /ups/app/oceanbase/cluster
# The directory for data storage. The default value is $home_path/store.
data_dir: /obdata/data/203
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /obdata/redo/203
zone: zone3
obproxy:
# Set dependent components for the component.
# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
depends:
- oceanbase-ce
servers:
- 192.168.10.221
- 192.168.10.222
- 192.168.10.223
global:
listen_port: 2883 # External port. The default value is 2883.
prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
home_path: /ups/app/oceanbase/obproxy
# oceanbase root server list
# format: ip:mysql_port;ip:mysql_port. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# rs_list: 192.168.1.2:2881;192.168.1.3:2881;192.168.1.4:2881
enable_cluster_checkout: false
# observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# cluster_name: obcluster
skip_proxy_sys_private_check: true
# obproxy_sys_password: # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
obagent:
# The list of servers to be monitored. This list is consistent with the servers in oceanbase-ce.
servers:
- name: server1
# Please don't use hostname, only IP can be supported
ip: 192.168.10.211
- name: server2
ip: 192.168.10.212
- name: server3
ip: 192.168.10.213
# Set dependent components for the component.
# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
depends:
- oceanbase-ce
global:
# The working directory for obagent. obagent is started under this directory. This is a required field.
home_path: /ups/app/oceanbase/obagent
# The port that pulls and manages the metrics. The default port number is 8088.
server_port: 8088
# Debug port for pprof. The default port number is 8089.
pprof_port: 8089
# Log level. The default value is INFO.
log_level: INFO
# Log path. The default value is log/monagent.log.
log_path: log/monagent.log
# Encryption method. OBD supports aes and plain. The default value is plain.
crypto_method: plain
# Path to store the crypto key. The default value is conf/.config_secret.key.
# crypto_path: conf/.config_secret.key
# Size for a single log file. Log size is measured in Megabytes. The default value is 30M.
log_size: 30
# Expiration time for logs. The default value is 7 days.
log_expire_day: 7
# The maximum number for log files. The default value is 10.
log_file_count: 10
# Whether to use local time for log files. The default value is true.
# log_use_localtime: true
# Whether to enable log compression. The default value is true.
# log_compress: true
# Username for HTTP authentication. The default value is admin.
http_basic_auth_user: admin
# Password for HTTP authentication. The default value is root.
http_basic_auth_password: root
# Username for debug service. The default value is admin.
pprof_basic_auth_user: admin
# Password for debug service. The default value is root.
pprof_basic_auth_password: root
# Monitor username for OceanBase Database. The user must have read access to OceanBase Database as a system tenant. The default value is root.
# monitor_user: root
# Monitor password for OceanBase Database. The default value is empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the root_password in oceanbase-ce.
# monitor_password:
# The SQL port for observer. The default value is 2881. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the mysql_port in oceanbase-ce.
# sql_port: 2881
# The RPC port for observer. The default value is 2882. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the rpc_port in oceanbase-ce.
# rpc_port: 2882
# Cluster name for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the appname in oceanbase-ce.
# cluster_name: obcluster
# Cluster ID for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the cluster_id in oceanbase-ce.
# cluster_id: 1
# Zone name for your observer. The default value is zone1. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the zone name in oceanbase-ce.
# zone_name: zone1
# Monitor status for OceanBase Database. Active is to enable. Inactive is to disable. The default value is active. When you deploy an cluster automatically, OBD decides whether to enable this parameter based on depends.
ob_monitor_status: active
# Monitor status for your host. Active is to enable. Inactive is to disable. The default value is active.
host_monitor_status: active
# Whether to disable the basic authentication for HTTP service. True is to disable. False is to enable. The default value is false.
disable_http_basic_auth: false
# Whether to disable the basic authentication for the debug interface. True is to disable. False is to enable. The default value is false.
disable_pprof_basic_auth: false
部署集群軟件
# 用法:obd cluster deploy [集群名] -c 集群配置文件
obd cluster deploy obce-single -c obce.yaml
啟動及初始化集群
obd cluster start obce
檢查集群狀態
obd cluster display obce
安裝obclient客戶端
rpm -ivh obclient-2.0.0-2.el7.x86_64.rpm libobclient-2.0.0-2.el7.x86_64.rpm