Apache Presto 简明教程
Apache Presto - Configuration Settings
本章将讨论 Presto 的配置设置。
This chapter will discuss the configuration settings for Presto.
Presto Verifier
Presto Verifier 可用于将 Presto 与另一个数据库(如 MySQL)进行测试,或将两个 Presto 集群彼此进行测试。
The Presto Verifier can be used to test Presto against another database (such as MySQL), or to test two Presto clusters against each other.
Create Database in MySQL
打开 MySQL 服务器并使用以下命令创建一个数据库。
Open MySQL server and create a database using the following command.
create database test
现在你在服务器中创建了“test”数据库。创建表并使用以下查询加载它。
Now you have created “test” database in the server. Create the table and load it with the following query.
CREATE TABLE verifier_queries(
id INT NOT NULL AUTO_INCREMENT,
suite VARCHAR(256) NOT NULL,
name VARCHAR(256),
test_catalog VARCHAR(256) NOT NULL,
test_schema VARCHAR(256) NOT NULL,
test_prequeries TEXT,
test_query TEXT NOT NULL,
test_postqueries TEXT,
test_username VARCHAR(256) NOT NULL default 'verifier-test',
test_password VARCHAR(256),
control_catalog VARCHAR(256) NOT NULL,
control_schema VARCHAR(256) NOT NULL,
control_prequeries TEXT,
control_query TEXT NOT NULL,
control_postqueries TEXT,
control_username VARCHAR(256) NOT NULL default 'verifier-test',
control_password VARCHAR(256),
session_properties_json TEXT,
PRIMARY KEY (id)
);
Add Config Settings
创建一个属性文件以配置验证器-
Create a properties file to configure the verifier −
$ vi config.properties
suite = mysuite
query-database = jdbc:mysql://localhost:3306/tutorials?user=root&password=pwd
control.gateway = jdbc:presto://localhost:8080
test.gateway = jdbc:presto://localhost:8080
thread-count = 1
这里,在 query-database 字段中,输入以下内容:mysql 数据库名称、用户名和密码。
Here, in the query-database field, enter the following details − mysql database name, user name, and password.
Download JAR File
通过访问以下链接下载 Presto 验证器 jar 文件,
Download Presto-verifier jar file by visiting the following link,
现在已在你的机器上下载版本 “presto-verifier-0.149-executable.jar” 。
Now the version “presto-verifier-0.149-executable.jar” is downloaded on your machine.
Execute JAR
使用以下命令执行 JAR 文件,
Execute the JAR file using the following command,
$ mv presto-verifier-0.149-executable.jar verifier
$ chmod+x verifier
Run Verifier
使用以下命令运行验证器,
Run the verifier using the following command,
$ ./verifier config.properties
Create Table
我们使用以下查询在 “test” 数据库中创建一个简单表。
Let’s create a simple table in “test” database using the following query.
create table product(id int not null, name varchar(50))
Insert Table
创建表后,使用以下查询插入两条记录,
After creating a table, insert two records using the following query,
insert into product values(1,’Phone')
insert into product values(2,’Television’)
Run Verifier Query
在验证器终端(./verifier config.propeties)中执行以下示例查询,以检查验证器结果。
Execute the following sample query in the verifier terminal (./verifier config.propeties) to check the verifier result.
Sample Query
insert into verifier_queries (suite, test_catalog, test_schema, test_query,
control_catalog, control_schema, control_query) values
('mysuite', 'mysql', 'default', 'select * from mysql.test.product',
'mysql', 'default', 'select * from mysql.test.product');
这里, select * from mysql.test.product 查询引用 mysql 目录, test 是数据库名称, product 是表名称。通过这种方式,你可以使用 Presto 服务器访问 mysql 连接器。
Here, select * from mysql.test.product query refers to mysql catalog, test is database name and product is table name. In this way, you can access mysql connector using Presto server.
这里,两个相同的 select 查询彼此进行测试,以查看性能。类似地,你可以运行其他查询来测试性能结果。你还可以连接两个 Presto 集群来检查性能结果。
Here, two same select queries are tested against each other to see the performance. Similarly, you can run other queries to test the performance results. You can also connect two Presto clusters to check the performance results.