root@cdh soft]# cd presto-server-0.216/
[root@cdh presto-server-0.216]# ls
bin lib NOTICE plugin README.txt
mkdir data && mkdir etc
[root@cdh etc]# vi config.properties
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=34445
query.max-memory=1GB
query.max-memory-per-node=1GB
query.max-total-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://127.0.0.1:34445
[root@cdh etc]# vi node.properties
node.environment=production
node.id=prestomaster
node.data-dir=/root/soft/presto-server-0.212/data
[root@cdh etc]# vi jvm.config
-server
-Xmx16G
-XX:+UseConcMarkSweepGC
-XX:+ExplicitGCInvokesConcurrent
-XX:+CMSClassUnloadingEnabled
-XX:+AggressiveOpts
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
-XX:ReservedCodeCacheSize=150M
[root@cdh presto-server-0.216]# vi log.properties
com.facebook.presto=INFO #server日志级别
如果需要从节点
2.2.4从节点配置
从节点配置只需要将主节点的config.properties、node.properties修改即可
config.properties
coordinator=false
http-server.http.port=9000
query.max-memory=20GB
query.max-memory-per-node=10GB
query.max-total-memory-per-node=10GB
discovery.uri=http://ip:9000
node.properties
node.environment=presto_test
node.id=persto02
node.data-dir=/opt/soft/presto-server-0.223/data
[root@cdh etc]# mkdir catalog
[root@cdh etc]# vim mysql.properties
[root@cdh presto-server-0.216]# cd etc
onnector.name=mysql
connection-url=jdbc:mysql://111.231.:3306/
connection-user=r
connection-password=SF
package com.paohaijiao.mybatis; import com.Application; import com.gather.common.constants.Constant; import com.gather.common.util.MD5andKL; import com.gather.general.bean.SysUser; import com.gather.general.bean.UserDto; import com.gather.general.mapper.SysUserMapper; import com.gather.general.mapper.UserMapper; import com.gather.general.service.UserService; import com.gather.general.service.VerifyCodeService; import org.apache.commons.codec.digest.Md5Crypt; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class MybatisApplicationTests { @Autowired private VerifyCodeService verifyCodeService; @Autowired private UserService userService; @Autowired private UserMapper userMapper; @Test public void contextLoads()throws Exception { Class.forName("com.facebook.presto.jdbc.PrestoDriver"); Connection connection = DriverManager.getConnection("jdbc:presto://cdh:34445/mysql/gaoxin","root",null); ; Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("show tables"); while (rs.next()) { System.out.println(rs.getString(1)); } rs.close(); connection.close(); } }
<dependency> <groupId>com.facebook.presto</groupId> <artifactId>presto-jdbc</artifactId> <version>0.100</version> </dependency>
SHOW TABLES FROM postgresql.public;
mybatis必须加statementType="STATEMENT"才能使用
<select id="selectUserList" resultType="com.gather.general.bean.UserDto" parameterType="com.gather.general.bean.UserDto" statementType="STATEMENT"> select b.id as id from user b </select>
PostgresSqlDataSourceMeta meta = new PostgresSqlDataSourceMeta(); meta.setUrl("jdbc:presto://cdh:34445/system/runtime"); meta.setUsername("root"); meta.setDriverClass("com.facebook.presto.jdbc.PrestoDriver");//driver-class-name return meta;
<select id="selectUserList" resultType="com.gather.general.bean.UserDto" parameterType="com.gather.general.bean.UserDto" statementType="STATEMENT"> select b.id as id, c.description as remark ,b.user_name as userName from postgresql.public.r_user c left join mysql.gaoxin.user b on b.id=c.id_user </select>
转换string ->description
<select id="selectUserList" resultType="java.util.HashMap" statementType="STATEMENT"> select b.id as id, c.id_user as isChengdu, cast(c.description AS varchar) as description from postgresql.public.r_user c left join mysql.gaoxin.user b on b.id=c.id_user </select>
来源:oschina
链接:https://my.oschina.net/goudingcheng/blog/3165263