代码之家  ›  专栏  ›  技术社区  ›  Paras

如何使用mysql作为数据源运行predictionio引擎?

  •  0
  • Paras  · 技术社区  · 7 年前

    我已经安装了 预测 以下发动机 link 使用 第一种方法 .现在我想用 MySQL数据库 作为一个 数据源。

    所以我配置了 环境卫生 文件如下:

    #!/usr/bin/env bash
    #
    # Copy this file as pio-env.sh and edit it for your site's configuration.
    #
    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #    http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #
    
    # PredictionIO Main Configuration
    #
    # This section controls core behavior of PredictionIO. It is very likely that
    # you need to change these to fit your site.
    
    # SPARK_HOME: Apache Spark is a hard dependency and must be configured.
    # SPARK_HOME=$PIO_HOME/vendors/spark-2.0.2-bin-hadoop2.7
    SPARK_HOME=$PIO_HOME/vendors/spark-2.1.1-bin-hadoop2.6
    
    POSTGRES_JDBC_DRIVER=$PIO_HOME/lib/postgresql-42.0.0.jar
    MYSQL_JDBC_DRIVER=$PIO_HOME/lib/mysql-connector-java-8.0.11.jar
    
    
    # PredictionIO Storage Configuration
    #
    # This section controls programs that make use of PredictionIO's built-in
    # storage facilities. Default values are shown below.
    #
    # For more information on storage configuration please refer to
    # http://predictionio.apache.org/system/anotherdatastore/
    
    # Storage Repositories
    
    # Default is to use PostgreSQL
    PIO_STORAGE_REPOSITORIES_METADATA_NAME=pio_meta
    PIO_STORAGE_REPOSITORIES_METADATA_SOURCE=MYSQL
    
    PIO_STORAGE_REPOSITORIES_EVENTDATA_NAME=pio_event
    PIO_STORAGE_REPOSITORIES_EVENTDATA_SOURCE=MYSQL
    
    PIO_STORAGE_REPOSITORIES_MODELDATA_NAME=pio_model
    PIO_STORAGE_REPOSITORIES_MODELDATA_SOURCE=MYSQL
    
    # Storage Data Sources
    
    # PostgreSQL Default Settings
    # Please change "pio" to your database name in PIO_STORAGE_SOURCES_PGSQL_URL
    # Please change PIO_STORAGE_SOURCES_PGSQL_USERNAME and
    # PIO_STORAGE_SOURCES_PGSQL_PASSWORD accordingly
    PIO_STORAGE_SOURCES_PGSQL_TYPE=jdbc
    PIO_STORAGE_SOURCES_PGSQL_URL=jdbc:postgresql://localhost/pio
    PIO_STORAGE_SOURCES_PGSQL_USERNAME=pio
    PIO_STORAGE_SOURCES_PGSQL_PASSWORD=pio
    
    # MySQL Example
    PIO_STORAGE_SOURCES_MYSQL_TYPE=jdbc
    PIO_STORAGE_SOURCES_MYSQL_URL=jdbc:mysql://localhost:3306/pio
    PIO_STORAGE_SOURCES_MYSQL_USERNAME=root
    PIO_STORAGE_SOURCES_MYSQL_PASSWORD=root
    

    我还将mysql java connector jar放在pio_home/lib目录中。 但是当我跑的时候 PIO状态 命令,我得到以下错误:

    [INFO] [Management$] PredictionIO 0.12.1 is installed at /home/oodles/predictionio/PredictionIO-0.12.1
    [INFO] [Management$] Inspecting Apache Spark...
    [INFO] [Management$] Apache Spark is installed at /home/oodles/predictionio/PredictionIO-0.12.1/vendors/spark-2.1.1-bin-hadoop2.6
    [INFO] [Management$] Apache Spark 2.1.1 detected (meets minimum requirement of 1.3.0)
    [INFO] [Management$] Inspecting storage backend connections...
    [INFO] [Storage$] Verifying Meta Data Backend (Source: MYSQL)...
    [ERROR] [Management$] Unable to connect to all storage backends successfully.
    The following shows the error message from the storage backend.
    
    No suitable driver found for jdbc:mysql://localhost:3306/pio (java.sql.SQLException)
    
    Dumping configuration of initialized storage backend sources.
    Please make sure they are correct.
    
    Source Name: MYSQL; Type: jdbc; Configuration: PASSWORD -> root, URL -> jdbc:mysql://localhost:3306/pio, TYPE -> jdbc, USERNAME -> root
    

    有人能帮我解决这个问题吗?

    2 回复  |  直到 7 年前
        1
  •  0
  •   Kishore    7 年前

    改变 jdbc:mysql://localhost:3306/pio jdbc:mysql://localhost/pio 在env.sh文件中

        2
  •  0
  •   Paul    7 年前

    我也遇到过同样的问题,这是因为jdbc驱动程序没有安装,尽管您可能认为它来自pio-env.sh,上面说有某种jar文件。你想做的就是去这个网站 https://dev.mysql.com/downloads/connector/j/ 然后选择“独立于平台”选项,然后单击下载按钮。这个甲骨文网站试图让你注册一些东西,但不要这样做。转到页面底部,显示“不,谢谢,开始下载”并右键单击并保存该链接。现在可以使用“wget”命令获取文件,然后在linux/ubuntu环境中解压缩该文件。我忘了解压命令文件是什么了。我不熟悉Linux/Unix环境,但这对我使用PIO确实有效。