其他分享
首页 > 其他分享> > 手动部署 OceanBase 单节点

手动部署 OceanBase 单节点

作者:互联网

一、测试环境

硬件环境:virtual box虚拟机,16G内存
操作系统:Kylin v10 SP2

PS:默认使用IPV6,需要进行调整,将ONBOOT=no 改成 yes

[root@10 ~]# svim /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
NAME=enp0s3
UUID=f3704d33-0f97-499a-aa51-9224d460f403
DEVICE=enp0s3
#ONBOOT=no
ONBOOT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
IPV6_ADDR_GEN_MODE=stable-privacy
[root@10 ~]# systemctl restart network
二、创建admin用户
[root@10 ob]# useradd admin
[root@10 ob]# passwd admin
New password: 
Retype new password: 

三、安装软件

  1. 下载软件包
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/ob-deploy-1.1.0-1.el8.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-3.1.0-3.el8.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/oceanbase-ce-libs-3.1.0-3.el8.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/obclient-2.0.0-2.el8.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/libobclient-2.0.0-2.el8.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/obproxy-3.1.0-1.el8.x86_64.rpm
  1. 安装软件包
yum install *.rpm
[root@10 ob]# yum install *.rpm
Kylin Linux Advanced Server 10 - Os                                                                                                                                             7.9 MB/s |  14 MB     00:01    
Kylin Linux Advanced Server 10 - Updates                                                                                                                                        1.1 MB/s | 4.1 MB     00:03    
Last metadata expiration check: 0:00:04 ago on Mon 31 Jan 2022 11:16:35 AM CST.
Dependencies resolved.
================================================================================================================================================================================================================
 Package                                                Architecture                                Version                                             Repository                                         Size
================================================================================================================================================================================================================
Installing:
 libobclient                                            x86_64                                      2.0.0-2.el8                                         @commandline                                      1.0 M
 ob-deploy                                              x86_64                                      1.1.0-1.el8                                         @commandline                                       13 M
 obclient                                               x86_64                                      2.0.0-2.el8                                         @commandline                                      190 M
 obproxy                                                x86_64                                      3.1.0-1.el8                                         @commandline                                      7.8 M
 oceanbase-ce                                           x86_64                                      3.1.0-3.el8                                         @commandline                                       45 M
 oceanbase-ce-libs                                      x86_64                                      3.1.0-3.el8                                         @commandline                                      486 k
Transaction Summary
================================================================================================================================================================================================================
Install  6 Packages
Total size: 257 M
Installed size: 1.0 G
Is this ok [y/N]: y
[admin@10 ~]$ pwd
/home/admin
[admin@10 ~]$ tree
.
├── obproxy-3.1.0
│   └── bin
│       ├── obproxy
│       └── obproxyd.sh
└── oceanbase
    ├── bin
    │   ├── import_time_zone_info.py
    │   └── observer
    ├── etc
    │   └── timezone_V1.log
    └── lib
        ├── libaio.so -> libaio.so.1.0.1
        ├── libaio.so.1 -> libaio.so.1.0.1
        ├── libaio.so.1.0.1
        ├── libmariadb.so -> libmariadb.so.3
        └── libmariadb.so.3
6 directories, 10 files

四、初始化目录

[admin@10 ~]$ sudo mkdir -p ~/oceanbase/store/obdemo  /data/obdemo/{sstable,etc3} /redo/obdemo/{clog,ilog,slog,etc2}
[admin@10 ~]$ for f in {clog,ilog,slog,etc2}; do ln -s /redo/obdemo/$f ~/oceanbase/store/obdemo/$f ; done
[admin@10 ~]$ for f in {sstable,etc3}; do ln -s /data/obdemo/$f ~/oceanbase/store/obdemo/$f; done
[admin@10 ~]$ tree
.
├── obproxy-3.1.0
│   └── bin
│       ├── obproxy
│       └── obproxyd.sh
└── oceanbase
    ├── bin
    │   ├── import_time_zone_info.py
    │   └── observer
    ├── etc
    │   └── timezone_V1.log
    ├── lib
    │   ├── libaio.so -> libaio.so.1.0.1
    │   ├── libaio.so.1 -> libaio.so.1.0.1
    │   ├── libaio.so.1.0.1
    │   ├── libmariadb.so -> libmariadb.so.3
    │   └── libmariadb.so.3
    └── store
        └── obdemo
            ├── clog -> /redo/obdemo/clog
            ├── etc2 -> /redo/obdemo/etc2
            ├── etc3 -> /data/obdemo/etc3
            ├── ilog -> /redo/obdemo/ilog
            ├── slog -> /redo/obdemo/slog
            └── sstable -> /data/obdemo/sstable
14 directories, 10 files

五、启动OBSERVER进程

  1. 设置环境
[admin@10 ~]$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile
[admin@10 ~]$ source  ~/.bash_profile
[admin@10 ~]$ env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=:/home/admin/oceanbase/lib
  1. 启动observer进程
[admin@10 bin]$ ./observer -h
./observer -h
observer [OPTIONS]
  -h,--help                print this help
  -V,--version             print the information of version
  -z,--zone ZONE           zone
  -p,--mysql_port PORT     mysql port
  -P,--rpc_port PORT       rpc port
  -N,--nodaemon            don't run in daemon
  -n,--appname APPNAME     application name
  -c,--cluster_id ID       cluster id
  -d,--data_dir DIR        OceanBase data directory
  -i,--devname DEV         net dev interface
  -o,--optstr OPTSTR       extra options string
  -r,--rs_list RS_LIST     root service list
  -l,--log_level LOG_LEVEL server log level
  -6,--ipv6 USE_IPV6   server use ipv6 address
  -m,--mode MODE server mode
  -f,--scn flashback_scn
[admin@10 oceanbase]$ bin/observer -i enp0s3 -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '10.0.2.15:2882:2881' -c 20220201 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=4G,memory_chunk_cache_size=128M,cpu_count=6,net_thread_count=2,datafile_size=10G,stack_size=1536K"
bin/observer -i enp0s3 -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 10.0.2.15:2882:2881 -c 20220201 -n obdemo -o memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=4G,memory_chunk_cache_size=128M,cpu_count=6,net_thread_count=2,datafile_size=10G,stack_size=1536K
devname: enp0s3
mysql port: 2881
rpc port: 2882
zone: zone1
data_dir: /home/admin/oceanbase/store/obdemo
rs list: 10.0.2.15:2882:2881
cluster id: 20220201
appname: obdemo
optstr: memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=4G,memory_chunk_cache_size=128M,cpu_count=6,net_thread_count=2,datafile_size=10G,stack_size=1536K
  1. 集群自举(初始化)
[admin@10 log]$ mysql -h10.0.2.15 -P2881 -uroot -c -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221225473
Server version: 5.7.25 OceanBase 3.1.0 (r3-b20901e8c84d3ea774beeaca963c67d7802e4b4e) (Built Aug 10 2021 08:10:38)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '10.0.2.15:2882' ;
Query OK, 0 rows affected (0.001 sec)
Query OK, 0 rows affected (25.337 sec)
MySQL [(none)]> exit
Bye
[admin@10 log]$ mysql -h10.0.2.15 -P2881 -uroot@sys -c -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221487640
Server version: 5.7.25 OceanBase 3.1.0 (r3-b20901e8c84d3ea774beeaca963c67d7802e4b4e) (Built Aug 10 2021 08:10:38)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.003 sec)
MySQL [(none)]> alter user root identified by '123456';
Query OK, 0 rows affected (0.074 sec)
MySQL [(none)]> grant select on oceanbase.* to proxyro identified by '123456';
Query OK, 0 rows affected (0.096 sec)
MySQL [(none)]> \q
Bye

六、启动OBPROXY

  1. 启动
[admin@10 obproxy-3.1.0]$ bin/obproxy -r "10.0.2.15:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo
bin/obproxy -r 10.0.2.15:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo
rs list: 10.0.2.15:2881
listen port: 2883
optstr: enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false
cluster_name: obdemo
[admin@10 obproxy-3.1.0]$ bin/obproxy -r "10.0.2.15:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo
  1. 检查进程状态
[admin@10 obproxy-3.1.0]$ ps -ef | grep ob
admin      32197       1 99 22:12 ?        00:40:00 bin/observer -i enp0s3 -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 10.0.2.15:2882:2881 -c 20220201 -n obdemo -o memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=4G,memory_chunk_cache_size=128M,cpu_count=6,net_thread_count=2,datafile_size=10G,stack_size=1536K
admin      39089       1  4 22:29 ?        00:00:40 bin/obproxy -r 10.0.2.15:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo
root       44356    2715  0 22:43 ?        00:00:00 bash -c while true; do sleep 1;head -v -n 8 /proc/meminfo; head -v -n 2 /proc/stat /proc/version /proc/uptime /proc/loadavg /proc/sys/fs/file-nr /proc/sys/kernel/hostname; tail -v -n 16 /proc/net/dev;echo '==> /proc/df <==';df -l;echo '==> /proc/who <==';who;echo '==> /proc/end <==';echo '##Moba##'; done
admin      44761    3397  0 22:44 pts/3    00:00:00 grep ob
[admin@10 obproxy-3.1.0]$ netstat -antpl |grep ob
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:2881            0.0.0.0:*               LISTEN      32197/bin/observer
tcp        0      0 0.0.0.0:2882            0.0.0.0:*               LISTEN      32197/bin/observer
tcp        0      0 0.0.0.0:2883            0.0.0.0:*               LISTEN      39089/bin/obproxy
tcp        0      0 0.0.0.0:2884            0.0.0.0:*               LISTEN      39089/bin/obproxy
tcp        0      0 10.0.2.15:44440         10.0.2.15:2882          ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:44432         10.0.2.15:2882          ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:2882          10.0.2.15:44434         ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:44452         10.0.2.15:2882          ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:2882          10.0.2.15:44440         ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:2882          10.0.2.15:44432         ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:2882          10.0.2.15:44452         ESTABLISHED 32197/bin/observer
tcp        0      0 10.0.2.15:2883          10.0.2.15:38300         ESTABLISHED 39089/bin/obproxy
tcp        0      0 10.0.2.15:44434         10.0.2.15:2882          ESTABLISHED 32197/bin/observer
  1. 通过OBPROXY链接集群
admin@10 log]$ mysql -h10.0.2.15 -P2883 -uroot@proxysys -c -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------------+-------------------+
| Variable_name            | Value             |
+--------------------------+-------------------+
| tx_isolation             | READ-COMMITTED    |
| system_time_zone         | +08:00            |
| time_zone                | +08:00            |
| character_set_server     | utf8mb4           |
| character_set_client     | utf8mb4           |
| interactive_timeout      | 28800             |
| query_cache_size         | 1048576           |
| character_set_results    | utf8mb4           |
| max_allowed_packet       | 4194304           |
| sql_mode                 | STRICT_ALL_TABLES |
| net_buffer_length        | 16384             |
| wait_timeout             | 28800             |
| lower_case_table_names   | 2                 |
| query_cache_type         | OFF               |
| init_connect             |                   |
| transaction_isolation    | READ              |
| character_set_connection | utf8mb4           |
| net_write_timeout        | 60                |
+--------------------------+-------------------+
18 rows in set (0.001 sec)
MySQL [(none)]> \q
Bye
[admin@10 log]$ mysql -h10.0.2.15 -P2883 -uroot@proxysys -c -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.25
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show proxyconfig like '%sys_password%';
+-----------------------+-------+--------------------------------+-------------+---------------+
| name                  | value | info                           | need_reboot | visible_level |
+-----------------------+-------+--------------------------------+-------------+---------------+
| observer_sys_password |       | password for observer sys user | false       | SYS           |
| obproxy_sys_password  |       | password for obproxy sys user  | false       | SYS           |
+-----------------------+-------+--------------------------------+-------------+---------------+
2 rows in set (0.001 sec)
  1. 验证部署
[admin@10 log]$ mysql -h10.0.2.15 -uroot@sys#obdemo -P2883 -p123456 -c -A oceanbase
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.6.25 OceanBase 3.1.0 (r3-b20901e8c84d3ea774beeaca963c67d7802e4b4e) (Built Aug 10 2021 08:10:38)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]> show processlist;
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+------+------+
| Id   | Tenant | User | Host            | db        | trans_count | svr_session_count | state             | tid  | pid  |
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+------+------+
|   10 | sys    | root | 10.0.2.15:35694 | oceanbase |           0 |                 1 | MCS_ACTIVE_READER | 7880 | 7880 |
+------+--------+------+-----------------+-----------+-------------+-------------------+-------------------+------+------+
1 row in set (0.002 sec)
MySQL [oceanbase]> show full processlist;
+------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+
| Id         | User    | Tenant | Host            | db        | Command | Time | State  | Info                  | Ip        | Port | Proxy_sessid |
+------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+
| 3221487744 | root    | sys    | 10.0.2.15:42434 | oceanbase | Query   |    0 | ACTIVE | show full processlist | 10.0.2.15 | 2881 |            6 |
| 3221487736 | proxyro | sys    | 10.0.2.15:42430 | oceanbase | Sleep   |   14 | SLEEP  | NULL                  | 10.0.2.15 | 2881 |            5 |
+------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+
2 rows in set (0.005 sec)

七、创建资源单元、资源池、租户

[admin@10 log]$ mysql -h10.0.2.15 -uroot@sys#obdemo -P2883 -p123456 -c -A oceanbase
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.6.25 OceanBase 3.1.0 (r3-b20901e8c84d3ea774beeaca963c67d7802e4b4e) (Built Aug 10 2021 08:10:38)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]> create resource unit ocp_unit min_cpu=1, max_cpu=1, min_memory=1073741824, max_memory=1073741824, max_iops=256, min_iops=128, max_disk_size=1000000000, max_session_num=64;
Query OK, 0 rows affected (0.011 sec)
MySQL [oceanbase]> create resource pool ocp_frank unit='ocp_unit', zone_list=('zone1'), unit_num=1;
Query OK, 0 rows affected (0.020 sec)
MySQL [oceanbase]> create tenant frank resource_pool_list = ('ocp_frank') set variables ob_compatibility_mode='mysql', ob_tcp_invited_nodes='%';
Query OK, 0 rows affected (2.104 sec)

八、创建用户

MySQL [oceanbase]>  create database obtest;
Query OK, 1 row affected (0.033 sec)
MySQL [oceanbase]> grant all privileges on *.* to 'ob_user'@'%' with grant option;
Query OK, 0 rows affected (0.060 sec)
MySQL [oceanbase]>  show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
| obtest             |
+--------------------+
8 rows in set (0.005 sec)

九、建表

MySQL [oceanbase]> use obtest;
Database changed
MySQL [obtest]> CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT, c3 INT, c4 INT,  INDEX k1(c2,c3));
Query OK, 0 rows affected (0.311 sec)
MySQL [obtest]> CREATE TABLE t2(c1 INT, c2 INT);
Query OK, 0 rows affected (0.122 sec)
MySQL [obtest]> INSERT INTO t2 VALUES(1, 1);
Query OK, 1 row affected (0.018 sec)
MySQL [obtest]> INSERT INTO t2 VALUES(3, 3);
Query OK, 1 row affected (0.004 sec)
MySQL [obtest]> INSERT INTO t2 VALUES(5, 5);
Query OK, 1 row affected (0.004 sec)
MySQL [obtest]> show tables;
+------------------+
| Tables_in_obtest |
+------------------+
| t1               |
| t2               |
+------------------+
2 rows in set (0.002 sec)
MySQL [obtest]> select * from t2;
+------+------+
| c1   | c2   |
+------+------+
|    1 |    1 |
|    3 |    3 |
|    5 |    5 |
+------+------+
3 rows in set (0.002 sec)

十、问题

由于硬件条件限制,在启动observer的时候多次失败,不断调解资源,过程中查看observer.log并没有看到有效信息。经过反复调低资源配置后方可正常启动。

十一、总结

最近上手了一些分布式数据库和其他产品相比,OB要想单机玩起来还是需要注意一些资源的问题,且排查问题的时候比太好定位资源问题,后续还需不断积累和总结。
由于资源限制,后续再补充多节点ob集群的实践。

标签:10,admin,OceanBase,手动,obdemo,oceanbase,sec,MySQL,节点
来源: https://blog.csdn.net/xk_xx/article/details/122763419