上篇(7 巨杉資料庫SequoiaDB手動創建集群)介紹了如何手動創建集群,下面將在上篇的基礎上將介紹如何手工創建MySQL實體,
1 部署架構
本實驗Sequoia DB巨杉資料庫集群拓撲結構為單副本三磁區,包括1個SequoiaSQL-MySQL資料庫實體節點、1個存盤引擎節點、1個編目節點和3個資料節點,

2 手工創建MySQL實體
2.1 安裝SequoiaSQL-MySQL實體
[root@sdbserver1 sequoiadb-3.4]# ./sequoiasql-mysql-3.4-linux_x86_64-installer.run --mode text
Language Selection
Please select the installation language
[1] English - English
[2] Simplified Chinese - 簡體中文
Please choose an option [1] : 2
----------------------------------------------------------------------------
由BitRock InstallBuilder評估本所建立
歡迎來到 SequoiaSQL MySQL Server 安裝程式
----------------------------------------------------------------------------
GNU 通用公共授權
第二版, 1991年6月
著作權所有 (C) 1989,1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
允許每個人復制和發布本授權檔案的完整副本,但不允許對它進行任何修改,
[1] 同意以上協議: 了解更多的協議內容,可以在安裝后查看協議檔案
[2] 查看詳細的協議內容
請選擇一個選項 [1] :
----------------------------------------------------------------------------
請指定 SequoiaSQL MySQL Server 將會被安裝到的目錄
安裝目錄 [/opt/sequoiasql/mysql]:
----------------------------------------------------------------------------
資料庫管理用戶配置
配置用于啟動SequoiaSQL-MySql的用戶名、用戶組和密碼
用戶名 [sdbadmin]:
用戶組 [sdbadmin_group]:
密碼 [********] :
確認密碼 [********] :
----------------------------------------------------------------------------
設定現在已經準備將 SequoiaSQL MySQL Server 安裝到您的電腦.
您確定要繼續? [Y/n]:
----------------------------------------------------------------------------
正在安裝 SequoiaSQL MySQL Server 于您的電腦中,請稍候.
安裝中
0% ______________ 50% ______________ 100%
#########################################
----------------------------------------------------------------------------
安裝程式已經完成安裝 SequoiaSQL MySQL Server 于你的電腦中.
2.2 創建MySQL實體
1)切換至sdbadmin用戶
[root@sdbserver1 sequoiadb-3.4]# su - sdbadmin
2)創建myinst實體
[sdbadmin@sdbserver1 ~]$ cd /opt/sequoiasql/mysql/
[sdbadmin@sdbserver1 mysql]$ bin/sdb_sql_ctl addinst myinst -D database/3306
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Adding instance myinst ...
Start instance myinst ...
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
ok
3)查看實體
[sdbadmin@sdbserver1 mysql]$ bin/sdb_sql_ctl status
INSTANCE PID SVCNAME SQLDATA SQLLOG
myinst 4461 3306 /opt/sequoiasql/mysql/database/3306 /opt/sequoiasql/mysql/myinst.log
Total: 1; Run: 1
[sdbadmin@sdbserver1 mysql]$ bin/sdb_sql_ctl listinst
NAME SQLDATA SQLLOG
myinst /opt/sequoiasql/mysql/database/3306 /opt/sequoiasql/mysql/myinst.log
Total: 1
4)查看組態檔
[sdbadmin@sdbserver1 mysql]$ cat database/3306/auto.cnf
[auto]
server-uuid=99a4fc85-742b-11ea-8874-080027f936eb
[client]
default_character_set=utf8mb4
[mysqld]
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
character_set_server=utf8mb4
collation_server=utf8mb4_bin
default_storage_engine=SequoiaDB
# Overhead threshold of table alteration. When count of records exceeds it, the alteration that needs to update the full table will be prohibited.
# sequoiadb_alter_table_overhead_threshold=10000000
# Automatically create partition table on SequoiaDB.
# sequoiadb_auto_partition=ON
# Maximum number of records per bulk insert.
# sequoiadb_bulk_insert_size=2000
# SequoiaDB addresses.
# sequoiadb_conn_addr=localhost:11810
# Turn on debug log of SequoiaDB storage engine.
# sequoiadb_debug_log=OFF
# Sequoiadb error level for updating sharding key error.
# sequoiadb_error_level=error
# Commands execute only in mysql.
# sequoiadb_execute_only_in_mysql=OFF
# Optimizer_options[=option[,option...]], where option can be 'direct_count', 'direct_delete', 'direct_update'.direct_count: use count() instead of reading records one by one for count queries. direct_delete: direct delete without reading records.direct_update: direct update without reading records.
# sequoiadb_optimizer_options=direct_count,direct_delete,direct_update
# SequoiaDB authentication password.
# sequoiadb_password=
# Replica size of write operations.
# sequoiadb_replica_size=1
# The threshold of selector push down to SequoiaDB.
# sequoiadb_selector_pushdown_threshold=30
# Enable autocommit of SequoiaDB storage engine.
# sequoiadb_use_autocommit=ON
# Enable bulk insert to SequoiaDB.
# sequoiadb_use_bulk_insert=ON
# Enable transaction of SequoiaDB.
# sequoiadb_use_transaction=ON
# SequoiaDB authentication user.
# sequoiadb_user=
port=3306
basedir=/opt/sequoiasql/mysql
datadir=/opt/sequoiasql/mysql/database/3306
pid-file=/opt/sequoiasql/mysql/database/3306/mysqld.pid
log_error=/opt/sequoiasql/mysql/myinst.log
socket=/opt/sequoiasql/mysql/database/3306/mysqld.sock
3 驗證MySQL實體
3.1 連接MySQL實體
[sdbadmin@sdbserver1 mysql]$ bin/mysql -h 127.0.0.1 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25 Source distribution
Copyright (c) 2000, 2019, 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>
3.2 創建資料庫和表
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql> use test;
Database changed
mysql> create table emp(empno int auto_increment primary key,ename varchar(200),age int);
Query OK, 0 rows affected (0.87 sec)
3.3 資料操作
1)查看表結構
mysql> show create table emp\G;
*************************** 1. row ***************************
Table: emp
Create Table: CREATE TABLE `emp` (
`empno` int(11) NOT NULL AUTO_INCREMENT,
`ename` varchar(200) COLLATE utf8mb4_bin DEFAULT NULL,
`age` int(11) DEFAULT NULL,
PRIMARY KEY (`empno`)
) ENGINE=SEQUOIADB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.01 sec)
ERROR:
No query specified
由此可見,創建的表默認為SEQUOIADB存盤引擎,
2)插入資料
mysql> insert into emp(ename,age) values('Alen',23),('Lucy',25),('Tom',30);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
3)查看資料
mysql> select * from emp;
+-------+-------+------+
| empno | ename | age |
+-------+-------+------+
| 1 | Alen | 23 |
| 2 | Lucy | 25 |
| 3 | Tom | 30 |
+-------+-------+------+
3 rows in set (0.00 sec)
3.4 存盤引擎層操作資料
1)連接SDB和查看資料
[sdbadmin@sdbserver1 mysql]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> var db=new Sdb('localhost',11810)
Takes 0.005398s.
> db.test.emp.find()
{
"_id": {
"$oid": "5e84b1d4354e2e0d13d357e6"
},
"ename": "Alen",
"age": 23,
"empno": 1
}
{
"_id": {
"$oid": "5e84b1d4354e2e0d13d357e7"
},
"ename": "Lucy",
"age": 25,
"empno": 2
}
{
"_id": {
"$oid": "5e84b1d4354e2e0d13d357e8"
},
"ename": "Tom",
"age": 30,
"empno": 3
}
Return 3 row(s).
Takes 0.012692s
2)插入資料
> db.test.emp.insert({empno:4,ename:'Jack',age:35})
{
"InsertedNum": 1,
"DuplicatedNum": 0
}
Takes 0.000798s.
直接在存盤引擎層操作的資料,會映射在資料庫實體層,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/19669.html
標籤:大數據
