暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

「OceanBase 征文」|OB4.0-快速安装部署

原创 不想用随机名字 2023-02-28
1085

    之前一直想在自己的虚拟机上安装一个OB玩玩,但是奈何我的电脑只有8G内存,实在是难以支撑OB的运行,去年推出了OB4.0,内存6G就可以玩了,但是最近确实太忙了,一直没有时间学习,趁着这次机会学习一下。

测试环境介绍

资源 描述
内存 6G
操作系统 Cenos7

下载解压

ob4.0的下载地址:https://open.oceanbase.com/quickStart
image.png
上传到/soft目录,然后进行解压

tar -xzf oceanbase-all-in-one.4.0.0.0-beta-100120221102135736.el7.x86_64.tar.gz

解压完成之后安装软件包

cd oceanbase-all-in-one/bin ./install.sh
[root@miniob bin]# ./install.sh name: grafana version: 7.5.17 release:1 arch: x86_64 md5: 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 add /soft/oceanbase-all-in-one/rpms/grafana-7.5.17-1.el7.x86_64.rpm to local mirror name: obagent version: 1.2.0 release:4.el7 arch: x86_64 md5: 0e8f5ee68c337ea28514c9f3f820ea546227fa7e add /soft/oceanbase-all-in-one/rpms/obagent-1.2.0-4.el7.x86_64.rpm to local mirror name: obproxy-ce version: 4.0.0 release:5.el7 arch: x86_64 md5: de53232a951184fad75b15884458d85e31d2f6c3 add /soft/oceanbase-all-in-one/rpms/obproxy-ce-4.0.0-5.el7.x86_64.rpm to local mirror name: oceanbase-ce version: 4.0.0.0 release:100000272022110114.el7 arch: x86_64 md5: 42611dc51ca9bb28f36e60e4406ceea4a74914c7 add /soft/oceanbase-all-in-one/rpms/oceanbase-ce-4.0.0.0-100000272022110114.el7.x86_64.rpm to local mirror name: oceanbase-ce-libs version: 4.0.0.0 release:100000272022110114.el7 arch: x86_64 md5: 188919f8128394bf9b62e3989220ded05f1d14da add /soft/oceanbase-all-in-one/rpms/oceanbase-ce-libs-4.0.0.0-100000272022110114.el7.x86_64.rpm to local mirror name: prometheus version: 2.37.1 release:10000102022110211.el7 arch: x86_64 md5: 58913c7606f05feb01bc1c6410346e5fc31cf263 add /soft/oceanbase-all-in-one/rpms/prometheus-2.37.1-10000102022110211.el7.x86_64.rpm to local mirror Disable remote ok ##################################################################### Install Finished ===================================================================== Setup Environment: source ~/.oceanbase-all-in-one/bin/env.sh Quick Start: obd demo More Details: obd -h =====================================================================

    日志中列出了安装了那些包,版本是什么。如果想要快速启动可以使用 obd demo,我还是想多手工参与一下手动创建ob集群。

配置OB集群

编辑配置文件

    默认的配置文件在~/oceanbase-all-in-one/conf中,因为我想用单机的,所以找到mini的配置文件mini-single-example.yaml,并对其进行修改

## Only need to configure when remote login is required # user: # username: your username # password: your password if need # 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 - 172.20.10.177 global: # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /home/miniob/observer # The directory for data storage. The default value is $home_path/store. # data_dir: /data # 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: enp0s3 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: 4G # The maximum running memory for an observer system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. datafile_size: 5G # Size of the data file. log_disk_size: 5G # The size of disk space used by the clog files. cpu_count: 16 production_mode: true 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

    注意:主要修改了IP地址、memory_limit、home_path,因为是测试环境,资源有限,所以我也没有安装obproxy,2881端口是对外提供服务的端口,2882是集群内部通信使用的端口。

执行安装命令

    编辑好配置文件,执行命令初始化集群 obd cluster autodeploy obtest -c miniob.yaml。

[root@miniob conf]# obd cluster autodeploy obtest -c miniob.yaml Package oceanbase-ce-4.0.0.0-100000272022110114.el7 is available. install oceanbase-ce-4.0.0.0 for local ok Cluster param config check ok Open ssh connection x [ERROR] root@172.20.10.177 connect failed: No authentication methods available

    提示报错了,看错误需要进行ssh免密登录,配置root用户的互信。

[root@miniob ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:00Av38jY5e7V+sUzOYgmLvnDlC1/7kKOxQFbF2xo2JM root@miniob The key's randomart image is: +---[RSA 2048]----+ | . o +.. | | . + E + | | o * = | | X * | | S X + | | = *. .o.| | +.Bo...=+| | o.+o= o .=| | oo. *o...| +----[SHA256]-----+ [root@miniob ~]# ssh-copy-id root@172.20.10.177 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@172.20.10.177's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@172.20.10.177'" and check to make sure that only the key(s) you wanted were added.

    配置完互信以后继续安装

[root@miniob conf]# obd cluster autodeploy obtest -c miniob.yaml install oceanbase-ce-4.0.0.0 for local ok Cluster param config check ok Open ssh connection ok Generate observer configuration ok install oceanbase-ce-4.0.0.0 for local ok +--------------------------------------------------------------------------------------------+ | Packages | +--------------+---------+------------------------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+------------------------+------------------------------------------+ | oceanbase-ce | 4.0.0.0 | 100000272022110114.el7 | 42611dc51ca9bb28f36e60e4406ceea4a74914c7 | +--------------+---------+------------------------+------------------------------------------+ Repository integrity check ok Parameter check ok Open ssh connection ok Cluster status check ok Initializes observer work home ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository install ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository lib check !! Try to get lib-repository Package oceanbase-ce-libs-4.0.0.0-100000272022110114.el7 is available. install oceanbase-ce-libs-4.0.0.0 for local ok Remote oceanbase-ce-libs-4.0.0.0-100000272022110114.el7-188919f8128394bf9b62e3989220ded05f1d14da repository install ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository lib check ok obtest deployed Get local repositories ok Search plugins ok Open ssh connection ok Load cluster param plugin ok Check before start observer x [WARN] (172.20.10.177) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536) [ERROR] OBD-1007: (172.20.10.177) open files must not be less than 20000 (Current value: 1024) [WARN] (172.20.10.177) clog and data use the same disk (/) [ERROR] (172.20.10.177) / not enough disk space. (Avail: 14.1G, Need: 20.0G) See https://www.oceanbase.com/product/ob-deployer/error-codes .

    仍然报错,错误也比较明显,磁盘空间不够,需要20个G,并且openfiile需要大于20000。扩容磁盘和修改openfile这里就不介绍了,调整完成后继续安装。

[root@miniob conf]# obd cluster autodeploy obtest miniob.yaml [ERROR] Deploy "obtest" is deployed. You could not deploy an deployed cluster. See https://www.oceanbase.com/product/ob-deployer/error-codes .

    仍然报错,提示已经部署过obtest,执行obd cluster -h 查看如何重新部署,需要使用参数redeploy,执行命令:obd cluster redeploy obtest

[root@miniob conf]# obd cluster redeploy obtest Get local repositories ok Search plugins ok Open ssh connection ok Cluster status check ok observer work dir cleaning ok obtest destroyed install oceanbase-ce-4.0.0.0 for local ok +--------------------------------------------------------------------------------------------+ | Packages | +--------------+---------+------------------------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+------------------------+------------------------------------------+ | oceanbase-ce | 4.0.0.0 | 100000272022110114.el7 | 42611dc51ca9bb28f36e60e4406ceea4a74914c7 | +--------------+---------+------------------------+------------------------------------------+ Repository integrity check ok Parameter check ok Cluster status check ok Initializes observer work home ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository install ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository lib check !! Try to get lib-repository install oceanbase-ce-libs-4.0.0.0 for local ok Remote oceanbase-ce-libs-4.0.0.0-100000272022110114.el7-188919f8128394bf9b62e3989220ded05f1d14da repository install ok Remote oceanbase-ce-4.0.0.0-100000272022110114.el7-42611dc51ca9bb28f36e60e4406ceea4a74914c7 repository lib check ok obtest deployed Search plugins ok Load cluster param plugin ok Check before start observer ok [WARN] (172.20.10.177) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536) [WARN] OBD-1007: (172.20.10.177) The recommended number of open files is 655350 (Current value: 65535) [WARN] (172.20.10.177) clog and data use the same disk (/) Start observer ok observer program health check ok Connect to observer ok Initialize cluster ok Wait for observer init ok +-------------------------------------------------+ | observer | +---------------+---------+------+-------+--------+ | ip | version | port | zone | status | +---------------+---------+------+-------+--------+ | 172.20.10.177 | 4.0.0.0 | 2881 | zone1 | ACTIVE | +---------------+---------+------+-------+--------+ obclient -h172.20.10.177 -P2881 -uroot -Doceanbase obtest running

    到这里安装成功了,OB4.0的安装还是比较简单的。

连接数据库

[root@miniob conf]# obclient -h172.20.10.177 -P2881 -uroot -Doceanbase Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221487617 Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov 1 2022 14:57:18) Copyright (c) 2000, 2018, OB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [oceanbase]>

总结

    在安装OB4.0的时候还是碰到了一些小插曲,这里总结一下,
    1. 使用obd安装部署时,因为obd是需要ssh远程部署,所以需要对安装用户进行ssh互信。
    2. 磁盘空间必须要大于20个G。
    3. 操作系统的max open file需要大于20000。
    4. 如果部署失败重新部署需要使用redeploy重新部署,obd -h 可以查看命令帮助,obd [option] -h 可以查看子命令的帮助。
    5. memory_limit最小是4G,否则在初始化集群的时候会报错。

最后修改时间:2023-03-06 11:26:34
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论