Giter Club home page Giter Club logo

datavproxy's Introduction

DataVProxy

这是 DataV 数据代理的一个 Node.js 示例应用。

DataV 将 SQL 查询字符串和数据库 id 加密后传到这个应用,而后这个应用连接数据库将查询后的结果返回到 DataV 的页面中。

大家可以直接使用这个 Node.js 版本的示例应用,也可以参照他自己实现。

欢迎大家贡献代码。

步骤

  1. 购买 ECS,最低配置即可,后续如果有需要可以灵活增配。
  2. 部署代码、启动服务
  3. 配置数据库
  4. 配置到 DataV

购买 ECS

https://raw.githubusercontent.com/ericdum/DataVProxy/master/res/ecs.jpg 如下图所示,在“镜像”中选择“公共镜像” => CentOS 7.0 64位。如果没有特殊需求不需要数据盘,带宽建议按流量付费。(参考价格:这样的配置每月¥45,公网流量费用¥0.8/GB) https://raw.githubusercontent.com/ericdum/DataVProxy/master/res/ecs_price.jpg

部署代码、启动服务

下载代码包

wget https://codeload.github.com/ericdum/DataVProxy/zip/master
unzip master
cd DataVProxy-master

部署

make install

https://raw.githubusercontent.com/ericdum/DataVProxy/master/res/output.jpg

保留上图红框中的信息,下一步要用。如果忘记可以执行 node ./bin/info.js 来查看,如果需要变更 key 可用 node ./bin/genkv.js 来生成。

看到红框下面的输出的应用状态信息后,则表示启动成功了。

可以访问 http://域名:端口/status 来验证服务器状态,如根据上图输出的信息则可访问:http://115.29.246.129:9998/status

这个接口会返回 hi, there. 表示服务正在运行

配置数据库

打开 config.js,在 databases 数组中仿照示例增加数据库。

  databases: [
    {
      id: 'test',        // 保证 id 不重复,填入 DataV 后台的“数据库”一栏中
      type: 'mysql',     // rds, ads
      host: '127.0.0.1', // 域名、ip
      user: 'root',      // 用户名
      password: 'root',  // 密码
      database: 'test',  // 数据库名
      port: 3306         // 端口
    },
    {
      // ... 
    },
    // ... 增加数据库填到这里
  ]

配置到 DataV

https://raw.githubusercontent.com/ericdum/DataVProxy/master/res/db.jpg

如图所示,在创建数据源的地方选择“自定义”类型, 然后将前两步红圈中的信息填入输入框

https://raw.githubusercontent.com/ericdum/DataVProxy/master/res/sql.jpg

在数据配置的地方选择“数据库”类型,再选择刚才自定义的数据源就可以了。

运维

查看实时日志

pm2 logs

查看历史日志

ls -al ./DataVProxy-master/logs

重启

pm2 restart all

datavproxy's People

Contributors

ericdum avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.