Chr*_*ris 9 openssl r rpostgresql
我在Windows上使用R连接到AWS上托管的PostgreSQL数据库.使用forcessl = 1设置数据库 - 这意味着需要使用sslmode = require设置任何连接.
基础RPostgreSQL包不提供任何ssl选项的暴露.这已成为一个问题多次(见这里,这里,这里和这里)
我知道有使用该RPostgres软件包的解决方法,但出于其他功能原因,我更喜欢使用该RPostgreSQL软件包.
一些答案(例如这里)建议使用修改后的dbname连接ssl,如下所示:
dbConnect(dbDriver('PostgreSQL'),
dbname = 'dbname=foobar sslmode=require', # modified dbname
host = 'foobar.rds.amazonaws.com',
port = 5439,
user = 'foobar',
password = 'foobar')
Run Code Online (Sandbox Code Playgroud)
但这对我来说不适用于使用CRAN版本的软件包.这导致我最近在RPostgreSQL github上提出了一个问题:https://github.com/tomoakin/RPostgreSQL/issues/88
初始用户在从源代码编译包时能够使用修改后的dbname方法.在Windows上,使用使用RTools编译的最新源包(0.6.2),运行修改后的dbname代码时出现以下错误:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect xxxxx.rds.amazonawss.com:5432 on dbname "xxxxxxx": sslmode value "require" invalid when SSL support is not compiled in
)
Run Code Online (Sandbox Code Playgroud)
从这个和线程的其余部分看,在Windows和Mac中看起来无法从当前源获得SSL.但是,开发人员建议:
如果在libssl和libpq成为SSL激活形式的环境中编译,则驱动程序可以使用SSL.
我认为这意味着我可以手动下载lib并自行编译,但我不确定它是否是一个快速修复或者是否需要重新编写包.任何帮助或指向正确的方向将非常感激.我怎样才能以安全,可重复的方式做到这一点?
Building on Windows is a can of worms. See R-Admin Windows Toolset. The only openSSL binaries for windows are from unknown developers. Building and installing openSSL on windows is another can of worms that you will need to research. It might be easier to install openSSL inside the R Windows build environment, but I have no experience with that.
EDIT: It turns out that when installing postgres on Windows, postgres installs openSSL. That means that the central problem on Windows is installing the Windows Toolset for R, installing postgres, then pointing the R build system to libpq.
Another solution would be to run linux in a virtual machine under windows. Here is one way to Install linux on Windows. With linux, depending on the distribution, you would only need to do something like the following from the linux command line (for a RedHat variant of linux):
sudo yum install openSSL
sudo yum install postgresql96
sudo yum install R
Run Code Online (Sandbox Code Playgroud)
Line 2 installs libpq which is required for RPostgreSQL. It is libpq which must be compiled with openSSL. You will only be installing and using the PostgreSQL client, not the server and will also get psql. There might be other packages required, see R linux toolset. Normally, these will get pulled in with the above and should not be a problem.
RPostgreSQL contains a version of libpq, but the compile script does not look like it checks for openSSL, at least not on macOS. So it is important to get a system provided libpq installed.
It is also important for the RPostgreSQL configure script to find pg_config, which is installed when postgres client is installed. Not sure about windows through. So make sure pg_config is in your path. Type pg_config to find out.
Now you need to download and compile RPostgreSQL. To start R, type the following at the linux terminal.
R
Run Code Online (Sandbox Code Playgroud)
Then from within R, get, compile and install RPostgreSQL:
install.packages("https://cran.r-project.org/src/contrib/RPostgreSQL_0.6-2.tar.gz", repo=NULL, type="source")
Run Code Online (Sandbox Code Playgroud)
This should compile and install this version of RPostgreSQL. This last line should also work in windows if you have the windows tools installed correctly.
Hopefully, this gives you some ideas.
| 归档时间: |
|
| 查看次数: |
867 次 |
| 最近记录: |