暂无图片
暂无图片
3
暂无图片
暂无图片
暂无图片

「OceanBase 征文」单片机树莓派 in OceanBase4.0 体验之旅!

原创 shunwah 2023-03-12
1488

作者:马顺华

从事运维管理工作多年,目前就职于某科技有限公司,熟悉运维自动化、OceanBase部署运维、MySQL 运维以及各种云平台技术和产品。并已获得OceanBase认证OBCA、OBCP 证书、OpenGauss社区认证结业证书。OceanBase & 墨天轮第二、三、四、五届技术征文大赛,多次获得 一、二、三 等奖,时常在墨天轮发布原创技术文章,并多次被首页推荐。

前言:

我这次测试的linux电脑是树莓派,装64位linux,再装上jdk8就能部署和运行OceanBase4.0数据库了,树莓派安装64位系统请参考网络。
这台树莓派是我在 OceanBase & 墨天轮技术征文大赛获得的奖品,一直没用,现在拿来测试一下。这份礼物有什么含义?这是地球上最小的电脑:树莓派,它是世界范围内技术文化的代表之一。而你手上这台更为特殊,我们将 OceanBase 4.0“小鱼”部署在上面,它对于 OceanBase 实现小型化具有象征意义,同时,“小鱼"这个名字也意味着从“分布式”到“单机分布式一体化”的转变。

image.png
image.png
我自己折腾过很多云服务器,花了好多钱买了很多便宜机器,啥事也没干,想要自己搭建一个 OB 集群肯定需要一些稳定的机器了。
刚好有一台树莓派微型电脑,使用树莓派再好不过了,功耗小,永久使用权,方便折腾,也有OB老师技术支持,所以毫不犹豫就下手实操。缺点就是有些软件不支持树莓派,例如私有镜像仓库软件Harber没有支持Arm架构,基于PHP的Hyperf框架也不支持Arm架构,还有更多的的坑还我去踩。

image.png

一、如何启动树莓派?

1.通过相应接口将树莓派与显示器、键鼠进行连接

(请勿直接连接电源)

连接电源前,请在电源线和树莓派之间接入电源控制线
image.png
image.png

2.电源控制线和HDMI线接入

image.png

image.png

3.通过USB2.0接口连接有线键盘与鼠标

image.png
image.png

二、连接树莓派针脚

把风扇与树莓派针脚正确地进行连接

image.png

树莓派配有通用输入输出 (GPIO)针脚,你可通过它连接传感器、继电器、和其它类型的电子元件如风扇。请参考图示进行连接(亮片面朝外,从外侧第二针脚插入)
image.png

三、连接电源及树莓派电源

image.png

1.连接至供电端口

如插座。此时树莓派应亮起工作指示灯,如未亮起,请点按电源控制线上的圆形按钮。树莓派通电后会自A0当你使用完设备后,请先关闭树莓派操作系统,等待指示灯停止闪烁,然后点按电源控制线圆形按钮断开电源。如需再次开机,请等待至少五秒后再通电。
image.png

2.进入树莓派系统桌面

image.png

四、连接Wi-Fi网络

1.进入树莓派界面后,请通过右上角按钮连接 Wi-Fi。

image.png

2.顺利连接上 Wi-Fi 网络

image.png

3.可以访问树莓派网站了

image.png

五、如何进入 OceanBase 4.0 数据库环境?

进入树莓派系统后,在系统桌面左上方单击命令行窗口。
image.png

1.查看obd命令是否生效
oceanbase@raspberrypi:~ $ command -v obd
/home/oceanbase/.oceanbase-all-in-one/obd/usr/bin/obd

image.png

2.添加不生效可执行
source ~/.bashrc
3.通过obd查看部署情况
oceanbase@raspberrypi:~ $ obd cluster list
+------------------------------------------------------------+
|                        Cluster List                        |
+------+-----------------------------------+-----------------+
| Name | Configuration Path                | Status (Cached) |
+------+-----------------------------------+-----------------+
| demo | /home/oceanbase/.obd/cluster/demo | running         |
+------+-----------------------------------+-----------------+

image.png

4.通过obd拉起observer
oceanbase@raspberrypi:~ $ obd cluster start demo
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Cluster status check ok
Check before start observer ok
[WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)
[WARN] (127.0.0.1) failed to get open files
[WARN] (127.0.0.1) failed to get max user processes

Check before start obproxy ok
Check before start obagent ok
Check before start prometheus ok
Check before start grafana ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster ok
Start obproxy ok
obproxy program health check ok
Connect to obproxy ok
Initialize cluster ok
Start obagent ok
obagent program health check ok
Start promethues ok
prometheus program health check ok
Connect to Prometheus ok
Initialize cluster ok
Start grafana ok
grafana program health check ok
Connect to grafana ok
Initialize cluster ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.0.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A

+---------------------------------------------+
|                   obproxy                   |
+-----------+------+-----------------+--------+
| ip        | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884            | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
+-------------------------------------------------+
|                     obagent                     |
+-----------+-------------+------------+----------+
| ip        | server_port | pprof_port | status   |
+-----------+-------------+------------+----------+
| 127.0.1.1 | 8088        | 8089       | inactive |
+-----------+-------------+------------+----------+
+--------------------------------------------------+
|                    prometheus                    |
+-----------------------+------+----------+--------+
| url                   | user | password | status |
+-----------------------+------+----------+--------+
| http://127.0.1.1:9090 |      |          | active |
+-----------------------+------+----------+--------+
+----------------------------------------------------------------+
|                            grafana                             |
+-----------------------------------+-------+-----------+--------+
| url                               | user  | password  | status |
+-----------------------------------+-------+-----------+--------+
| http://127.0.1.1:3000/d/oceanbase | admin | oceanbase | active |
+-----------------------------------+-------+-----------+--------+
demo running

image.png

5.访问prometheus

127.0.1.1:9090

image.png

6.访问grafana

127.0.1.1:3000

image.png

6.访问observer 2881
oceanbase@raspberrypi:~ $ obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487618
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:25:35)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.063 sec)

obclient [oceanbase]> 

4b597b4fbed2be5a72d699af910cfbe.jpg

7.访问 obproxy 2883
oceanbase@raspberrypi:~ $ obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 2
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:25:35)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.044 sec)

obclient [oceanbase]> 

0929ff51325ed4cd851b907a439f3e8.jpg

到此,你已进入数据库环境,可以根据你的需求进行下一步操作。

总结:

感谢 OB 金吾老师提供树莓派的使用与配置技术和文档支持,想尝试更多的安装历程,查找相关软件包是否支持树莓派非常重要。在尝试中遇到的问题非常的多,我遇到的问题基本上都可以通过搜索引擎搜到解决方法,只要自己勇于折腾不怕犯错,就一定可以完成,自己从零开始到OB正常运行跑起来就会非常有成就感啊。当然obd demo简化了很多安装流程,新手马上就能上手部署,没有涉及到很复杂的知识。当然我也不是太专业也难免会有出错的地方,有哪些有问题的地方欢迎大家指出,不甚感激。接下来会在树莓派测试集群功能和相关应用测试一下,感谢大家的支持,大家的评论点赞互动才是我的动力哦。

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

评论