広告 Serposcope

Serposcopeが動かなくなったので、復帰させる

Google Cloud PlatformにインストールしたSerposcopeのアドレスにアクセスするが、画面が表示されない。落ちているようだ。前にも動かなくなったことがある。結構な頻度で落ちるような気がする。復帰させようと思う。

1.データベース関連をバックアップ

最初に、いろいろ触る前に、データベース関連をバックアップする。
Google Cloud Platformのサイトに行って、ログイン。VMインスタンスに行って、ブラウザウインドウでカスタムポートを開くで、ポート番号を入力してログイン。ここでインスタンスにアクセスする方法はいろいろあるので、適宜選択してください。

データベースとserposcope.sonfをダウンロードする。
公式サイトにこう書いてあった。

Configuration /etc/serposcope.conf
Log files /var/log/serposcope/
Database directory /var/lib/serposcope/

データベースのディレクトリを開くと、db.mv.dbというデータベースがあった。

SSHをブラウザで使うときは、画面に歯車が表示されて、そこからいろいろな機能が使える。ダウンロードアップロードもここからだ。ほかにもいろいろなダウンロード方法があるが、手軽なので、これを使用した。コンソール画面ダウンロードウィンドウ

コンソール画面の右上の歯車をクリックして、ファイルをダウンロードで、完全修飾ファイルパス:のところに、
/etc/serposcope.confを入力して、ダウンロードをクリック。
データベースのライブラリーにもデータがあったので、
/var/lib/serposcope/db.mv.dbを入力してダウンロードをクリック。

しかし、データはMYSQLにしていたので、これじゃないかも。
MYSQLのデータベースをダウンロードする。

MYSQLのデータをダンプファイルにするコマンドmysqldumpを使う。
Sudo mysqldump --lock-all-tables -u root -p -x --all-databases > /tmp/mysqldump_all_database.dump
でデータを作って、これもダウンロード。

2.serposcope再起動

バックアップを取った後、
sudo service serposcope restartを実行した。
すると、あっさりサイトが復活した。以前落ちたときはこんな具合にいかず、結局最初から入れ直したが。上のバックアップは意味なかったがよかった。

3.落ちる原因の対策

サイトのデータを見ると、12月9日までしかデータがない。今は16日。その間は止まったせいだろう、データを取ってない。
/var/lib/serposcopeに、hs_err_pid*.logというのがあって、日付がDec 10 となってて、中身はOut of Memory Errorと書いてある。
以前も止まったことがあるが、 hs_err_pid*.logというのが複数ここにあって、どれもOut of Memory Errorだ。

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 12288 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Unscaled Compressed Oops mode in which the Java heap is
# placed in the first 4GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:xxxx), pid=xxxxx, tid=xxxx
#
# JRE version: OpenJDK Runtime Environment (8.0_232-b09) (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
# Java VM: OpenJDK 64-Bit Server VM (25.232-b09 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

と書いてある。メモリが足りてない?ようだ。Increase physical memory or swap space(メモリかスワップスペースを増やせ)と書いてあるので、
以前やったスワップファイルを作る。
sudo fallocate -l 512M /swapfile
sudo sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

として、もう一度
sudo service serposcope restartとした。
これでしばらく様子を見ようと思う。また落ちたりしたら、スワップファイルの大きさを大きくするとかしてみようと思う。

おすすめドメイン

-Serposcope