現在vagrantを用いて環境構築を行っています。
macのローカル環境ではpsql -l
でデフォルト?のデータベースが表示されますが、vagrant sshでログインし、cd /vagrantでローカルのVagrantfileのある共有ディレクトリに移動してpsql -l
とするとpsql: FATAL: Rolle »vagrant« existiert nicht
と返されてしまいます。
ちなみに、psql --version
で確認するとpsql (PostgreSQL) 9.5.7
と表示されるのでpsqlは存在しているはずです。
こちらの原因について教えていただけると幸いです。
よろしくお願いいたします。
パソコン環境
macOS Sierra バージョン 10.12.5
cat Vagrantfile 結果
ruby
1# -*- mode: ruby -*- 2# vi: set ft=ruby : 3 4# All Vagrant configuration is done below. The "2" in Vagrant.configure 5# configures the configuration version (we support older styles for 6# backwards compatibility). Please don't change it unless you know what 7# you're doing. 8Vagrant.configure("2") do |config| 9 # The most common configuration options are documented and commented below. 10 # For a complete reference, please see the online documentation at 11 # https://docs.vagrantup.com. 12 13 # Every Vagrant development environment requires a box. You can search for 14 # boxes at https://atlas.hashicorp.com/search. 15 config.vm.box = "CentOS7" 16 17 18 # Disable automatic box update checking. If you disable this, then 19 # boxes will only be checked for updates when the user runs 20 # `vagrant box outdated`. This is not recommended. 21 # config.vm.box_check_update = false 22 23 # Create a forwarded port mapping which allows access to a specific port 24 # within the machine from a port on the host machine. In the example below, 25 # accessing "localhost:8080" will access port 80 on the guest machine. 26 # NOTE: This will enable public access to the opened port 27 config.vm.network "forwarded_port", guest: 3000, host: 3000 28 29 # Create a forwarded port mapping which allows access to a specific port 30 # within the machine from a port on the host machine and only allow access 31 # via 127.0.0.1 to disable public access 32 # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" 33 34 # Create a private network, which allows host-only access to the machine 35 # using a specific IP. 36 config.vm.network "private_network", ip: "192.168.33.10" 37 38 # Create a public network, which generally matched to bridged network. 39 # Bridged networks make the machine appear as another physical device on 40 # your network. 41 # config.vm.network "public_network" 42 43 # Share an additional folder to the guest VM. The first argument is 44 # the path on the host to the actual folder. The second argument is 45 # the path on the guest to mount the folder. And the optional third 46 # argument is a set of non-required options. 47 # config.vm.synced_folder "../data", "/vagrant_data" 48 49 # Provider-specific configuration so you can fine-tune various 50 # backing providers for Vagrant. These expose provider-specific options. 51 # Example for VirtualBox: 52 # 53 # config.vm.provider "virtualbox" do |vb| 54 # # Display the VirtualBox GUI when booting the machine 55 # vb.gui = true 56 # 57 # # Customize the amount of memory on the VM: 58 # vb.memory = "1024" 59 # end 60 # 61 # View the documentation for the provider you are using for more 62 # information on available options. 63 64 # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 65 # such as FTP and Heroku are also available. See the documentation at 66 # https://docs.vagrantup.com/v2/push/atlas.html for more information. 67 # config.push.define "atlas" do |push| 68 # push.app = "YOUR_ATLAS_USERNAME0. 番号リスト/YOUR_APPLICATION_NAME" 69 # end 70 71 # Enable provisioning wih a shell script. Additional provisioners such as 72 # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 73 # documentation for more information about their specific syntax and use. 74 # config.vm.provision "shell", inline: <<-SHELL 75 # apt-get update 76 # apt-get install -y apache2 77 # SHELL 78end
試したこと
出力 systemctl list-units --type=service | grep postgres
結果 postgresql-9.5.service loaded active running PostgreSQL 9.5 database server
出力 'sudo yum install postgresql-server'
結果 'Komplett!'
CentOS7ローカル開発環境にてexit直後、(Vagrantfile直下のディレクトリ)
出力 psql -l -U postgres
結果 psql: FATAL: role "postgres" does not exist
cd /vagrant
共有フォルダへ移動ls
共有フォルダ内表示createuser -s vagrant
の流れになります。
出力 su - postgres
結果 Letzte Anmeldung: Montag, den 12. Juni 2017, 07:21:16 CEST auf pts/0
状態 [vagrant@localhost vagrant]
→ -bash-4.2$ psql -l
へと初期状態が変更
回答2件
あなたの回答
tips
プレビュー