- 官网详细部署文档
1、使用OBD部署安装OceanBase
1.1、安装OBD
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy
source /etc/profile.d/obd.sh
1.2、安装OBClient
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install obclient
1.3、修改OceanBase配置文件
1.3.1、本地安装配置文件
## Only need to configure when remote login is required
user:
username: root
password: root123
# key_file: your ssh-key file path if need
# port: your ssh port, default 22
# timeout: ssh connection timeout (second), default 30
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 192.100.3.240
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
# The directory for data storage. The default value is $home_path/store.
data_dir: /data/observer/store
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# 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: eth0
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.
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 8G # The maximum running memory for an observer
system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
stack_size: 512K
cpu_count: 16
cache_wash_threshold: 1G
__min_full_resource_pool_memory: 268435456
workers_per_cpu_quota: 10
schema_history_expire_time: 1d
# The value of net_thread_count had better be same as cpu's core number.
net_thread_count: 4
major_freeze_duty_time: Disable
minor_freeze_times: 10
enable_separate_sys_clog: 0
enable_merge_by_turn: FALSE
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.
# root_password: # root user password, can be empty
修改位置
#在配置文件顶部添加用户密码信息
user:
username: root
password: root123
#修改配置文件中的 IP 地址。
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 192.100.3.240
#修改配置文件中的 devname 变量和 home_path
oceanbase-ce:
global:
home_path: /root/observer
devname: eth0
# 修改数据和日志存储路径
data_dir: /data/observer/store
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
您需要拥有 home_path 目录的权限。
1.4、配置 limits.conf
说明
您必须在每台机器上执行此操作。
将会话级别的最大栈空间大小设置为 unlimited,最大文件句柄数设置为 655350,Core 文件大小设置为 unlimited。vi /etc/security/limits.conf
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft stack 20480
* hard stack 20480
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
1.5、配置 sysctl.conf
vi /etc/sysctl.conf
# for oceanbase
## 修改内核异步 I/O 限制
fs.aio-max-nr=1048576
## 网络优化
net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.ip_local_port_range = 3500 65535
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_slow_start_after_idle=0
vm.swappiness = 0
vm.min_free_kbytes = 2097152
# 此处为 OceanBase 数据库的 data 目录
kernel.core_pattern = /data/core-%e-%p-%t
其中,kernel.core_pattern 中的 /data 为 OceanBase 数据库的 data 目录。如果您只是测试,您可以只设置 fs.aio-max-nr=1048576。
执行sysctl -p
1.6、启动OceanBase数据库
1.6.1、部署集群
obd cluster deploy -c
obd cluster deploy observer-test -c mini-single-example.yaml
obd cluster deploy observer-test -c mini-single-example.yaml
在您执行了 obd cluster deploy 命令之后,OBD 将检查您的目标机器是否有 OceanBase 数据库安装包。如果没有安装包,OBD 将自动从 yum 源获取。
1.6.2、启动集群
obd cluster start observer-test
1.6.3、查看集群状态
obd cluster display <deploy_name>
1.7、连接 OceanBase 数据库
obclient -h127.1 -P2881 -uroot
返回:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3221546072
Server version: 5.7.25 OceanBase 3.1.0 (r1-) (Built Apr 7 2021 08:14:49)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
1.8、验证集群
MySQL [oceanbase]> USE oceanbase;
MySQL [oceanbase]> SELECT * FROM __all_server;
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| gmt_create | gmt_modified | svr_ip | svr_port | id | zone | inner_port | with_rootserver | status | block_migrate_in_time | build_version | stop_time | start_service_time | first_sessid | with_partition | last_offline_time |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| 2021-04-21 10:59:04.967158 | 2021-04-21 10:59:20.344774 | 11.166.80.01 | 2882 | 1 | zone1 | 2881 | 1 | active | 0 | 3.1.0_1-(Apr 7 2021 08:14:49) | 0 | 1618973957346877 | 0 | 1 | 0 |
| 2021-04-21 10:59:04.956632 | 2021-04-21 10:59:20.223340 | 11.166.80.02 | 2882 | 2 | zone2 | 2881 | 0 | active | 0 | 3.1.0_1-(Apr 7 2021 08:14:49) | 0 | 1618973958225270 | 0 | 1 | 0 |
| 2021-04-21 10:59:03.956853 | 2021-04-21 10:59:22.415147 | 11.166.81.103 | 2882 | 3 | zone3 | 2881 | 0 | active | 0 | 3.1.0_1-(Apr 7 2021 08:14:49) | 0 | 1618973958416271 | 0 | 1 | 0 |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
3 rows in set (0.00 sec)