实验2:通过OBD安装部署OceanBase集群

通过OBD安装部署OceanBase集群

主机环境

使用单机部署单副本集群,包括一个 OBProxy 节点

主机名ip配置操作系统
competet-oecanbase192.179.4.21216C/64G/1.5TCentOS 7.9

安装前准备

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

关闭selinux

setenforce 0
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config

配置limits.conf

cat >> /etc/security/limits.conf << EOF
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft stack 20480
* hard stack 20480
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
EOF

新建连接,ulimit -a查看资源分配

[root@competet-oecanbase ~]# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256964
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 655350
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 20480
cpu time               (seconds, -t) unlimited
max user processes              (-u) 655360
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

配置sysctl.conf

echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
sysctl -p

关闭透明大页

[root@competet-oecanbase ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@competet-oecanbase ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

通过OBD安装部署OceanBase集群

安装OBD

在root用户下执行

如果网络不通,可以在https://open.oceanbase.com/softwareCenter/community下载需要的软件包

yum -y install ob-deploy

安装OBClient

yum -y install obclient

安装OBProxy

rpm -ivh obproxy-3.2.0-1.el7.x86_64.rpm 

使用OBD部署

下载配置文件

下载地址:https://github.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml

修改配置文件

oceanbase-ce:
  servers:
    # Please don't use hostname, only IP can be supported
    - 127.0.0.1
  global:
    home_path: /home/observer
    # 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: lo
    mysql_port: 2883
    rpc_port: 2882
    zone: zone1
    cluster_id: 1
    # please set memory limit to a suitable value which is matching resource. 
    memory_limit: 30G
    system_memory: 2G
    stack_size: 512K
    cpu_count: 16
    cache_wash_threshold: 1G
    __min_full_resource_pool_memory: 268435456
    workers_per_cpu_quota: 10
    schema_history_expire_time: 1d
    # The value of net_thread_count had better be same as cpu's core number. 
    net_thread_count: 4
    sys_bkgd_migration_retry_num: 3
    minor_freeze_times: 10
    enable_separate_sys_clog: 0
    enable_merge_by_turn: FALSE
    datafile_disk_percentage: 20
    appname: test
obproxy:
  servers:
    - 127.0.0.1
  global:
    listen_port: 2885
    home_path: /home/admin
    # oceanbase root server list
    # format: ip:mysql_port,ip:mysql_port
    rs_list: 127.0.0.1:2883
    enable_cluster_checkout: false
    # observer cluster name, consistent with oceanbase-ce's appname
    cluster_name: test

deploy集群

由于在配置文件已经写入了obproxy的信息,在deploy完集群,obproxy也安装并启动完成。

[root@competet-oecanbase ~]# obd cluster deploy ob02 -c mini-local-example.yaml 
oceanbase-ce-3.1.4 already installed.
obproxy-3.2.0 already installed.
+-------------------------------------------------------------------------------------------+
|                                          Packages                                         |
+--------------+---------+-----------------------+------------------------------------------+
| Repository   | Version | Release               | Md5                                      |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4   | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
| obproxy      | 3.2.0   | 1.el7                 | 8d5c6978f988935dc3da1dbec208914668dcf3b2 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Initializes obproxy work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Remote obproxy-3.2.0-1.el7-8d5c6978f988935dc3da1dbec208914668dcf3b2 repository install ok
Remote obproxy-3.2.0-1.el7-8d5c6978f988935dc3da1dbec208914668dcf3b2 repository lib check ok
Try to get lib-repository
oceanbase-ce-libs-3.1.4 already installed.
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
ob02 deployed
[root@competet-oecanbase ~]# obd cluster display ob02
Deploy "ob02" is deployed
See https://open.oceanbase.com/docs/obd-cn/V1.4.0/10000000000436999 .
[root@competet-oecanbase ~]# ps -ef|grep obproxy
root      2201     1  2 17:01 ?        00:00:18 /home/admin/bin/obproxy -o enable_cluster_checkout=False --listen_port 2885 --prometheus_listen_port 2884 --rs_list 127.0.0.1:2883 --cluster_name test
root      2256     1  0 17:01 pts/1    00:00:00 bash /home/admin/obproxyd.sh /home/admin 127.0.0.1 2885 daemon
root      4003 27563  0 17:15 pts/1    00:00:00 grep --color=auto obproxy
#通过obproxy登录,端口为2885
[root@competet-oecanbase ~]# obclient -h127.0.0.1 -P2885 -uroot
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 2
Server version: 5.6.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

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

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

obclient [(none)]> show processlist;
+------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+
| Id   | Tenant | User | Host            | db   | trans_count | svr_session_count | state             | tid  | pid  |
+------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+
|    2 | sys    | root | 127.0.0.1:57998 | NULL |           0 |                 1 | MCS_ACTIVE_READER | 2201 | 2201 |
+------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+
1 row in set (0.001 sec)

start集群

[root@competet-oecanbase ~]# obd cluster start ob02
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (127.0.0.1) clog and data use the same disk (/home)

Check before start obproxy ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.4   | 2883 | zone1 | active |
+-----------+---------+------+-------+--------+

Start obproxy ok
obproxy program health check ok
Connect to obproxy ok
Initialize cluster
+---------------------------------------------+
|                   obproxy                   |
+-----------+------+-----------------+--------+
| ip        | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2885 | 2884            | active |
+-----------+------+-----------------+--------+
ob02 running

使用obclient登录

[root@competet-oecanbase ~]# obclient -h127.0.0.1 -P2883 -uroot
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487630
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

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

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

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

obclient [(none)]> use oceanbase;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
obclient [oceanbase]> select * from gv$tenant;
+-----------+-------------+-----------+--------------+----------------+---------------+-----------+---------------+
| tenant_id | tenant_name | zone_list | primary_zone | collation_type | info          | read_only | locality      |
+-----------+-------------+-----------+--------------+----------------+---------------+-----------+---------------+
|         1 | sys         | zone1     | zone1        |              0 | system tenant |         0 | FULL{1}@zone1 |
+-----------+-------------+-----------+--------------+----------------+---------------+-----------+---------------+
1 row in set (0.003 sec)

obclient [oceanbase]>  select * from gv$unit;
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
| unit_id | unit_config_id | unit_config_name | resource_pool_id | resource_pool_name | zone  | tenant_id | tenant_name | svr_ip    | svr_port | migrate_from_svr_ip | migrate_from_svr_port | max_cpu | min_cpu | max_memory | min_memory | max_iops | min_iops | max_disk_size | max_session_num     |
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
|       1 |              1 | sys_unit_config  |                1 | sys_pool           | zone1 |         1 | sys         | 127.0.0.1 |     2882 |                     |                     0 |       5 |     2.5 | 9019431321 | 7516192768 |    10000 |     5000 |  304254812160 | 9223372036854775807 |
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
1 row in set (0.009 sec)

创建资源&租户

obclient [oceanbase]> CREATE resource unit mysql_unit max_cpu=4, min_cpu=4, max_memory='16G', min_memory='16G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='400G';
Query OK, 0 rows affected (0.010 sec)

obclient [oceanbase]> CREATE resource pool my_pool unit = 'mysql_unit', unit_num = 1;
Query OK, 0 rows affected (0.018 sec)

obclient [oceanbase]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='zone1',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (1.025 sec)

创建业务数据库&表

[root@competet-oecanbase ~]# obclient -h127.0.0.1 -P2883 -uroot@obmysql
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487720
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

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

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

obclient [(none)]> create database db02;
Query OK, 1 row affected (0.023 sec)

obclient [(none)]> use db02;
Database changed
obclient [db02]> CREATE TABLE course (
    -> cno varchar(5) NOT NULL,
    -> cname varchar(50) NOT NULL,
    -> tno char(3) NOT NULL,
    -> PRIMARY KEY (cno)
    -> );
Query OK, 0 rows affected (0.112 sec)

obclient [db02]> INSERT INTO course VALUES ('3001','C语言实践','801');
S ('3005','离散数学','805');
INSERT INTO course VALUES ('3006','大学英语','806');
INSERT INTO course VALUES ('3007','线性代数','807');Query OK, 1 row affected (0.010 sec)

obclient [db02]> INSERT INTO course VALUES ('3002','高等数学','802');
Query OK, 1 row affected (0.002 sec)

obclient [db02]> INSERT INTO course VALUES ('3003','数学分析','803');
Query OK, 1 row affected (0.002 sec)

obclient [db02]> INSERT INTO course VALUES ('3004','数据库原理','804');
Query OK, 1 row affected (0.001 sec)

obclient [db02]> INSERT INTO course VALUES ('3005','离散数学','805');
Query OK, 1 row affected (0.001 sec)

obclient [db02]> INSERT INTO course VALUES ('3006','大学英语','806');
Query OK, 1 row affected (0.002 sec)

obclient [db02]> INSERT INTO course VALUES ('3007','线性代数','807');
Query OK, 1 row affected (0.002 sec)

obclient [db02]> select * from course;
+------+-----------------+-----+
| cno  | cname           | tno |
+------+-----------------+-----+
| 3001 | C语言实践       | 801 |
| 3002 | 高等数学        | 802 |
| 3003 | 数学分析        | 803 |
| 3004 | 数据库原理      | 804 |
| 3005 | 离散数学        | 805 |
| 3006 | 大学英语        | 806 |
| 3007 | 线性代数        | 807 |
+------+-----------------+-----+
7 rows in set (0.003 sec)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值