mysql -h fe_host -P9030 -u root -p
mysql > drop database if exists example_db;mysql > drop user test;
mysql> SHOW PROC '/frontends'\\G************************* 1. row ************************Name: 172.16.139.24_9010_1594200991015IP: 172.16.139.24HostName: starrocks-sandbox01EditLogPort: 9010HttpPort: 8030QueryPort: 9030RpcPort: 9020Role: FOLLOWERIsMaster: trueClusterId: 861797858Join: trueAlive: trueReplayedJournalId: 64LastHeartbeat: 2020-03-23 20:15:07IsHelper: trueErrMsg:1 row in set (0.03 sec)
Role is FOLLOWER, indicating that the FE is eligible for master election. The value of IsMaster is true, indicating that the FE is the current master node.mysql> SHOW PROC '/backends'\\G********************* 1. row **********************BackendId: 10002Cluster: default_clusterIP: 172.16.139.24HostName: starrocks-sandbox01HeartbeatPort: 9050BePort: 9060HttpPort: 8040BrpcPort: 8060LastStartTime: 2020-03-23 20:19:07LastHeartbeat: 2020-03-23 20:34:49Alive: trueSystemDecommissioned: falseClusterDecommissioned: falseTabletNum: 0DataUsedCapacity: .000AvailCapacity: 327.292 GBTotalCapacity: 450.905 GBUsedPct: 27.41 %MaxDiskUsedPct: 27.41 %ErrMsg:Version:1 row in set (0.01 sec)
isAlive is true, the BE is connected to the cluster normally; if not, view the be.WARNING log file in the log directory to identify the cause.MySQL> SHOW PROC "/brokers"\\G*************************** 1. row ***************************Name: broker1IP: 172.16.139.24Port: 8000Alive: trueLastStartTime: 2020-04-01 19:08:35LastUpdateTime: 2020-04-01 19:08:45ErrMsg:1 row in set (0.00 sec)
Alive is true, the status is normal.mysql > create user 'test' identified by '123456';
example\\_db database:mysql > create database example_db;
show databases:mysql > show databases;+--------------------+| Database |+--------------------+| example_db || information_schema |+--------------------+2 rows in set (0.00 sec)
information_schema exists to be compatible with the MySQL protocol. In practice, information may not be accurate. Therefore, we recommend you get the information of a specific database by directly querying the database.example_db database, you can grant its read/write permissions to the test account through the root account and then log in with the test account to manipulate the database.mysql > grant all on example_db to test;
mysql > exitmysql -h 127.0.0.1 -P9030 -utest -p123456
KEY columns will be selected) and the number of buckets for HASH distribution of data.DELETE statement to the specified partition.mysql to use example_db.table1 by assigning ten hash buckets based on siteid, with the schema as shown below:siteid: The type is INT (4 bytes); the default value is 10.city_code: The type is SMALLINT (two bytes).username: The type is VARCHAR. The maximum length is 32. The default value is an empty string.pv: The type is BIGINT (eight bytes), and the default value is 0. It is a metric column and will be aggregated by StarRocks with the SUM method. The aggregation model is used here. In addition, StarRocks supports the detail model and update model. For more information, see Data Model.
The table creation statement is as follows:mysql >CREATE TABLE table1(siteid INT DEFAULT '10',citycode SMALLINT,username VARCHAR(32) DEFAULT '',pv BIGINT SUM DEFAULT '0')AGGREGATE KEY(siteid, citycode, username)DISTRIBUTED BY HASH(siteid) BUCKETS 10PROPERTIES("replication_num" = "1");
table2 with the schema as shown below:event_day: The type is DATE; no default value.siteid: The type is INT (4 bytes); the default value is 10.city_code: The type is SMALLINT (two bytes).username: The type is VARCHAR. The maximum length is 32. The default value is an empty string.pv: The type is BIGINT (eight bytes), and the default value is 0. It is a metric column and will be aggregated by StarRocks with the SUM method.
Use the event_day column as the partitioning column to create three partitions: p1, p2, and p3.siteid to assign ten hash buckets to each partition.
The table creation statement is as follows:CREATE TABLE table2(event_day DATE,siteid INT DEFAULT '10',citycode SMALLINT,username VARCHAR(32) DEFAULT '',pv BIGINT SUM DEFAULT '0')AGGREGATE KEY(event_day, siteid, citycode, username)PARTITION BY RANGE(event_day)(PARTITION p1 VALUES LESS THAN ('2017-06-30'),PARTITION p2 VALUES LESS THAN ('2017-07-31'),PARTITION p3 VALUES LESS THAN ('2017-08-31'))DISTRIBUTED BY HASH(siteid) BUCKETS 10PROPERTIES("replication_num" = "1");
example\\_db:mysql> show tables;+-------------------------+| Tables_in_example_db |+-------------------------+| table1 || table2 |+-------------------------+2 rows in set (0.01 sec)mysql> desc table1;+----------+-------------+------+-------+---------+-------+| Field | Type | Null | Key | Default | Extra |+----------+-------------+------+-------+---------+-------+| siteid | int(11) | Yes | true | 10 | || citycode | smallint(6) | Yes | true | N/A | || username | varchar(32) | Yes | true | | || pv | bigint(20) | Yes | false | 0 | SUM |+----------+-------------+------+-------+---------+-------+4 rows in set (0.00 sec)mysql> desc table2;+-----------+-------------+------+-------+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------+-------------+------+-------+---------+-------+| event_day | date | Yes | true | N/A | || siteid | int(11) | Yes | true | 10 | || citycode | smallint(6) | Yes | true | N/A | || username | varchar(32) | Yes | true | | || pv | bigint(20) | Yes | false | 0 | SUM |+-----------+-------------+------+-------+---------+-------+5 rows in set (0.00 sec)
Feedback