您当前的位置: 首页 > 

实践练习二(必选):手动部署 OceanBase 单副本集群

发布时间:2022-01-08 18:22:27 ,浏览量:0

说明

相关连接:

https://open.oceanbase.com/blog/10900159

https://open.oceanbase.com/answer/detail?id=13700696

练习目的

本次练习目的掌握 OceanBase 集群的手动部署技能,理解进程的相关目录、集群初始化、OBProxy和 OB 集群关系等。

练习条件

有笔记本或服务器,内存至少12G 。

练习内容

请记录并分享下列内容:

  1. (必选)手动部署一个 OB 单副本集群,包括一个 OBProxy 节点。
  2. (必选)创建一个业务租户、一个业务数据库,以及一些表等。
  3. (可选)如果单台服务器内存有32G,或者有三台服务器,改为部署一个 OB 三副本集群,包括一个 OBProxy 节点。
  4. (可选)如果有三台服务器并且服务器内存有 32 G,可以单服务器内启动 2 个节点,实现 1-1-1 扩容到 2-2-2 。
软件下载

下载地址:https://open.oceanbase.com/softwareCenter/community

从https://www.oceanbase.com/softwareCenter/community下载3个软件,分别是obproxy-3.2.0-1.el7.x86_64.rpm、oceanbase-ce-3.1.1-4.el7.x86_64.rpm、oceanbase-ce-libs-3.1.1-4.el7.x86_64.rpm。

wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*4VfBRbz_ncIAAAAAAAAAAAAADmF2AQ?af_fileName=oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*obcATbEfH_QAAAAAAAAAAAAADmF2AQ?af_fileName=oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm wget https://mdn.alipayobjects.com/ob_portal/afts/file/A*mMziSJneiZcAAAAAAAAAAAAADmF2AQ?af_fileName=obproxy-3.2.0-1.el7.x86_64.rpm 
手动部署一个 OB 单副本集群 环境准备
docker rm -f lhrob312
docker run -d --name lhrob312 -h lhrob312 \ -p 12881-12889:2881-2889 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/lhrcentos76:8.5 \ /usr/sbin/init

docker exec -it lhrob312 bash -- 创建用户 useradd admin
echo "admin:lhr" | chpasswd



echo "admin       ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers -- 安装OB软件 rpm -ivh *.rpm

echo "export PATH=$PATH:/home/admin/oceanbase/bin:/home/admin/obproxy-3.2.0/bin" >> /home/admin/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/" >> /home/admin/.bash_profile
source /home/admin/.bash_profile


chown -R admin:admin /home/admin -- 安装OB和MySQL客户端 yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo yum install -y obclient mariadb mariadb-libs mariadb-devel

安装过程:

[root@lhrob312 soft]# ll -h total 55M -rw-r--r-- 1 root root 7.9M Nov  5 09:10 obproxy-3.2.0-1.el7.x86_64.rpm -rw-r--r-- 1 root root  47M Dec 31 17:57 oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm -rw-r--r-- 1 root root 156K Dec 31 19:40 oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm [root@lhrob312 soft]# useradd admin [root@lhrob312 soft]# echo "admin:lhr" | chpasswd [root@lhrob312 soft]#  [root@lhrob312 soft]# chown -R admin:admin /home/admin [root@lhrob312 soft]# echo "admin       ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers [root@lhrob312 soft]#  [root@lhrob312 soft]#  [root@lhrob312 soft]# rpm -ivh *.rpm warning: obproxy-3.2.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Preparing... ################################# [100%] Updating / installing... 1:oceanbase-ce-libs-3.1.2-100003920################################# [ 33%] 2:oceanbase-ce-3.1.2-10000392021123################################# [ 67%] 3:obproxy-3.2.0-1.el7 ################################# [100%] [root@lhrob312 soft]# echo "export PATH=$PATH:/home/admin/oceanbase/bin:/home/admin/obproxy-3.2.0/bin" >> /home/admin/.bash_profile [root@lhrob312 soft]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/oceanbase/lib/" >> /home/admin/.bash_profile [root@lhrob312 soft]# source  /home/admin/.bash_profile [root@lhrob312 soft]#  [root@lhrob312 soft]# rpm -ql oceanbase-ce /home/admin/oceanbase/bin /home/admin/oceanbase/bin/import_time_zone_info.py /home/admin/oceanbase/bin/observer /home/admin/oceanbase/etc /home/admin/oceanbase/etc/oceanbase_upgrade_dep.yml /home/admin/oceanbase/etc/priv_checker.py /home/admin/oceanbase/etc/timezone_V1.log /home/admin/oceanbase/etc/upgrade_checker.py /home/admin/oceanbase/etc/upgrade_cluster_health_checker.py /home/admin/oceanbase/etc/upgrade_post.py /home/admin/oceanbase/etc/upgrade_post_checker.py /home/admin/oceanbase/etc/upgrade_pre.py /home/admin/oceanbase/etc/upgrade_rolling_post.py /home/admin/oceanbase/etc/upgrade_rolling_pre.py [root@lhrob312 soft]# rpm -ql oceanbase-ce-libs /home/admin/oceanbase/lib /home/admin/oceanbase/lib/libaio.so /home/admin/oceanbase/lib/libaio.so.1 /home/admin/oceanbase/lib/libaio.so.1.0.1 /home/admin/oceanbase/lib/libmariadb.so /home/admin/oceanbase/lib/libmariadb.so.3 [root@lhrob312 soft]# rpm -ql obproxy /home/admin/obproxy-3.2.0/bin /home/admin/obproxy-3.2.0/bin/obproxy /home/admin/obproxy-3.2.0/bin/obproxyd.sh [root@lhrob312 ~]# chown -R admin:admin /home/admin 
配置启动OB并初始化
-- 单副本 su - admin
mkdir -p /home/admin/oceanbase/store/sstable
cd /home/admin/oceanbase/store/ && /home/admin/oceanbase/bin/observer -r "127.0.0.1:2882:2881" -o "__min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4" -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR #以上命令中指定的参数作用可参考obd自动部署过程yaml文件的说明,请移步 https://gitee.com/oceanbase/obdeploy/tree/master/example  # 查看进程信息 ps -ef |grep observer 
netstat -tulnp | grep 288 -- bootstrap集群(初始化集群) mysql -h127.1 -uroot -P2881 -p -c -A # 默认空密码 set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '127.0.0.1:2882'; # 修改root密码 alter user root identified by 'lhr'; create user proxyro identified by 'lhr'; grant select on *.* to proxyro; 

过程:

[admin@lhrob312 oceanbase]$ mkdir -p /home/admin/oceanbase/store/sstable [admin@lhrob312 oceanbase]$ ll /home/admin/oceanbase/store/sstable      
total 0 [admin@lhrob312 oceanbase]$ [admin@lhrob312 oceanbase]$ [admin@lhrob312 oceanbase]$ /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o "__min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4" -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR
rs list: 127.0.0.1:2882:2881 optstr: __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 zone: zone1
mysql port: 2881 rpc port: 2882 appname: lhrob-single
cluster id: 20220108 data_dir: /home/admin/oceanbase/store
devname: lo
log level: ERROR [admin@lhrob312 oceanbase]$ ll
total 24 drwxr-xr-x 2 admin admin 4096 Jan 8 11:34 bin
drwxr-xr-x 2 admin admin 4096 Jan 8 11:34 etc
drwxr-xr-x 2 admin admin 4096 Jan 8 11:33 lib
drwxrwxr-x 2 admin admin 4096 Jan 8 14:51 log
drwxrwxr-x 2 admin admin 4096 Jan 8 14:51 run
drwxrwxr-x 6 admin admin 4096 Jan 8 14:51 store [admin@lhrob312 oceanbase]$ tree store/ store/ ├── clog
│   └── 1 ├── ilog
├── slog
└── sstable
    └── block_file 4 directories, 2 files [admin@lhrob312 oceanbase]$ ps -ef|grep ob
admin 17740 0 99 14:51 ? 00:00:35 /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR
admin 18337 15142 0 14:51 pts/0 00:00:00 grep --color=auto ob [admin@lhrob312 oceanbase]$ cd [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ netstat -tulnp | grep 288 (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 2516/observer       
tcp 0 0 0.0.0.0:2882 0.0.0.0:* LISTEN 2516/observer [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ [admin@lhrob312 ~]$ mysql -h127.1 -uroot -P2881 -p -c -A
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221225472 Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29) 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 '127.0.0.1:2882'; Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (3 min 30.85 sec) MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.10 sec) MySQL [(none)]> alter user root identified by 'lhr'; grant select on *.* to proxyro;Query OK, 0 rows affected (0.88 sec) MySQL [(none)]> create user proxyro identified by 'lhr'; Query OK, 0 rows affected (0.48 sec) MySQL [(none)]> grant select on *.* to proxyro; Query OK, 0 rows affected (0.62 sec) 
配置obproxy

https://open.oceanbase.com/articles/1100243

obproxy跟OB集群通信是使用sys租户内的一个内部账户proxyro。这个账户需要创建。

obproxy启动后,默认用 root@proxysys 登录,密码为空。需要改密码(通过proxy参数obproxy_sys_password指定)。

obproxy启动后,还需要修改proxyro的密码(通过proxy参数observer_sys_password指定),设置为跟OB集群里创建的proxyro密码一致才能链接那个OB集群。

-- 启动obproxy,其中-c 对应集群的名称,和前面的observer的启动参数对应。 cd /home/admin/obproxy-3.2.0 && /home/admin/obproxy-3.2.0/bin/obproxy -r "127.0.0.1:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c 20220108 netstat -ntlp |grep obproxy -- 通过obproxy登录,初始密码为空 mysql -h127.1 -uroot@proxysys -P2883 -p alter proxyconfig set obproxy_sys_password='lhr'; alter proxyconfig set observer_sys_password='lhr'; show proxyconfig like '%sys_password%'; mysql -h127.1 -uroot@sys -P2883 -plhr -c -A oceanbase
mysql -uroot@sys -plhr -h192.168.66.35 -P12883 select * from oceanbase.__all_server; show full processlist; 

执行过程:

[admin@lhrob312 ~]$ /home/admin/obproxy-3.2.0/bin/obproxy -r "127.0.0.1:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c 20220108 /home/admin/obproxy-3.2.0/bin/obproxy -r 127.0.0.1:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c 20220108 rs list: 127.0.0.1:2881 listen port: 2883 optstr: enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false cluster_name: 20220108 [root@lhrob312 soft]# netstat -ntlp |grep obproxy tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 18870/obproxy       
tcp 0 0 0.0.0.0:2884 0.0.0.0:* LISTEN 18870/obproxy [root@lhrob312 soft]# ps -ef|grep ob admin 17740 0 99 14:51 ? 00:35:38 /home/admin/oceanbase/bin/observer -r 127.0.0.1:2882:2881 -o __min_full_resource_pool_memory=268435456,memory_limit=8G,system_memory=4G,stack_size=512K,cpu_count=16,cache_wash_threshold=1G,workers_per_cpu_quota=10,schema_history_expire_time=1d,net_thread_count=4,major_freeze_duty_time=Disable,minor_freeze_times=10,enable_separate_sys_clog=0,enable_merge_by_turn=False,datafile_size=5G,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4 -z zone1 -p 2881 -P 2882 -n lhrob-single -c 20220108 -d /home/admin/oceanbase/store -i lo -l ERROR
admin 18870 0 9 15:02 ? 00:00:20 /home/admin/obproxy-3.2.0/bin/obproxy -r 127.0.0.1:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c 20220108 root 19095 3413 0 15:05 pts/1 00:00:00 grep --color=auto ob [admin@lhrob312 ~]$ mysql -h127.1 -uroot@proxysys -P2883 -p
Enter password: 
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)]> MySQL [(none)]> show proxyconfig like '%sys_password%'; +------------------------+-------+--------------------------------+-------------+---------------+ | name | value | info | need_reboot | visible_level | +------------------------+-------+--------------------------------+-------------+---------------+ | observer_sys_password1 | | password for observer sys user | false | SYS | | observer_sys_password | | password for observer sys user | false | SYS | | obproxy_sys_password | | password for obproxy sys user | false | SYS | +------------------------+-------+--------------------------------+-------------+---------------+ 3 rows in set (0.00 sec) MySQL [(none)]> alter proxyconfig set obproxy_sys_password='lhr'; Query OK, 0 rows affected (0.01 sec) MySQL [(none)]> alter proxyconfig set observer_sys_password='lhr'; Query OK, 0 rows affected (0.03 sec) MySQL [(none)]> show proxyconfig like '%sys_password%'; +------------------------+------------------------------------------+--------------------------------+-------------+---------------+ | name | value | info | need_reboot | visible_level | +------------------------+------------------------------------------+--------------------------------+-------------+---------------+ | observer_sys_password1 | | password for observer sys user | false | SYS | | observer_sys_password | 6095142f4b755fb18e0ca1edc3fa38fe0bdc78b9 | password for observer sys user | false | SYS | | obproxy_sys_password | 6095142f4b755fb18e0ca1edc3fa38fe0bdc78b9 | password for obproxy sys user | false | SYS | +------------------------+------------------------------------------+--------------------------------+-------------+---------------+ 3 rows in set (0.01 sec) [admin@lhrob312 ~]$ mysql -h127.1 -uroot@sys -P2883 -plhr -c -A oceanbase
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29) 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]> MySQL [oceanbase]> select * from oceanbase.__all_server; +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ | gmt_create | gmt_modified | svr_ip | svr_port | id | zone | inner_port | with_rootserver | status | block_migrate_in_time | build_version | stop_time | start_service_time | first_sessid | with_partition | last_offline_time | +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ | 2022-01-08 14:52:34.064705 | 2022-01-08 15:00:26.771987 | 127.0.0.1 | 2882 | 1 | zone1 | 2881 | 1 | active | 0 | 3.1.2_10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d(Dec 30 2021 02:47:29) | 0 | 1641624917461162 | 0 | 1 | 0 | +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ 1 row in set (0.01 sec) MySQL [oceanbase]> show full processlist; +------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+ | Id | User | Tenant | Host | db | Command | Time | State | Info | Ip | Port | Proxy_sessid | +------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+ | 3221487783 | proxyro | sys | 127.0.0.1:42192 | oceanbase | Sleep | 0 | SLEEP | NULL | 127.0.0.1 | 2881 | 3 | | 3221487781 | root | sys | 127.0.0.1:42188 | oceanbase | Query | 0 | ACTIVE | show full processlist | 127.0.0.1 | 2881 | 2 | | 3221487792 | root | sys | 127.0.0.1:43042 | NULL | Sleep | 8 | SLEEP | NULL | 127.0.0.1 | 2881 | 4 | +------------+---------+--------+-----------------+-----------+---------+------+--------+-----------------------+-----------+------+--------------+ 3 rows in set (0.08 sec) MySQL [oceanbase]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.00 sec) 
登录ob数据库并创建租户
mysql -uroot@sys -plhr -h192.168.66.35 -P12883 CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G'; CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1; create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql'; -- 密码为空 mysql -uroot@obmysql -p -h192.168.66.35 -P12883

过程:

C:\Users\lhrxxt>mysql -uroot@sys -plhr -h192.168.66.35 -P12883
mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 262145 Server version: 5.6.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> select * from oceanbase.__all_server; +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ | gmt_create | gmt_modified | svr_ip | svr_port | id | zone | inner_port | with_rootserver | status | block_migrate_in_time | build_version | stop_time | start_service_time | first_sessid | with_partition | last_offline_time | +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ | 2022-01-08 14:52:34.064705 | 2022-01-08 15:00:26.771987 | 127.0.0.1 | 2882 | 1 | zone1 | 2881 | 1 | active | 0 | 3.1.2_10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d(Dec 30 2021 02:47:29) | 0 | 1641624917461162 | 0 | 1 | 0 | +----------------------------+----------------------------+-----------+----------+----+-------+------------+-----------------+--------+-----------------------+----------------------------------------------------------------------------------------+-----------+--------------------+--------------+----------------+-------------------+ 1 row in set (0.09 sec) 
创建资源单元、资源池、租户
MySQL [oceanbase]> CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G'; Query OK, 0 rows affected (0.006 sec) MySQL [oceanbase]> CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1; Query OK, 0 rows affected (0.011 sec) MySQL [oceanbase]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql'; Query OK, 0 rows affected (0.612 sec) MySQL [oceanbase]> 
登录obmysql tenant并创建数据库及表等
C:\Users\lhrxxt>mysql -uroot@obmysql -p -h192.168.66.35 -P12883
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.6.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [test]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | test | +--------------------+ 4 rows in set (0.017 sec) MySQL [test]> create database lhrdb charset utf8mb4; Query OK, 1 row affected (0.168 sec) MySQL [test]> use lhrdb; Database changed

MySQL [lhrdb]> source /tmp/mysql_employees.sql Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected, 1 warning (0.004 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.001 sec) ..... MySQL [lhrdb]> show tables; +-----------------+ | Tables_in_lhrdb | +-----------------+ | departments | | job_grades | | jobs | | late | | locations | +-----------------+ 5 rows in set (0.018 sec) MySQL [lhrdb]> select * from jobs; +------------+---------------------------------+------------+------------+ | job_id | job_title | min_salary | max_salary | +------------+---------------------------------+------------+------------+ | AC_ACCOUNT | Public Accountant | 4200 | 9000 | | AC_MGR | Accounting Manager | 8200 | 16000 | | AD_ASST | Administration Assistant | 3000 | 6000 | | AD_PRES | President | 20000 | 40000 | | AD_VP | Administration Vice President | 15000 | 30000 | | FI_ACCOUNT | Accountant | 4200 | 9000 | | FI_MGR | Finance Manager | 8200 | 16000 | | HR_REP | Human Resources Representative | 4000 | 9000 | | IT_PROG | Programmer | 4000 | 10000 | | MK_MAN | Marketing Manager | 9000 | 15000 | | MK_REP | Marketing Representative | 4000 | 9000 | | PR_REP | Public Relations Representative | 4500 | 10500 | | PU_CLERK | Purchasing Clerk | 2500 | 5500 | | PU_MAN | Purchasing Manager | 8000 | 15000 | | SA_MAN | Sales Manager | 10000 | 20000 | | SA_REP | Sales Representative | 6000 | 12000 | | SH_CLERK | Shipping Clerk | 2500 | 5500 | | ST_CLERK | Stock Clerk | 2000 | 5000 | | ST_MAN | Stock Manager | 5500 | 8500 | +------------+---------------------------------+------------+------------+ 19 rows in set (0.003 sec) 
问题

搞不懂,为啥OB的CPU占用率总是这么高:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uOeENNyQ-1641637320223)(https://cdn.jsdelivr.net/gh/lhrbest/pic/img_2022/202201081514701.png)]

本实验结束!

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    105695博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.4704s