当前位置:   article > 正文

oceanbase部署--使用OBD自动化部署单节点集群_oceanbase obce

oceanbase obce

资源列表:

OS:  rhel 8.0
CPU: 4C
内存:总内存 16G,可用内存 14G
磁盘1:/dev/sdb 30G
磁盘2:/dev/sdc 30G
  • 1
  • 2
  • 3
  • 4
  • 5

机器和角色划分

OBD      192.168.152.30 中控机,自动化部署软件
OBServer 192.168.152.30 OceanBase 数据库
OBProxy  192.168.152.30 OceanBase 访问反向代理
OBClient 192.168.152.30 OceanBase 命令行客户端
  • 1
  • 2
  • 3
  • 4

lvm 分盘

pvcreate /dev/sdb
vgcreate obvg /dev/sdb
lvcreate -L 5G obvg -n lvredo
lvcreate -l 100%FREE obvg -n lvdata(也可以单独为data文件系统创建新的VG和LV)
  • 1
  • 2
  • 3
  • 4

格式化文件系统

mkfs.xfs /dev/obvg/lvdata
mkfs.xfs /dev/obvg/lvredo
mkdir -p /redo /data
注意:xfs扩容在8.x linux里,用xfs_growfs /挂载点 而非 xfs.growfs /dev/vgname/lvname
  • 1
  • 2
  • 3
  • 4

修改 mount 参数文件

vim /etc/fstab
/dev/obvg/lvredo /redo xfs defaults 0 0
/dev/obvg/lvdata /data xfs defaults 0 0
mount /data
mount /redo
chown -R admin.admin /data /redo
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

admin用户编辑 OBD 配置文件obce-single.yaml

oceanbase-ce:
  servers:
    # Please don't use hostname, only IP can be supported
    - 192.168.152.30
  global:
    home_path: /home/admin/oceanbase-ce
    data_dir: /data
    redo_dir: /redo
    devname: ens33
    mysql_port: 2881
    rpc_port: 2882
    zone: zone1
    cluster_id: 1 
    memory_limit: 8G # The maximum running memory for an observer
    system_memory: 3G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
    datafile_size: 10G # Size of the data file. 
    log_disk_size: 2G # The size of disk space used by the clog files.
    cpu_count: 16
    production_mode: false
    syslog_level: WARN # 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: bzNvgyhB # root user password, can be empty
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

该配置文件是专门针对最小内存(可用内存大于 8G)的节点配置,指定了很多 observer 进程 的启动参数。
需注意 yaml的格式,每个配置项后面冒号(:)跟后面的值之间必须有个空格 (’ ')。
部署成功后,OBD 会把配置文件obce-single.yaml复制到自己的工作目录里(~/.obd/cluster/obce-single/config.yaml),后期再对原obce-single.yaml 文件进行修改是不生效的。

开始部署

 obd cluster deploy [集群名] -c 集群配置文件。
 集群名是配置文件在 OBD 里的唯一标识,可以跟配置文件中的集群名相同,也可以跟文件名相同(建议都一致)。
 
 admin用户:
 obd cluster deploy obce-single -c obce-single.yaml
  • 1
  • 2
  • 3
  • 4
  • 5

部署结果

obd cluster list 查看部署状态。
  • 1

查看目录结构。

其中 /store 、/data 和 /redo 的目录关系是重点。总体结构不变,后期映射关系时可能会进行细微调整

tree /home/admin/oceanbase-ce/
[admin@obce01 ~]$ tree /home/admin/oceanbase-ce//single/   ---此处我的环境是在配置文件做了修改,包括home_path: /home/admin/oceanbase-ce/single,data、redo等
/home/admin/oceanbase-ce//single/
├── admin
├── bin
│   ├── import_time_zone_info.py -> /home/admin/.obd/repository/oceanbase-ce/3.1.0/84bd2fe27f8b8243cc57d8a3f68b4c50f94aab80/bin/./import_time_zone_info.py
│   └── observer -> /home/admin/.obd/repository/oceanbase-ce/3.1.0/84bd2fe27f8b8243cc57d8a3f68b4c50f94aab80/bin/./observer
├── etc
│   ├── observer.config.bin
│   ├── observer.config.bin.history
│   └── timezone_V1.log
├── etc2
│   ├── observer.conf.bin
│   └── observer.conf.bin.history
├── etc3
│   ├── observer.conf.bin
│   └── observer.conf.bin.history
├── lib
├── log
│   ├── election.log
│   ├── election.log.wf
│   ├── observer.log
│   ├── observer.log.20230209120454
│   ├── observer.log.wf
│   ├── rootservice.log
│   └── rootservice.log.wf
├── run
│   ├── mysql.sock
│   └── observer.pid
└── store -> /data/single

9 directories, 18 files

 tree /redo/single/   --我的集群已启动运行好几天,所有存在日志文件
 /redo/single/
├── clog
│   ├── 1
│   ├── 10
│   ├── 11
│   ├── 12
│   ├── 13
│   ├── 14
│   ├── 15
│   ├── 16
│   ├── 17
│   ├── 18
│   ├── 19
│   ├── 2
│   ├── 3
│   ├── 4
│   ├── 5
│   ├── 6
│   ├── 7
│   ├── 8
│   └── 9
├── ilog
│   ├── 1
│   └── 2
└── slog
    └── 1


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62

启动和初始化集群

第一次运行 start 命令会对集群进行初始化(boostrap),以后再使用 start 命令就只会启动集群中节点进程。

obd cluster start obce-single
注意:当可用内存不足 8G 或者日志目录剩余可用空间比例不足 5%时,bootstrap 很可能会失败
  • 1
  • 2

检查数据文件大小
进程 observer 启动后会初始化数据文件 block_file 的大小,可根据参数 datafile_size 或 datafile_disk_percentage 进行控制。

ls -lrth /data/sstable/block_file
  • 1

检查进程

 ps -ef | grep observer | grep -v grep
 结果如下:
[admin@obce01 clog]$  ps -ef | grep observer | grep -v grep
admin    18074     1 99 Feb09 ?        1-08:29:02 /home/admin/oceanbase-ce/single/bin/observer -r 192.168.152.30:2882:2881 -p 2881 -P 2882 -z zone1 -c 1 -d /data/single -i ens33 -l WARN -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=3G,datafile_size=10G,log_disk_size=2G,cpu_count=16,production_mode=False,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4
  • 1
  • 2
  • 3
  • 4

可以看到进程启动时,通过 -o 指定了很多参数,这些参数均已是在前述 OBD 集群部署配置文件中指定

netstat -ntlp |grep observer
  • 1

查看 OceanBase 集群obce-single并连接内部实例(sys)

[admin@obce01 clog]$ obd cluster display obce-single
Get local repositories and plugins ok
Open ssh connection ok
Cluster status check ok
Connect to observer ok
Wait for observer init ok
+--------------------------------------------------+
|                     observer                     |
+----------------+---------+------+-------+--------+
| ip             | version | port | zone  | status |
+----------------+---------+------+-------+--------+
| 192.168.152.30 | 3.1.0   | 2881 | zone1 | active |
+----------------+---------+------+-------+--------+
obclient -h192.168.152.30 -P2881 -uroot -pbzNvgyhB -Doceanbase -A
连接数据库:mysql命令或者obclient命令均可
mysql    -h 192.168.152.30 -uroot@sys -P2881 -pbzNvgyhB -c -A oceanbase
obclient -h 192.168.152.30 -uroot@sys -P2881 -pbzNvgyhB -c -A oceanbase
MySQL [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.003 sec)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/168057
推荐阅读
相关标签
  

闽ICP备14008679号