• 官网详细部署文档

    1、使用OBD部署安装OceanBase

    1.1、安装OBD

    1. sudo yum install -y yum-utils
    2. sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
    3. sudo yum install -y ob-deploy
    4. source /etc/profile.d/obd.sh

    1.2、安装OBClient

    1. sudo yum install -y yum-utils
    2. sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
    3. sudo yum install obclient

1.3、修改OceanBase配置文件

1.3.1、本地安装配置文件

  1. ## Only need to configure when remote login is required
  2. user:
  3. username: root
  4. password: root123
  5. # key_file: your ssh-key file path if need
  6. # port: your ssh port, default 22
  7. # timeout: ssh connection timeout (second), default 30
  8. oceanbase-ce:
  9. servers:
  10. # Please don't use hostname, only IP can be supported
  11. - 192.100.3.240
  12. global:
  13. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
  14. home_path: /root/observer
  15. # The directory for data storage. The default value is $home_path/store.
  16. data_dir: /data/observer/store
  17. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  18. # redo_dir: /redo
  19. # Please set devname as the network adaptor's name whose ip is in the setting of severs.
  20. # if set severs as "127.0.0.1", please set devname as "lo"
  21. # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
  22. devname: eth0
  23. mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
  24. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
  25. zone: zone1
  26. cluster_id: 1
  27. # please set memory limit to a suitable value which is matching resource.
  28. memory_limit: 8G # The maximum running memory for an observer
  29. system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
  30. stack_size: 512K
  31. cpu_count: 16
  32. cache_wash_threshold: 1G
  33. __min_full_resource_pool_memory: 268435456
  34. workers_per_cpu_quota: 10
  35. schema_history_expire_time: 1d
  36. # The value of net_thread_count had better be same as cpu's core number.
  37. net_thread_count: 4
  38. major_freeze_duty_time: Disable
  39. minor_freeze_times: 10
  40. enable_separate_sys_clog: 0
  41. enable_merge_by_turn: FALSE
  42. 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.
  43. syslog_level: INFO # System log level. The default value is INFO.
  44. enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
  45. enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
  46. max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
  47. # root_password: # root user password, can be empty

修改位置

  1. #在配置文件顶部添加用户密码信息
  2. user:
  3. username: root
  4. password: root123
  5. #修改配置文件中的 IP 地址。
  6. oceanbase-ce:
  7. servers:
  8. # Please don't use hostname, only IP can be supported
  9. - 192.100.3.240
  10. #修改配置文件中的 devname 变量和 home_path
  11. oceanbase-ce:
  12. global:
  13. home_path: /root/observer
  14. devname: eth0
  15. # 修改数据和日志存储路径
  16. data_dir: /data/observer/store
  17. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  18. # redo_dir: /redo
  19. 您需要拥有 home_path 目录的权限。

1.4、配置 limits.conf

说明
您必须在每台机器上执行此操作。
将会话级别的最大栈空间大小设置为 unlimited,最大文件句柄数设置为 655350,Core 文件大小设置为 unlimited。
vi /etc/security/limits.conf

  1. root soft nofile 655350
  2. root hard nofile 655350
  3. * soft nofile 655350
  4. * hard nofile 655350
  5. * soft stack 20480
  6. * hard stack 20480
  7. * soft nproc 655360
  8. * hard nproc 655360
  9. * soft core unlimited
  10. * hard core unlimited

1.5、配置 sysctl.conf

vi /etc/sysctl.conf

  1. # for oceanbase
  2. ## 修改内核异步 I/O 限制
  3. fs.aio-max-nr=1048576
  4. ## 网络优化
  5. net.core.somaxconn = 2048
  6. net.core.netdev_max_backlog = 10000
  7. net.core.rmem_default = 16777216
  8. net.core.wmem_default = 16777216
  9. net.core.rmem_max = 16777216
  10. net.core.wmem_max = 16777216
  11. net.ipv4.ip_local_port_range = 3500 65535
  12. net.ipv4.ip_forward = 0
  13. net.ipv4.conf.default.rp_filter = 1
  14. net.ipv4.conf.default.accept_source_route = 0
  15. net.ipv4.tcp_syncookies = 0
  16. net.ipv4.tcp_rmem = 4096 87380 16777216
  17. net.ipv4.tcp_wmem = 4096 65536 16777216
  18. net.ipv4.tcp_max_syn_backlog = 16384
  19. net.ipv4.tcp_fin_timeout = 15
  20. net.ipv4.tcp_max_syn_backlog = 16384
  21. net.ipv4.tcp_tw_reuse = 1
  22. net.ipv4.tcp_tw_recycle = 1
  23. net.ipv4.tcp_slow_start_after_idle=0
  24. vm.swappiness = 0
  25. vm.min_free_kbytes = 2097152
  26. # 此处为 OceanBase 数据库的 data 目录
  27. 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 命令之后,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
返回:

  1. Welcome to the MariaDB monitor. Commands end with ; or \g.
  2. Your MySQL connection id is 3221546072
  3. Server version: 5.7.25 OceanBase 3.1.0 (r1-) (Built Apr 7 2021 08:14:49)
  4. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  5. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  6. MySQL [(none)]>

1.8、验证集群

  1. MySQL [oceanbase]> USE oceanbase;
  2. MySQL [oceanbase]> SELECT * FROM __all_server;
  3. +----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
  4. | 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 |
  5. +----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
  6. | 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 |
  7. | 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 |
  8. | 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 |
  9. +----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
  10. 3 rows in set (0.00 sec)