OceanBase | 试用版安装初体验

使用部署脚本在 Linux 平台上部署 OceanBase 试用版

OceanBase官网提供了试用版产品包,对于一直想学习OceanBase的同学来说是一大福音,本文将对试用版的安装做一个记录。

试用版本可以通过脚本部署安装,也可使用使用 docker 镜像进行安装,本片介绍前者内容,也就是在 Linux 上使用提供的部署脚本安装。

在服务器的配置上,使用版本没有对数量上的要求,我们可以使用1台测试机进行安装部署,一般的虚机环境就可以搞定。

  • 操作系统:CentOS 6 或 CentOS 7

  • 内存:8G

  • 磁盘:20G

 

01 准备工作

资源下载

在OceanBase的官网即可完成试用版OB的下载(需注册),产品包名为mini-ob-deploy.tar,大小为79.3M。

官网下载地址:

https://www.oceanbase.com/download

检查系统

这里使用CentOS7.6作为部署环境,内存为8G,系统剩余存储空间在60G。

系统内核

[root@tank ~]# uname -a
Linux gs01 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

内存空间

[root@tank ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7

磁盘空间

[root@tank ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        80G   20G   61G  25% /
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G   13M  3.8G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1       497M  167M  330M  34% /boot
tmpfs           781M  4.0K  781M   1% /run/user/42
tmpfs           781M   48K  781M   1% /run/user/0

iptables策略

[root@tank ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@tank ~]#

创建用户

这里参照在线手册的规范,创建admin用户。

[root@tank ~]# useradd admin
[root@tank ~]# passwd admin

创建工作路径


[root@tank ~]# mkdir /ob
[root@tank ~]# chown admin:admin /ob

02 安装

首先切换至admin用户,对安装包进行解包。

[root@tank ~]# su - admin
Last login: Tue Oct 27 21:21:44 CST 2020 on pts/0
[admin@tank ~]$  ll
total 81268
-rw-r--r-- 1 admin admin 83216182 Oct 27 21:21 mini-ob-deploy.tar
[admin@tank ~]$  tar xvf mini-ob-deploy.tar
[admin@tank ~]$  ll
total 81272
drwxr-xr-x 11 admin admin     4096 Aug 20 11:39 mini-ob-deploy
-rw-r--r--  1 admin admin 83216182 Oct 27 21:21 mini-ob-deploy.tar
[admin@tank ~]$  cd mini-ob-deploy
[admin@tank mini-ob-deploy]$  pwd
/home/admin/mini-ob-deploy
[admin@tank mini-ob-deploy]$  ll
total 3764
drwxr-xr-x 2 admin admin      27 Aug 20 11:36 b
drwxr-xr-x 2 admin admin      22 Aug 20 11:38 bin
-rw-r--r-- 1 admin admin     501 Aug 20 11:36 config.py
-rw-r--r-- 1 admin admin     305 Aug 20 11:36 deploy.dockerfile
-rw-r--r-- 1 admin admin     606 Aug 20 11:36 features.md
drwxr-xr-x 2 admin admin     114 Aug 20 11:36 h
-rwxr-xr-x 1 admin admin  276599 Aug 20 11:36 hap.py
-rw-r--r-- 1 admin admin    2835 Aug 20 11:36 init.sql
-rw-r--r-- 1 admin admin     342 Aug 20 11:36 init_user_oracle.sql
-rw-r--r-- 1 admin admin     295 Aug 20 11:36 init_user.sql
drwxr-xr-x 2 admin admin      95 Aug 20 11:36 install
drwxr-xr-x 2 admin admin      53 Aug 20 11:36 lib
-rw-r--r-- 1 admin admin     560 Aug 20 11:36 Makefile
-rwxr-xr-x 1 admin admin 3539416 Aug 20 11:36 mysql
drwxr-xr-x 2 admin admin     163 Aug 20 11:40 mysql_example
drwxr-xr-x 2 admin admin     207 Aug 20 11:36 oracle_example
-rw-r--r-- 1 admin admin     960 Aug 20 11:39 README.md
drwxr-xr-x 4 admin admin      30 Aug 20 11:36 sysbench

在config.py文件中确认默认配置,需要注意“home”参数所对应路径的权限。

执行命令之后会启动一个单 server 的 OceanBase 集群,默认 MySQL 端口号为 2881,rpc 端口号为 2882。


[admin@tank mini-ob-deploy]$ cat config.py 
load('obi,obt-patch,mini-mode,sample-db,sysbench')
if not indocker():
    home = '/ob'
obs_cfg.update(mini_mode_cfg)
obs_cfg.update(system_memory='5G', memory_limit='8G', datafile_size='10G')

# 定义一个单server的ob集群,mysql端口号2881,rpc端口号2882
ob1 = OBI('127.0.0.1:2882:2881')
# 定义另一个单server的ob集群,mysql端口号/rpc端口号由uid hash生成
ob2 = OBI('127.0.0.1')
# 单个机器上起3个observer
ob3 = OBI('127.0.0.1@[z1,z2,z3]', dev='lo', is_local=True)
[admin@tank mini-ob-deploy]$

接下来通过脚本初始化OceanBase实例,时间在1分钟左右。如反复提示连接拒绝,请确认iptables是否被清空。

[admin@tank mini-ob-deploy]$  ./hap.py ob1.reboot
2020-10-27 21:39:04.419072 call.py:3 CALL: top make_local_etc_dir
2020-10-27 21:39:04.452645 call.py:3 CALL: top ob1.reboot
2020-10-27 21:39:04.457306 call.py:3 CALL: top.ob1 local_reboot
2020-10-27 21:39:04.465673 call.py:3 CALL: top.ob1 force_stop
2020-10-27 21:39:04.472002 call.py:3 CALL: top.ob1 stop
2020-10-27 21:39:04.481572 call.py:3 CALL: top.ob1 all_server
2020-10-27 21:39:04.490331 call.py:3 CALL: top.ob1.obs0 stop
2020-10-27 21:39:04.506482 magic_ctrl.py:3 retry_loop: retryloop: timeout=10 interval = 0.1
2020-10-27 21:39:04.516732 magic_ctrl.py:6 retry_loop: #### tryloop try_stop ####
2020-10-27 21:39:04.531343 call.py:3 CALL: top.ob1.obs0 try_stop
12445
2020-10-27 21:39:04.575025 magic_ctrl.py:12 retry_loop: tryloop fail: Fail: shell fail: if pgrep -u admin -f '^/ob/ob1.obs0/bin/'; then  pkill -9 -u admin -f '^/ob/ob1.obs0/bin/' && false; fi input=None ret=1 
2020-10-27 21:39:04.686865 magic_ctrl.py:6 retry_loop: #### tryloop try_stop ####
2020-10-27 21:39:04.714658 call.py:3 CALL: top.ob1.obs0 try_stop
2020-10-27 21:39:04.770073 magic_ctrl.py:9 retry_loop: #### tryloop success ####
2020-10-27 21:39:04.783420 call.py:3 CALL: top.ob1 sleep
***中间过程省略***
2020-10-27 21:39:41.450288 magic_ctrl.py:9 retry_loop: #### tryloop success ####
2020-10-27 21:39:41.456057 call.py:3 CALL: top.ob1 exec_init_sql
2020-10-27 21:39:41.463690 call.py:3 CALL: top.ob1 obs0.sql
2020-10-27 21:39:55.535108 call.py:3 CALL: top.ob1 add_server
2020-10-27 21:39:55.545867 call.py:3 CALL: top.ob1 all_obs
2020-10-27 21:39:55.558274 call.py:3 CALL: top.ob1 exec_init_user_sql1
2020-10-27 21:39:55.566954 call.py:3 CALL: top.ob1 exec_init_user_sql2
2020-10-27 21:39:55.576170 call.py:3 CALL: top.ob1 obs0.mysql
2020-10-27 21:39:55.813021 call.py:3 CALL: top.ob1 start_proxy
2020-10-27 21:39:55.848355 call.py:3 CALL: top.ob1 all_proxy
2020-10-27 21:39:55.857583 call.py:3 CALL: top.ob1 check_bootstrap
2020-10-27 21:39:55.864445 call.py:3 CALL: top.ob1 obs0.check_bootstrap
[('force_stop', [('obs0.stop', 'succ')]),
 ('sleep', None),
 ('cleanup', [('obs0.rmdir', 0)]),
 ('mk_local_dir', 0),
 ('mkdir', [('obs0.mkdir', 0)]),
 ('local_sync', [('obs0.local_sync', 0)]),
 ('prepare_proxy_cfg', 'skip'),
 ('start_servers', [('obs0.start', 0)]),
 ('bootstrap', 'succ'),
 ('post_bootstrap', None),
 ('wait_service', 'succ'),
 ('exec_init_sql', 0),
 ('add_server', []),
 ('exec_init_user_sql1', 'skip'),
 ('exec_init_user_sql2', 0),
 ('start_proxy', []),
 ('check_bootstrap', 0)]

如果输出内容和上述内容一致,那么到这里已经初试化完成了。

如果 2881/2882 端口被占用, 可以修改 config.py 中如下这一行。

ob1 = OBI('127.0.0.1:2882:2881')

初始化 OceanBase 实例成功之后,会自动创建两个租户,sys 租户和一个普通的 mysql 租户。

 

03 验证

按照如下方式来通过 MySQL 客户端连接 OceanBase 数据库。

[admin@tank mini-ob-deploy]$  ./hap.py ob1.obmysql
2020-10-27 21:53:44.664389 call.py:3 CALL: top make_local_etc_dir
2020-10-27 21:53:44.689985 call.py:3 CALL: top ob1.obmysql
2020-10-27 21:53:44.694479 call.py:3 CALL: top.ob1 sql
2020-10-27 21:53:44.698630 call.py:3 CALL: top.ob1 obs0.sql
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 MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221491363
Server version: 5.7.25 OceanBase 2.2.50 (r1-1c6441e8fb858c80da395f934f67ed305425864e) (Built Mar  6 2020 18:41:01)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

OceanBase(root@oceanbase)>

创建、查看数据库


OceanBase(root@oceanbase)>create database tank;
Query OK, 1 row affected (0.09 sec)

OceanBase(root@oceanbase)>show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
| tank               |
+--------------------+
8 rows in set (0.01 sec)


OceanBase(root@oceanbase)>use tank;
Database changed

OceanBase(root@tank)>select database();
+------------+
| database() |
+------------+
| tank       |
+------------+
1 row in set (0.00 sec)

查询当前数据库版本


OceanBase(root@tank)>select version();
+-----------+
| version() |
+-----------+
| 2.2.50    |
+-----------+
1 row in set (0.01 sec)

后台进程

[admin@tank ~]$ ps -ef|grep admin
root      11411  10683  0 15:17 pts/0    00:00:00 su - admin
admin     11412  11411  0 15:17 pts/0    00:00:00 -bash
root      12058  11493  0 15:26 pts/0    00:00:00 su - admin
admin     12059  12058  0 15:26 pts/0    00:00:00 -bash
admin     13272      1 99 15:35 ?        04:17:32 /ob/ob1.obs0/bin/observer -P 2882 -p 2881 -z test -n ob1.admin -c 1 -d /ob/ob1.obs0/store -l INFO -i lo -r 127.0.0.1:2882:2881 -o memory_limit=8G,cache_wash_threshold=1G,row_purge_thread_count=1,net_thread_count=1,enable_syslog_recycle=True,enable_merge_by_turn=FALSE,cpu_count=16,location_refresh_thread_count=2,max_syslog_file_count=3,major_freeze_duty_time=Disable,__easy_memory_limit=1G,schema_history_expire_time=1d,merge_thread_count=1,writing_throttling_trigger_percentage=70,_max_trx_size=2M,workers_per_cpu_quota=2,enable_separate_sys_clog=0,datafile_disk_percentage=50,__min_full_resource_pool_memory=536870912,system_memory=5G,memory_chunk_cache_size=128M,trace_log_slow_query_watermark=10s,writing_throttling_maximum_duration=1m,switchover_process_thread_count=1,datafile_size=10G,minor_freeze_times=500,stack_size=1536K,disk_io_thread_coun=1
admin     14357  12059  0 15:50 pts/0    00:00:00 python2 ./hap.py ob1.obmysql
admin     14364  14357  0 15:50 pts/0    00:00:00 ./mysql --prompt OceanBase(\u@\d)> -h 127.0.0.1 -P 2881 -uroot -Doceanbase -c

结语

试用版安装已完成,对于单机的试用版来说安装比较简单,创建用户、解压、初始化即完成了安装,可以说是分分钟搞定。

通过简单的验证可以发现和黑屏客户端基本和MySQL是一致的,熟悉MySQL的同学可直接上手操作,以上是试用版的安装记录,后续讲深入学习OceanBase在技术架构上的内容。

 

参考资料

https://www.oceanbase.com/docs/oceanbase-trial/V2.2.50/gvudvy

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 13
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值