2014/01/23

「Your VM has become "inaccessible."」メッセージでVagrant起動に失敗した場合の復旧方法

Vagrant環境の起動(Vagrant up)を実行した所、
以下メッセージで起動に失敗した時の復旧方法になります。
-----------------------------------------------------------------------
C:\HashiCorp\Vagrant\localdev>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
Your VM has become "inaccessible." Unfortunately, this is a critical error
with VirtualBox that Vagrant can not cleanly recover from. Please open VirtualBox
and clear out your inaccessible virtual machines or find a way to fix
them.

C:\HashiCorp\Vagrant\localdev>
-----------------------------------------------------------------------

VirtualBox上で確認すると、「アクセスできません」というステータスで
操作できなくなっているようです。




ここで、
対象のVirtualBox用ディレクトリにある仮想マシンイメージファイル(.vox)
の「xxxxxx.vbox-tmp」を「xxxxxx.vbox」にリネームして、
Virtualboxを再起動すると「中断」状態で正常認識されました。


この状態で再度vagrantupを実行すると正常起動を確認できました。
-----------------------------------------------------------------------
C:\HashiCorp\Vagrant\localdev>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => xxxx (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
-----------------------------------------------------------------------

Virtualbox上でも正常起動が確認できました。




直前にvagarant halt実行しないまま、うっかりPCシャットダウンしてしまったので、間違いなくそれが原因だと思います。。
この時、起動時に参照するべきVirtualBox用仮想マシンイメージファイル(.vox)が正常終了していないためにtmpファイルとして別名保存されていたようです。

同様の現象の場合はお試しあれ。

9:341 comment

2014/01/18

Linux基礎コマンドまとめ(随時更新)

Linux基礎コマンドまとめ(随時更新)

#CentOSのバージョン確認
cat /etc/redhat-release

#システム情報の確認
uname -a

#プロセスの状況確認
$ top

#サービスの状況確認
$ service サービス名 status

#サービスの開始
$ service サービス名 start

#サービスの停止
$ service サービス名 stop

#サービスの再起動
$ service サービス名 restart

# タスク一覧の確認
$ crontab -l

# タスクの編集
$ crontab -e

#システムシャットダウン
shutdown -h
※以下のようにnowをつけると即時実行
shutdown -h now

#システム再起動
shutdown -r
※以下のようにnowをつけると即時実行
shutdown -r now

# ファイル名検索
find 検索場所 -name ファイル名
例)find / -name php.ini

#データダウンロード
wget ダウンロードURL

#圧縮データの解凍
tar xvfz 圧縮データ




17:49No comments

Vagrantの仮想イメージのバックアップ、別ボックスへの復元方法

Vagrantの仮想イメージのバックアップ、別ボックスへの復元方法

【バックアップ】
①起動側にて以下コマンドを実行
 $ vagrant package

②以下メッセージが表示されれば正常完了。
 C:\HashiCorp\Vagrant\localdev>vagrant package
 [default] Attempting graceful shutdown of VM...
 [default] Clearing any previously set forwarded ports...
 [default] Creating temporary directory for export...
 [default] Exporting VM...
 [default] Compressing package to: C:/HashiCorp/Vagrant/localdev/package.box

 C:\HashiCorp\Vagrant\localdev>


③ローカルディレクトリに、バックアップファイル「package.box」が作成されている事を確認


【復元】
①以下コマンドにて新規ボックス作成
 $ vagrant box add 新規作成ボックス名 バックアップファイル
 $ vagrant box add centos64bk package.box

②以下メッセージが表示されれば正常完了
 C:\HashiCorp\Vagrant\localdev>vagrant box add centos6_bk package.box
 Downloading or copying the box...
 Extracting box...ate: 960M/s, Estimated time remaining: --:--:--)
 Successfully added box 'centos6_bk' with provider 'virtualbox'!

14:15No comments

MySQLのバックアップ、復元方法

# MySQLのバックアップ、復元方法


環境は以下
CentOS :CentOS release 6.5 (Final)
MySQL   :5.5

【バックアップ】
# 全てのDBの場合
$ mysqldump -u ユーザ名 -p パスワード --all-databases > backup.sql

# 特定のDBの場合
$ mysqldump -u ユーザ名 -p パスワード DB名 > 出力ファイル名
例)mysql -u root -p password dbname > dbname.sql

※実行時に以下エラーが出る場合有り。
  mysqldump: unknown variable 'symbolic-links=0'

  この場合は、以下を実行
  MySQLの設定ファイル「my.cnf」にて「symbolic-links」をコメントアウト

  symbolic-links=0
 ↓
  # symbolic-links=0


【復元】
# 全てのDBの場合
mysql -u ユーザ名 -p < 出力ファイル名

# 特定のDBの場合
mysql -u ユーザ名 -p DB名 < 出力ファイル名
14:02No comments

2014/01/15

MySQLのタイムゾーン設定変更方法

①MySQLの設定ファイル「my.cnf」の場所を確認
$ find / -name my.cnf

②MySQLの設定ファイル「my.cnf」を変更
$ vi (①で確認したパス)

[mysqld]
default-time-zone='+9:00'

③MySQLの再起動
$ sudo service mysqld restart

④MySQLにログインの上、以下コマンドデータが正しく反映された事を確認
$ mysql>select curdate(),curtime();

以下のような表示で日付時刻が一致していればOK
+------------+-----------+
| curdate()  | curtime() |
+------------+-----------+
| 2014-01-15 | 20:53:45  |
+------------+-----------+
20:56No comments