
大数据模型
作者介绍
01.
单节点安装 MySQL 8.0 与单节点安装 OceanBase 4.0 的安装操作步骤 MySQL 8.0 与 OceanBase 4.0 的整体认识 MySQL 8.0 与 OceanBase 4.0 的性能影响关键因素和重要参数
02.

03.
MySQL 8.0 RPM 安装
1. 下载一个8.0的rpm文件,约25KB wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm2. 安装rpm文件 yum -y install mysql80-community-release-el7-3.noarch.rpm3. 安装mysql服务,因为 yum -y install mysql-community-server --nogpgcheck4. 启动mysql服务,查看运行状态 systemctl start mysqld.servicesystemctl status mysqld.service5. 从当前数据库的日志文件中找出初始随机密码 grep "password" var/log/mysqld.log6. 初始随机密码登录mysql,并修改密码 [root@hdp2 ~]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.32 MySQL Community Server - GPLCopyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>将密码修改为自己的密码 将下面 Mypassword 换成你自己定的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mypassword';7. 建立应用访问的用户名和密码 mysql> create user henley identified by 'Mypassword';Query OK, 0 rows affected (0.02 sec)mysql> grant all privileges on *.* to 'henley'@'%';Query OK, 0 rows affected (0.04 sec)8. 查看MySQL的关键参数 show global status like '%innodb_buffer_pool%';show variables like '%Innodb_buffer%';show variables like '%conn%';show variables like '%log%';OceanBase 4.0 RPM 安装

wget https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/7/x86_64/oceanbase-all-in-one-4.0.0.0-100120230113164218.el7.x86_64.tar.gz?Expires=1679311481&OSSAccessKeyId=LTAI5tGVLeRRycCRGerZJMNC&Signature=eBZoWUq8bsRExzF4Zx8ZBkcbnIM%3D
[root@hdp2 ob_allinone]# du -sh oceanbase-all-in-one/*12K oceanbase-all-in-one/bin264K oceanbase-all-in-one/conf45M oceanbase-all-in-one/obclient85M oceanbase-all-in-one/obd4.0K oceanbase-all-in-one/README.md201M oceanbase-all-in-one/rpms4.0K oceanbase-all-in-one/VERSION
bin/install.sh
obd cluster playground -c oceanbase-ce,obproxy-ce,obagent,prometheus,grafana
+----------------------------+------+----------+--------+| url | user | password | status |+----------------------------+------+----------+--------+| http://192.168.XX.XX:9090 | | | active |+----------------------------+------+----------+--------++---------------------------------------------------------------------+| grafana |+----------------------------------------+-------+-----------+--------+| url | user | password | status |+----------------------------------------+-------+-----------+--------+| http://192.168.XX.XX:3000/d/oceanbase | admin | oceanbase | active |+----------------------------------------+-------+-----------+--------+demo running
[root@hdp2 oceanbase-all-in-one]# obclient -h127.0.0.1 -P2881 -urootWelcome to the OceanBase. Commands end with ; or \g.Your OceanBase connection id is 3221664483Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)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 [(none)]> use oceanbase;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed创建15个CPU,3G内存的资源单位unitfishobclient [oceanbase]> CREATE RESOURCE UNIT unitfish MAX_CPU 15, MEMORY_SIZE '3G', MAX_IOPS 1280,LOG_DISK_SIZE '10G', MIN_IOPS=1024;Query OK, 0 rows affected (0.015 sec)资源单位unitfish绑定资源池poolfishobclient [oceanbase]> CREATE RESOURCE POOL poolfish UNIT = 'unitfish', UNIT_NUM = 1,ZONE_LIST = ('zone1');Query OK, 0 rows affected (0.025 sec)资源池poolfish绑定租户tenantfishobclient [oceanbase]> create tenant tenantfish resource_pool_list=('poolfish'), charset=utf8mb4, replica_num=3, zone_list('zone1'), primary_zone=RANDOM, locality='F@zone1' set variables ob_compatibility_mode='mysql', ob_tcp_invited_nodes='%';Query OK, 0 rows affected (24.164 sec)obclient [oceanbase]> SELECT unit_config_id,name,max_cpu,min_cpu,memory_size/1024/1024/1024 FROM __all_unit_config;+----------------+-----------------+---------+---------+----------------------------+| unit_config_id | name | max_cpu | min_cpu | memory_size/1024/1024/1024 |+----------------+-----------------+---------+---------+----------------------------+| 1 | sys_unit_config | 1 | 1 | 2.000000000000 || 1015 | unitfish | 15 | 15 | 3.000000000000 |+----------------+-----------------+---------+---------+----------------------------+2 rows in set (0.003 sec)
[root@hdp2 oceanbase-all-in-one]# obclient -h192.168.30.221 -uroot@tenantfish -P2883 -c -A oceanbaseWelcome to the OceanBase. Commands end with ; or \g.Your OceanBase connection id is 13Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)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]> create user henley identified by 'P@ssw0rd';Query OK, 0 rows affected (0.111 sec)obclient [oceanbase]> grant all privileges on *.* to 'henley'@'%';Query OK, 0 rows affected (0.045 sec)
安装总结
04.
基本性能
// private static final String JDBC_CLASS_NAME = “com.mysql.cj.jdbc.Driver”;// private static final String JDBC_URL = “jdbc:mysql://xxxx:3306/fish?useUnicode=true” +// “&characterEncoding=UTF-8&useSSL=false&rewriteBatchedStatements=true” +// “&allowPublicKeyRetrieval=true”;// private static final String JDBC_USER = “henley”;// private static final String JDBC_PWD = “xxxx”;// private static final String JDBC_CLASS_NAME = “com.mysql.jdbc.Driver”;// private static final String JDBC_URL = “jdbc:mysql://xxxx:2881/fish?useServerPrepStmts=true” +// “&rewriteBatchedStatements=true” +// “&allowMultiQueries=true” +// “&useSSL=false”;// private static final String JDBC_USER = “henley@tenantfish”;// private static final String JDBC_PWD = “xxxx”;




索引功能
mysql> explain SELECT * FROM tb_order where warehouse_number = 'whs_0000000075';+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+| 1 | SIMPLE | tb_order | NULL | ALL | NULL | NULL | NULL | NULL | 994284 | 10.00 | Using where |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+1 row in set, 1 warning (0.00 sec)
2. MySQL 建立索引
mysql> CREATE INDEX `tb_order_idx02` ON fish.`tb_order` (`warehouse_number`, `product_number`);Query OK, 0 rows affected (18.98 sec)Records: 0 Duplicates: 0 Warnings: 0
mysql> explain SELECT * FROM tb_order where warehouse_number = 'whs_0000000075';+----+-------------+----------+------------+------+----------------+----------------+---------+-------+-------+----------+-------+| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+----------+------------+------+----------------+----------------+---------+-------+-------+----------+-------+| 1 | SIMPLE | tb_order | NULL | ref | tb_order_idx02 | tb_order_idx02 | 82 | const | 19526 | 100.00 | NULL |+----+-------------+----------+------------+------+----------------+----------------+---------+-------+-------+----------+-------+1 row in set, 1 warning (0.00 sec)
obclient [fish]> explain SELECT * FROM tb_order where warehouse_number = 'whs_0000000075';|ID|OPERATOR |NAME |EST. ROWS|COST |------------------------------------------------------|0 |PX COORDINATOR | |10000 |106628||1 | EXCHANGE OUT DISTR |:EX10000|10000 |93272 ||2 | PX PARTITION ITERATOR| |10000 |63232 ||3 | TABLE SCAN |tb_order|10000 |63232 |======================================================Outputs & filters:-------------------------------------0 - output([INTERNAL_FUNCTION(tb_order.id, tb_order.ord_number, tb_order.custom_number, tb_order.product_number, tb_order.warehouse_number, tb_order.ord_status, tb_order.order_time)]), filter(nil), rowset=2561 - output([INTERNAL_FUNCTION(tb_order.id, tb_order.ord_number, tb_order.custom_number, tb_order.product_number, tb_order.warehouse_number, tb_order.ord_status, tb_order.order_time)]), filter(nil), rowset=256, dop=12 - output([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), filter(nil), rowset=2563 - output([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), filter([tb_order.warehouse_number = 'whs_0000000075']), rowset=256,access([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), partitions(p[0-7])
5. OceanBase 建立索引
obclient [fish]> CREATE INDEX `tb_order_idx02` ON fish.`tb_order` (`warehouse_number`, `product_number`);Query OK, 0 rows affected (44.654 sec)
6. OceanBase 建立索引后
obclient [fish]> explain SELECT * FROM tb_order where warehouse_number = 'whs_0000000075';|ID|OPERATOR |NAME |EST. ROWS|COST |---------------------------------------------------------------------|0 |PX COORDINATOR | |10000 |86879||1 | EXCHANGE OUT DISTR |:EX10000 |10000 |73523||2 | PX PARTITION ITERATOR| |10000 |43482||3 | TABLE SCAN |tb_order(tb_order_idx02)|10000 |43482|=====================================================================Outputs & filters:-------------------------------------0 - output([INTERNAL_FUNCTION(tb_order.id, tb_order.ord_number, tb_order.custom_number, tb_order.product_number, tb_order.warehouse_number, tb_order.ord_status, tb_order.order_time)]), filter(nil), rowset=2561 - output([INTERNAL_FUNCTION(tb_order.id, tb_order.ord_number, tb_order.custom_number, tb_order.product_number, tb_order.warehouse_number, tb_order.ord_status, tb_order.order_time)]), filter(nil), rowset=256, dop=12 - output([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), filter(nil), rowset=2563 - output([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), filter(nil), rowset=256,access([tb_order.id], [tb_order.warehouse_number], [tb_order.ord_number], [tb_order.custom_number], [tb_order.product_number], [tb_order.ord_status], [tb_order.order_time]), partitions(p[0-7])
倒序索引
SELECT custom_number, product_number from tb_order order by custom_number, product_number DESC ;
CREATE INDEX `tb_order_idx01` ON fish.`tb_order` (`custom_number`, `product_number` DESC);
CREATE INDEX `tb_order_idx01` ON fish.`tb_order` (`custom_number`, `product_number` );
测试总结
05.
今天分享到这里就结束了,关于本期内容,如果大家有什么想交流的,欢迎评论区留言探讨~
文章转载自OceanBase数据库星球,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。






