链接Google Compute Engine和Google Cloud SQL [英] Linking Google Compute Engine and Google Cloud SQL

查看:129
本文介绍了链接Google Compute Engine和Google Cloud SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**由于缺乏针对Google云计算引擎(GCE)的清晰文档以及与Google Cloud SQL的集成,尤其是两者之间的链接而感到沮丧.没有实时支持,并且当前文档由于继续引用Google App Engine而缺乏清晰性. Google App Engine上的文档引用了链接,但是没有明确的过程来创建VM实例(在Compute Engine-GCE中)和Google Cloud中的同一项目(同样在Google Cloud上)之间的Google SQL之间的链接.

**Frustrated by the lack of clear documentation for Google cloud compute engine (GCE) and integration with Google cloud SQL and especially linking the two. No live support, and current documentation lacks clarity by continuing to refer to Google App Engine. The documentation on Google App Engine references linking but no clear process for creating a link between VM Instance (in Compute Engine - GCE) and Google SQL on the same project in the Google Cloud (again both on Google Cloud).

我已经安装了具有所有连接器的Mariadb,MariaDB服务器和PHP的Centos 7 VM(64).我已经测试了所有localhost调用,并且都正常工作.

I have installed Centos 7 VM (64) with Mariadb, MariaDB server and PHP with all connectors. I have tested all localhost call and all are working.

在Google SQL的访问控制中:

In Access Control on Google SQL:

  1. 方向似乎指示使用套接字,然后将root用于PHP应用程序?

  1. Directions seem to indicate using socket and then using root for PHP application ?

  • 似乎不太安全.与使用root作为管理员,然后让应用程序在受限数据库中运行受限权限用户相对.需要不同的软件组件才能具有不同的数据库和表访问权限.

从CLI在mySQL中建立具有特权的用户时,Access Control是否需要使用相同的设置来设置相同的用户?

When establishing a user with privileges in mySQL from CLI does Access Control require the same user setup up with same settings?

在Cloud SQl上设置SSL时,不应将SSL自动填充到计算引擎,还是我也需要在计算引擎中设置密钥文件.我尝试过将此设置关闭(需要非常安全的数据传输).但仍然没有喜悦.

When setting up SSL on Cloud SQl, should not the SSL be auto-populated to compute engine or do I need to set up the key files in compute engine as well. I have tried with this setting off (need very secure data transfer). But still no joy.

到目前为止,在测试PHP访问权限I时,尚未获得数据调用, 甚至使用此处的说明:从Google Compute访问Google Cloud SQL实例引擎?

In testing PHP access I, as of yet, have NOT gotten a data call to work, even using instructions found here: Accessing Google Cloud SQL instance from Google Compute Engine?

编辑-已解决-感谢下面的David和下面的评论中提到的链接.

EDIT - SOLVED - Thanks to David below and link mentioned in comment below.

按照下面的说明进行操作,并添加以下步骤:

Follow directions below and add following steps:

  • a.在Cloud SQL的开发人员控制台上创建用户后,使用CLI,HEIDI,mySQL Workbench或类似方法连接到Instance并通过调整已创建的用户来设置特定的数据库特权.

  • a. After user is created on Developers Console in Cloud SQL, use CLI, HEIDI, mySQL Workbench or something similar to connect to Instance and set specific database privileges by adjusting the user already created.

b.然后通过SSH返回VM(GCE)实例,并通过允许远程mysql调整Apache/SELinux-请参见以下链接:

b. Then return to VM (GCE) instance via SSH and adjust Apache/SELinux by allowing remote mysql - see this link: php can't connect to mysql with error 13 (but command line can)

c.安装一个TEST mysqli或PDO连接器,并检查错误.

c. Install a TEST mysqli or PDO connector and check for errors.

d.瞧

推荐答案

在GCE上从PHP连接到Cloud SQL的基本本质如下:

The basic essence of connecting to Cloud SQL from PHP on GCE is the following:

  1. 确保您的Cloud SQL实例具有IPv4地址(实例页面上的访问控制> IP地址"下)
  2. 找出您的GCE实例的公共IP地址,并将其添加为Cloud SQL实例上的授权网络(在访问控制>授权"下).
  3. 为具有远程访问权限的实例添加一个MySQL用户名和密码(在访问控制>用户"下-您需要一个用户作为客户端主机%)
  4. 从GCE连接时,请使用标准MySQL连接系统(例如mysqli_connect)和您刚刚设置的用户名和密码,连接到Cloud SQL实例的IPv4地址.

添加SSL是非常手动的操作-您需要创建客户端证书,然后将服务器CA,客户端证书和客户端私钥复制到服务器,然后配置MySQL客户端以使用它.

Adding SSL is pretty manual - you need to create a client certificate, and copy the server CA, client certificate and client private key to the server, and then configure your MySQL client to use it.

您提到插座&根访问权限.这是App Engine特有的.在Compute Engine中,您不能使用套接字进行连接,您可以自由使用已创建的任何用户.

You mention sockets & root access. This is App Engine specific. From Compute Engine you cannot use a socket to connect, and you are free to use any user you have created.

这篇关于链接Google Compute Engine和Google Cloud SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆