Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vagrant postgresql和外部数据库gui_Postgresql_Vagrant_Puppet - Fatal编程技术网

vagrant postgresql和外部数据库gui

vagrant postgresql和外部数据库gui,postgresql,vagrant,puppet,Postgresql,Vagrant,Puppet,我正在使用PuPHPet/Puppet/Vagrant用nginx和postgresql建立一个VM。我希望能够通过GUI连接到postgresql数据库。但我不知道设置此项所需的步骤 我想我需要在本地机器上将端口5432转发到5432,然后编辑pg_hba.conf以允许外部连接,但我不知道这需要是什么样子 这是我当前的Vagrant文件(没有转发端口) 这是我的默认.pp文件 group { 'puppet': ensure => present } Exec { path =>

我正在使用PuPHPet/Puppet/Vagrant用nginx和postgresql建立一个VM。我希望能够通过GUI连接到postgresql数据库。但我不知道设置此项所需的步骤

我想我需要在本地机器上将端口5432转发到5432,然后编辑pg_hba.conf以允许外部连接,但我不知道这需要是什么样子

这是我当前的Vagrant文件(没有转发端口)

这是我的默认.pp文件

group { 'puppet': ensure => present }
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }

class {'apt':
  always_apt_update => true,
}

Class['::apt::update'] -> Package <|
    title != 'python-software-properties'
and title != 'software-properties-common'
|>

    apt::key { '4F4EA0AAE5267A6C': }

apt::ppa { 'ppa:ondrej/php5-oldstable':
  require => Apt::Key['4F4EA0AAE5267A6C']
}

class { 'puphpet::dotfiles': }

package { [
    'build-essential',
    'vim',
    'curl',
    'git-core'
  ]:
  ensure  => 'installed',
}

class { 'nginx': }


nginx::resource::vhost { 'mylaravel.com':
  ensure       => present,
  server_name  => [
    'mylaravel.com'  ],
  listen_port  => 80,
  index_files  => [
    'index.html',
    'index.htm',
    'index.php'
  ],
  www_root     => '/var/www/public',
  try_files    => ['$uri', '$uri/', '/index.php?$args'],
}

$path_translated = 'PATH_TRANSLATED $document_root$fastcgi_path_info'
$script_filename = 'SCRIPT_FILENAME $document_root$fastcgi_script_name'

nginx::resource::location { 'mylaravel.com-php':
  ensure              => 'present',
  vhost               => 'mylaravel.com',
  location            => '~ \.php$',
  proxy               => undef,
  try_files           => ['$uri', '$uri/', '/index.php?$args'],
  www_root            => '/var/www/public',
  location_cfg_append => {
    'fastcgi_split_path_info' => '^(.+\.php)(/.+)$',
    'fastcgi_param'           => 'PATH_INFO $fastcgi_path_info',
    'fastcgi_param '          => $path_translated,
    'fastcgi_param  '         => $script_filename,
    'fastcgi_param   '           => 'APP_ENV dev',
    'fastcgi_param    '           => 'APP_DBG true',
    'fastcgi_pass'            => 'unix:/var/run/php5-fpm.sock',
    'fastcgi_index'           => 'index.php',
    'include'                 => 'fastcgi_params'
  },
  notify              => Class['nginx::service'],
}

class { 'php':
  package             => 'php5-fpm',
  service             => 'php5-fpm',
  service_autorestart => false,
  config_file         => '/etc/php5/fpm/php.ini',
  module_prefix       => ''
}

php::module {
  [
    'php5-pgsql',
    'php5-cli',
    'php5-curl',
    'php5-intl',
    'php5-mcrypt',
    'php-apc',
  ]:
  service => 'php5-fpm',
}

service { 'php5-fpm':
  ensure     => running,
  enable     => true,
  hasrestart => true,
  hasstatus  => true,
  require    => Package['php5-fpm'],
}

class { 'php::devel':
  require => Class['php'],
}


class { 'xdebug':
  service => 'nginx',
}

class { 'composer':
  require => Package['php5-fpm', 'curl'],
}

puphpet::ini { 'xdebug':
  value   => [
    'xdebug.default_enable = 1',
    'xdebug.remote_autostart = 0',
    'xdebug.remote_connect_back = 1',
    'xdebug.remote_enable = 1',
    'xdebug.remote_handler = "dbgp"',
    'xdebug.remote_port = 9000'
  ],
  ini     => '/etc/php5/conf.d/zzz_xdebug.ini',
  notify  => Service['php5-fpm'],
  require => Class['php'],
}

puphpet::ini { 'php':
  value   => [
    'date.timezone = "America/Chicago"'
  ],
  ini     => '/etc/php5/conf.d/zzz_php.ini',
  notify  => Service['php5-fpm'],
  require => Class['php'],
}

puphpet::ini { 'custom':
  value   => [
    'display_errors = On',
    'error_reporting = -1'
  ],
  ini     => '/etc/php5/conf.d/zzz_custom.ini',
  notify  => Service['php5-fpm'],
  require => Class['php'],
}


class { 'postgresql':
  charset => 'UTF8',
  locale  => 'en_US.UTF-8',
}->
class { 'postgresql::server':
  config_hash => {
    postgres_password => 'root',
  },
}

postgresql::db { 'appDB':
  user     => 'dadams',
  password => 'mypassword',
  grant    => 'ALL',
}

vagrant文件
中添加以下端口转发规则,并执行
vagrant重新加载
,查看是否可以连接到postgresql

config.vm.network:forwarded\u端口,来宾:5432,主机:5432

注意:您可能仍然需要将
postgresql.conf
listen\u addresses
(bind)更改为*(all)接口,并通过修改pg\u hba.conf文件中的主机记录来允许来自特定网络的客户端连接

示例允许无条件从网络10.1.1.0/24连接

host    all             all             10.1.1.0/24                 trust

我认为,在您的用例中,启用第二个网络接口(公共网络)将使生活更加轻松,避免大量端口转发和网络问题。

大多数GUI将允许您通过SSH隧道进行连接。这是做您想做的事情的最佳方式。

如何在pb_hba.conf文件中允许客户端连接?添加到答案中,请参阅此处的更多信息我在使用“puppetlabs postgresql”模块时也遇到过类似问题。对我来说,修复方法是设置listen_addresses=>“*”,因为模块默认设置为“localhost”,这会阻止外部VM通信。sweet。准备好了。我使用的是Navicat,您必须填写两个选项卡才能连接。我没有意识到这一点。谢谢你,胡安
# This file is managed by Puppet. DO NOT EDIT.

# Rule Name: local access as postgres user
# Description: none
# Order: 001
local   all     postgres                ident

# Rule Name: local access to database with same name
# Description: none
# Order: 002
local   all     all             ident

# Rule Name: deny access to postgresql user
# Description: none
# Order: 003
host    all     postgres        0.0.0.0/0       reject

# Rule Name: allow access to all users
# Description: none
# Order: 100
host    all     all     127.0.0.1/32    md5

# Rule Name: allow access to ipv6 localhost
# Description: none
# Order: 101
host    all     all     ::1/128 md5
host    all             all             10.1.1.0/24                 trust