質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Oracle

Oracleは、米オラクルが取り扱うリレーショナルデータベース管理システムです。メインフレームからPCまで、多様なプラットフォームに対応しています。

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

解決済

1回答

1778閲覧

vagrant virtualbox間でのdb接続が出来ないです。

larachan

総合スコア28

Oracle

Oracleは、米オラクルが取り扱うリレーショナルデータベース管理システムです。メインフレームからPCまで、多様なプラットフォームに対応しています。

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2020/06/03 07:42

編集2020/06/03 08:52

vagarnt-oracel19でvirtualbox上にOracleを作成し、ホストのWindowsからはSQLDeveloperで疎通できるようになりました。

vagrantcentOS7をvirtualbox上に作成し、Laravelの環境構築をし、OracleClientなどOracle接続に必要なものは入れました。

LaravelからDBサーバー間の疎通をしようとしましたが、

PHP Warning: oci_connect(): ORA-12541: TNS:no listener in /var/www/html/laravel/vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8.php on line 473 Yajra/Pdo/Oci8/Exceptions/Oci8Exception with message 'ORA-12541: TNS:no listener'

リスナーが立ち上がってないとの事でしたので、Oracle側の確認をしましたがリスナーは立ち上がってました。

[oracle@oracle-19c-vagrant vagrant]$ lsnrctl start LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 03-JUN-2020 16:29:28 Copyright (c) 1991, 2019, Oracle. All rights reserved. TNS-01106: Listener using listener name LISTENER has already been started

virtual box間のネットワークの設定でしょうか?

分かる方教えて下さい。

修正依頼内容
バージョン

$ vagrant --version Vagrant 2.2.9

centOSのVagrantfile

# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. config.vm.box = "centos/7" config.vm.network "forwarded_port", guest: 22, host: 2223, id: "ssh" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # NOTE: This will enable public access to the opened port # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine and only allow access # via 127.0.0.1 to disable public access # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" # Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network "private_network", ip: "192.168.33.10" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options. # Enable provisioning with a shell script. Additional provisioners such as # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # apt-get update # apt-get install -y apache2 # SHELL end

oracleのVagrantfile

# # LICENSE UPL 1.0 # # Copyright (c) 2018, 2020 Oracle and/or its affiliates. # # Since: July, 2018 # Author: gerald.venzl@oracle.com # Description: Creates an Oracle database Vagrant virtual machine. # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" # Box metadata location and box name BOX_URL = "https://oracle.github.io/vagrant-boxes/boxes" BOX_NAME = "oraclelinux/7" # define hostname NAME = "oracle-19c-vagrant" unless Vagrant.has_plugin?("vagrant-proxyconf") puts 'Installing vagrant-proxyconf Plugin...' system('vagrant plugin install vagrant-proxyconf') end # get host time zone for setting VM time zone, if possible # can override in env section below offset_sec = Time.now.gmt_offset if (offset_sec % (60 * 60)) == 0 offset_hr = ((offset_sec / 60) / 60) timezone_suffix = offset_hr >= 0 ? "-#{offset_hr.to_s}" : "+#{(-offset_hr).to_s}" SYSTEM_TIMEZONE = 'Etc/GMT' + timezone_suffix else # if host time zone isn't an integer hour offset, fall back to UTC SYSTEM_TIMEZONE = 'UTC' end # define listener and EM Express ports LISTENER_PORT = 1522 EM_EXPRESS_PORT = 5501 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = BOX_NAME config.vm.box_url = "#{BOX_URL}/#{BOX_NAME}.json" config.vm.define NAME # change memory size config.vm.provider "virtualbox" do |v| v.memory = 2048 v.name = NAME end config.vm.provider :libvirt do |v| v.memory = 2048 end # add proxy configuration from host env - optional if Vagrant.has_plugin?("vagrant-proxyconf") puts "getting Proxy Configuration from Host..." if ENV["http_proxy"] puts "http_proxy: " + ENV["http_proxy"] config.proxy.http = ENV["http_proxy"] end if ENV["https_proxy"] puts "https_proxy: " + ENV["https_proxy"] config.proxy.https = ENV["https_proxy"] end if ENV["no_proxy"] config.proxy.no_proxy = ENV["no_proxy"] end end # VM hostname config.vm.hostname = NAME # Oracle port forwarding config.vm.network "forwarded_port", guest: LISTENER_PORT, host: LISTENER_PORT config.vm.network "forwarded_port", guest: EM_EXPRESS_PORT, host: EM_EXPRESS_PORT # Provision everything on the first run config.vm.provision "shell", path: "scripts/install.sh", env: { "ORACLE_BASE" => "/opt/oracle", "ORACLE_HOME" => "/opt/oracle/product/19c/dbhome_1", "ORACLE_SID" => "ORCLCDB", "ORACLE_PDB" => "ORCLPDB1", "ORACLE_CHARACTERSET" => "AL32UTF8", "ORACLE_EDITION" => "EE", "LISTENER_PORT" => LISTENER_PORT, "EM_EXPRESS_PORT" => EM_EXPRESS_PORT, "SYSTEM_TIMEZONE" => SYSTEM_TIMEZONE } end 現状、仮想マシン(DBサーバー)にprivateIpを振って、仮想マシン(APサーバー)と仮想マシン(DBサーバー)間でのpingの疎通確認ができました。 エラー内容も変更にあったので、仮想マシン間での疎通は出来てそうです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

take88

2020/06/03 07:57

Vagrantのバージョン、Vagrantfileの内容を追記してもらえますか?
yukky1201

2020/06/03 08:05

VirtualBOXで作成した仮想マシン2台の間で接続したいのでしょうか。 その場合、仮想マシンA と 仮想マシンB 間でping疎通できること、firewallで遮断されてないことは確認済みでしょうか。
larachan

2020/06/03 08:32

ごめんなさい。 DB→centOSへはping到達してました。 DB側の仮想マシンのifconfig [vagrant@oracle-19c-vagrant ~]$ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fe20:fd4f prefixlen 64 scopeid 0x20<link> ether 08:00:27:20:fd:4f txqueuelen 1000 (Ethernet) RX packets 2715 bytes 310595 (303.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1931 bytes 457441 (446.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 906 bytes 71289 (69.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 906 bytes 71289 (69.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 こちらにもprivateipをふれば問題ないでしょうか?
guest

回答1

0

自己解決

DB側の仮想マシンにprivateipを振っていけました

投稿2020/06/03 09:06

larachan

総合スコア28

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問