- 官网详细部署文档
1、使用OBD部署安装OceanBase
1.1、安装OBD
sudo yum install -y yum-utilssudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.reposudo yum install -y ob-deploysource /etc/profile.d/obd.sh
1.2、安装OBClient
sudo yum install -y yum-utilssudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.reposudo yum install obclient
1.3、修改OceanBase配置文件
1.3.1、本地安装配置文件
## Only need to configure when remote login is requireduser:username: rootpassword: root123# key_file: your ssh-key file path if need# port: your ssh port, default 22# timeout: ssh connection timeout (second), default 30oceanbase-ce:servers:# Please don't use hostname, only IP can be supported- 192.100.3.240global:# 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: eth0mysql_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: zone1cluster_id: 1# please set memory limit to a suitable value which is matching resource.memory_limit: 8G # The maximum running memory for an observersystem_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.stack_size: 512Kcpu_count: 16cache_wash_threshold: 1G__min_full_resource_pool_memory: 268435456workers_per_cpu_quota: 10schema_history_expire_time: 1d# The value of net_thread_count had better be same as cpu's core number.net_thread_count: 4major_freeze_duty_time: Disableminor_freeze_times: 10enable_separate_sys_clog: 0enable_merge_by_turn: FALSEdatafile_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: rootpassword: root123#修改配置文件中的 IP 地址。oceanbase-ce:servers:# Please don't use hostname, only IP can be supported- 192.100.3.240#修改配置文件中的 devname 变量和 home_pathoceanbase-ce:global:home_path: /root/observerdevname: 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 655350root 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 = 2048net.core.netdev_max_backlog = 10000net.core.rmem_default = 16777216net.core.wmem_default = 16777216net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.ip_local_port_range = 3500 65535net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0net.ipv4.tcp_syncookies = 0net.ipv4.tcp_rmem = 4096 87380 16777216net.ipv4.tcp_wmem = 4096 65536 16777216net.ipv4.tcp_max_syn_backlog = 16384net.ipv4.tcp_fin_timeout = 15net.ipv4.tcp_max_syn_backlog = 16384net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_slow_start_after_idle=0vm.swappiness = 0vm.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 3221546072Server 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)
