sg <

PDF全文検索サーバー構築、再び。honyomiをリモートサーバー上で稼働させ、外でも読書できるようにするのよ。

環境

ローカル

OS: Ubuntu 18.04.1 LTS
Docker: Docker version 18.09.0, build 4d60db4
Honyomi: honyomi 1.5.0

リモート

OS: CentOS release 6.10 (Final)
Docker: Docker version 1.7.1, build 786b29d

はじめに

ローカルでhonyomiを構築して、ある程度便利に運用していたが、やはり外で読書できなきゃね。

というわけでリモートサーバ上で稼働させることにしたよ。

まずは、ローカルでどのくらいディスクスペースを占めているのか。

$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ongaeshi/honyomi    latest              110b36179697        3 years ago         823MB

823MBか。まあ、PDFをぶち込みまくったからねぇ。

いやちがうで、

$ sudo docker ps -a -s
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                    NAMES               SIZE
d969bee1bd4b        ongaeshi/honyomi    "/bin/sh -c 'honyomi…"   4 months ago        Up 9 days                   0.0.0.0:9295->9295/tcp   my-honyomi1         34.8GB (virtual 35.6GB

35.6GBかい。きついわー。

PDFそのものはどれくらいか。自分の場合、/booksディレクトリ配下にPDFを配置しているので、以下の通り

/books$ sudo du -s -m
57942	.

57942MBか、、、サーバ側のディスクフリースペースが気になるところ。

[ ~]# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda3         199322 11949    177248   7% /
tmpfs                939     0       939   0% /dev/shm
/dev/vda1            243    79       151  35% /boot

まあ、ぎりナントカ。

今時のDockerはCentOS6をサポートしてない!!

調べを進めると、CentOS6はDockerのサポート外だと!!

https://docs.docker.com/install/linux/docker-ce/centos/

To install Docker CE, you need a maintained version of CentOS 7. Archived versions aren’t supported or tested.

絶対に許さない。

友よ、力を貸したまえ!

https://qiita.com/soushiy/items/4a600b0a545701e4fd15

1. yumでインストール

そうか、そうか、ならばやってみよう。

[ ~]# yum -y --enablerepo=remi,epel,rpmforge install docker-io
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                            | 8.2 kB     00:00
 * base: mirrors.cat.net
 * epel: ftp.riken.jp
 * extras: mirrors.cat.net
 * remi: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirrors.cat.net
base                                                     | 3.7 kB     00:00
extras                                                   | 3.4 kB     00:00
remi                                                     | 3.0 kB     00:00
remi/primary_db                                          | 2.3 MB     00:00
remi-safe                                                | 3.0 kB     00:00
updates                                                  | 3.4 kB     00:00
No package docker-io available.
Error: Nothing to do

ダメじゃないか、このやろう

2. rpmをダウンロードして、これをインストール

[ ]# curl -O -sSL https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
[ ]# yum -y localinstall --nogpgcheck docker-engine-1.7.1-1.el6.x86_64.rpm
Loaded plugins: fastestmirror, security
Setting up Local Package Process
Examining docker-engine-1.7.1-1.el6.x86_64.rpm: docker-engine-1.7.1-1.el6.x86_64
Marking docker-engine-1.7.1-1.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: ftp.riken.jp
 * extras: mirrors.cat.net
 * remi: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.7.1-1.el6 will be installed
--> Processing Dependency: libcgroup for package: docker-engine-1.7.1-1.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-27.el6_10 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch   Version            Repository                         Size
================================================================================
Installing:
 docker-engine
              x86_64 1.7.1-1.el6        /docker-engine-1.7.1-1.el6.x86_64  19 M
Installing for dependencies:
 libcgroup    x86_64 0.40.rc1-27.el6_10 updates                           131 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total size: 19 M
Total download size: 131 k
Installed size: 20 M
Downloading Packages:
libcgroup-0.40.rc1-27.el6_10.x86_64.rpm                  | 131 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libcgroup-0.40.rc1-27.el6_10.x86_64                          1/2
  Installing : docker-engine-1.7.1-1.el6.x86_64                             2/2
  Verifying  : docker-engine-1.7.1-1.el6.x86_64                             1/2
  Verifying  : libcgroup-0.40.rc1-27.el6_10.x86_64                          2/2

Installed:
  docker-engine.x86_64 0:1.7.1-1.el6

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-27.el6_10

Complete!
[ ]# service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]
[ ]# chkconfig docker on

いいよ、いいよ。すごくいいよ。

4. 動作確認

[ ~]# docker --version
Docker version 1.7.1, build 786b29d

ちな

みに、「docker コンテナで Too many open files が発生する」ことがあるので、ulimit -n を変更せよというのはやっていません。

https://www.agilegroup.co.jp/technote/howto-change-docker-container-ulimit.html

docker export my_honyomi1 > local_honyomi_export.tar

tarファイルはかなり巨大。ナントか新しいサーバーにコピーして。

cat local_honyomi_export.tar |sudo docker import - ongaeshi:honyomi

あかんであかんで

[ ]# cat local_honyomi_export.tar |sudo docker import - ongaeshi:honyomi
Error response from daemon: ApplyLayer exit status 1 stdout:  stderr: write /root/.honyomi/image/1/book-0972.jpg: no space left on device

クレームや。

[ ]# vi docker
# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d
DOCKER_STORAGE_OPTIONS=--storage-opt dm.basesize=40G

other_args=""

追記したらうまくいくかな。

[root@www16299uf sysconfig]# /etc/rc.d/init.d/docker restart
/etc/sysconfig/docker: line 6: dm.basesize=40G: command not found
Stopping docker: [ OK ]
Starting docker: [ OK ]

駄目すぎる、、、

https://qiita.com/Hige-Moja/items/e81377554c02f986f4f4

https://github.com/moby/moby/issues/8971

https://qiita.com/hana_shin/items/392bd01be6aff9fc1dd4

とりあえず、もちつけ。

[ ]# docker run --name my-honyomi -it -p 9295:9295 ongaeshi/honyomi
Unable to find image 'ongaeshi/honyomi:latest' locally
latest: Pulling from ongaeshi/honyomi

902b87aaaec9: Pulling fs layer
9a61b6b1315e: Pull complete
1ff9f26f09fb: Pull complete
607e965985c1: Pull complete
9213e81cb0f2: Pull complete
68e6b69220e6: Pull complete
98d9b550773a: Pull complete
a6f910a70a8b: Pull complete
70aaa32bac74: Pull complete
328b8d8d5f29: Pull complete
6cc6e6b9897f: Pull complete
a258a6d11ba6: Pull complete
6c2bd65ee48c: Pull complete
3c6f42a203cc: Pull complete
0d7c46794474: Pull complete
dfb63f893158: Pull complete
9664620d4c2a: Pull complete
3a6861591502: Pull complete
b2896a1c79c4: Pull complete
d88fb9904e94: Pull complete
50a846670263: Pull complete
0d5f7dcc1c3b: Pull complete
f6446108911b: Pull complete
3f69df9178fe: Pull complete
Digest: sha256:62e6f1d496b419f2133d229126bd77dbcba7c6ed6182ec4307866cb141e36662
Status: Downloaded newer image for ongaeshi/honyomi:latest
Error response from daemon: Cannot start container 5fa0d1903d1f415dc67e6d6db486ee9db40c8f954dee11c9d7038ac9bcdf6133: no such file or directory

さてよく分からない。

[ ]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[ ]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ongaeshi/honyomi    latest              3f69df9178fe        3 years ago         823.1 MB
[ ]# docker run --name my-honyomi -it -p 9295:9295 ongaeshi/honyomi
Error response from daemon: Conflict. The name "my-honyomi" is already in use by container 5fa0d1903d1f. You have to delete (or rename) that container to be able to reuse that name.
[ ]# docker start my-honyomi
Error response from daemon: Cannot start container my-honyomi: no such file or directory
Error: failed to start containers: [my-honyomi]

 

止まっているコンテナを発見。

[ ]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
5fa0d1903d1f        ongaeshi/honyomi    "/bin/sh -c 'honyomi   49 minutes ago

 

[ ]# find / -name "docker"
/etc/docker
/etc/rc.d/init.d/docker
/etc/sysconfig/docker
/usr/bin/docker
/usr/share/bash-completion/completions/docker
/usr/libexec/docker
/var/run/docker
/var/log/docker
/var/lock/subsys/docker
/var/lib/docker

よく分からなくて父さん憤死。Docker1.17は時代遅れ。

というわけで、RubyGem経由でインストールを試みることに相成った。

まず憎らしいdockerを闇に葬る

[ ]# rpm -e docker-engine-1.7.1-1.el6.x86_64

これが俺のやり方だ。

まずはインストール方法を熟読する

http://honyomi.nagoya/ja/install.html

gemコマンドを使うのだ。

あ、つかえませんでした。

[ ]# gem install honyomi
-bash: gem: command not found

1. RubyGemsのインストール

おいそこからかよ。Rubyなんて使ったことないもんね。

[ ]# yum -y install rubygems
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: ftp.iij.ad.jp
 * extras: mirrors.cat.net
 * remi: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package rubygems.noarch 0:1.3.7-5.el6 will be installed
--> Processing Dependency: ruby(abi) = 1.8 for package: rubygems-1.3.7-5.el6.noarch
--> Processing Dependency: ruby-rdoc for package: rubygems-1.3.7-5.el6.noarch
--> Processing Dependency: /usr/bin/ruby for package: rubygems-1.3.7-5.el6.noarch
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.374-5.el6 will be installed
---> Package ruby-libs.x86_64 0:1.8.7.374-5.el6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: ruby-libs-1.8.7.374-5.el6.x86_64
---> Package ruby-rdoc.x86_64 0:1.8.7.374-5.el6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.374-5.el6 for package: ruby-rdoc-1.8.7.374-5.el6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
---> Package ruby-irb.x86_64 0:1.8.7.374-5.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
 Package                                  Arch                           Version                                 Repository                    Size
====================================================================================================================================================
Installing:
 rubygems                                 noarch                         1.3.7-5.el6                             base                         207 k
Installing for dependencies:
 compat-readline5                         x86_64                         5.2-17.1.el6                            base                         130 k
 ruby                                     x86_64                         1.8.7.374-5.el6                         base                         538 k
 ruby-irb                                 x86_64                         1.8.7.374-5.el6                         base                         318 k
 ruby-libs                                x86_64                         1.8.7.374-5.el6                         base                         1.7 M
 ruby-rdoc                                x86_64                         1.8.7.374-5.el6                         base                         381 k

Transaction Summary
====================================================================================================================================================
Install       6 Package(s)

Total download size: 3.2 M
Installed size: 11 M
Downloading Packages:
(1/6): compat-readline5-5.2-17.1.el6.x86_64.rpm                                                                              | 130 kB     00:00
(2/6): ruby-1.8.7.374-5.el6.x86_64.rpm                                                                                       | 538 kB     00:00
(3/6): ruby-irb-1.8.7.374-5.el6.x86_64.rpm                                                                                   | 318 kB     00:00
(4/6): ruby-libs-1.8.7.374-5.el6.x86_64.rpm                                                                                  | 1.7 MB     00:00
(5/6): ruby-rdoc-1.8.7.374-5.el6.x86_64.rpm                                                                                  | 381 kB     00:00
(6/6): rubygems-1.3.7-5.el6.noarch.rpm                                                                                       | 207 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                               6.7 MB/s | 3.2 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : compat-readline5-5.2-17.1.el6.x86_64                                                                                             1/6
  Installing : ruby-libs-1.8.7.374-5.el6.x86_64                                                                                                 2/6
  Installing : ruby-1.8.7.374-5.el6.x86_64                                                                                                      3/6
  Installing : ruby-irb-1.8.7.374-5.el6.x86_64                                                                                                  4/6
  Installing : ruby-rdoc-1.8.7.374-5.el6.x86_64                                                                                                 5/6
  Installing : rubygems-1.3.7-5.el6.noarch                                                                                                      6/6
  Verifying  : ruby-rdoc-1.8.7.374-5.el6.x86_64                                                                                                 1/6
  Verifying  : compat-readline5-5.2-17.1.el6.x86_64                                                                                             2/6
  Verifying  : ruby-libs-1.8.7.374-5.el6.x86_64                                                                                                 3/6
  Verifying  : ruby-1.8.7.374-5.el6.x86_64                                                                                                      4/6
  Verifying  : rubygems-1.3.7-5.el6.noarch                                                                                                      5/6
  Verifying  : ruby-irb-1.8.7.374-5.el6.x86_64                                                                                                  6/6

Installed:
  rubygems.noarch 0:1.3.7-5.el6

Dependency Installed:
  compat-readline5.x86_64 0:5.2-17.1.el6   ruby.x86_64 0:1.8.7.374-5.el6   ruby-irb.x86_64 0:1.8.7.374-5.el6   ruby-libs.x86_64 0:1.8.7.374-5.el6
  ruby-rdoc.x86_64 0:1.8.7.374-5.el6

Complete!

2. gemコマンドでインストールだ

[root@www16299uf vip]# gem install honyomi
ERROR:  Error installing honyomi:
        json requires Ruby version >= 1.9.

ぐぬぬ。jsonインストールするのマンドクセ

第3の路があるのだよ

1. git経由でhonyomiのソースを入手

https://github.com/ongaeshi/honyomi-web

2. git経由で直接インストールです。

[ ]# cd /var/www/html
[ ]# git clone https://github.com/ongaeshi/honyomi-web.git honyomi
Initialized empty Git repository in /var/www/html/honyomi/.git/
remote: Enumerating objects: 46, done.
remote: Total 46 (delta 0), reused 0 (delta 0), pack-reused 46
Unpacking objects: 100% (46/46), done.
[ ]# cd honyomi
[ ]# bundle install --path vendor/bundle
-bash: bundle: command not found

いったい何なの?bundleって。

こちとら板東英二しか知らないって

[ ]# yum install rubygem-bundler
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.net
 * epel: ftp.iij.ad.jp
 * extras: mirrors.cat.net
 * remi: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package rubygem-bundler.noarch 0:1.5.2-2.el6 will be installed
--> Processing Dependency: rubygem(net-http-persistent) for package: rubygem-bundler-1.5.2-2.el6.noarch
--> Processing Dependency: rubygem(thor) for package: rubygem-bundler-1.5.2-2.el6.noarch
--> Running transaction check
---> Package rubygem-net-http-persistent.noarch 0:2.9.4-2.el6 will be installed
---> Package rubygem-thor.noarch 0:0.18.1-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
 Package                                           Arch                         Version                            Repository                  Size
====================================================================================================================================================
Installing:
 rubygem-bundler                                   noarch                       1.5.2-2.el6                        epel                       141 k
Installing for dependencies:
 rubygem-net-http-persistent                       noarch                       2.9.4-2.el6                        epel                        24 k
 rubygem-thor                                      noarch                       0.18.1-3.el6                       epel                        51 k

Transaction Summary
====================================================================================================================================================
Install       3 Package(s)

Total download size: 216 k
Installed size: 623 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): rubygem-bundler-1.5.2-2.el6.noarch.rpm                                                                                | 141 kB     00:00
(2/3): rubygem-net-http-persistent-2.9.4-2.el6.noarch.rpm                                                                    |  24 kB     00:00
(3/3): rubygem-thor-0.18.1-3.el6.noarch.rpm                                                                                  |  51 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                               1.0 MB/s | 216 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : rubygem-thor-0.18.1-3.el6.noarch                                                                                                 1/3
  Installing : rubygem-net-http-persistent-2.9.4-2.el6.noarch                                                                                   2/3
  Installing : rubygem-bundler-1.5.2-2.el6.noarch                                                                                               3/3
  Verifying  : rubygem-bundler-1.5.2-2.el6.noarch                                                                                               1/3
  Verifying  : rubygem-net-http-persistent-2.9.4-2.el6.noarch                                                                                   2/3
  Verifying  : rubygem-thor-0.18.1-3.el6.noarch                                                                                                 3/3

Installed:
  rubygem-bundler.noarch 0:1.5.2-2.el6

Dependency Installed:
  rubygem-net-http-persistent.noarch 0:2.9.4-2.el6                                rubygem-thor.noarch 0:0.18.1-3.el6

Complete!
[ ]# bundle -v
Bundler version 1.5.2

3. 気を取り直して、インストール継続

[ ]# bundle install --path vendor/bundle
Fetching gem metadata from http://rubygems.org/...........
Resolving dependencies...

Gem::InstallError: public_suffix requires Ruby version >= 2.1.
An error occurred while installing public_suffix (3.0.3), and Bundler cannot continue.
Make sure that `gem install public_suffix -v '3.0.3'` succeeds before bundling.

rubyのバージョンがふるいだと!

[ ]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

やばい。超めんどくさくなってきた。

ほんじゃあ、古いrubyは捨てる。

[ ]# yum remove ruby
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.374-5.el6 will be erased
--> Processing Dependency: ruby = 1.8.7.374-5.el6 for package: ruby-irb-1.8.7.374-5.el6.x86_64
--> Running transaction check
---> Package ruby-irb.x86_64 0:1.8.7.374-5.el6 will be erased
--> Processing Dependency: ruby-irb = 1.8.7.374-5.el6 for package: ruby-rdoc-1.8.7.374-5.el6.x86_64
--> Running transaction check
---> Package ruby-rdoc.x86_64 0:1.8.7.374-5.el6 will be erased
--> Processing Dependency: ruby-rdoc for package: rubygems-1.3.7-5.el6.noarch
--> Running transaction check
---> Package rubygems.noarch 0:1.3.7-5.el6 will be erased
--> Processing Dependency: ruby(rubygems) for package: rubygem-thor-0.18.1-3.el6.noarch
--> Processing Dependency: ruby(rubygems) for package: rubygem-bundler-1.5.2-2.el6.noarch
--> Processing Dependency: rubygems for package: rubygem-net-http-persistent-2.9.4-2.el6.noarch
--> Running transaction check
---> Package rubygem-bundler.noarch 0:1.5.2-2.el6 will be erased
---> Package rubygem-net-http-persistent.noarch 0:2.9.4-2.el6 will be erased
---> Package rubygem-thor.noarch 0:0.18.1-3.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
 Package                                          Arch                        Version                              Repository                  Size
====================================================================================================================================================
Removing:
 ruby                                             x86_64                      1.8.7.374-5.el6                      @base                      1.8 M
Removing for dependencies:
 ruby-irb                                         x86_64                      1.8.7.374-5.el6                      @base                      1.0 M
 ruby-rdoc                                        x86_64                      1.8.7.374-5.el6                      @base                      1.3 M
 rubygem-bundler                                  noarch                      1.5.2-2.el6                          @epel                      409 k
 rubygem-net-http-persistent                      noarch                      2.9.4-2.el6                          @epel                       54 k
 rubygem-thor                                     noarch                      0.18.1-3.el6                         @epel                      160 k
 rubygems                                         noarch                      1.3.7-5.el6                          @base                      713 k

Transaction Summary
====================================================================================================================================================
Remove        7 Package(s)

Installed size: 5.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : rubygem-bundler-1.5.2-2.el6.noarch                                                                                               1/7
  Erasing    : rubygem-thor-0.18.1-3.el6.noarch                                                                                                 2/7
  Erasing    : rubygem-net-http-persistent-2.9.4-2.el6.noarch                                                                                   3/7
  Erasing    : rubygems-1.3.7-5.el6.noarch                                                                                                      4/7
  Erasing    : ruby-rdoc-1.8.7.374-5.el6.x86_64                                                                                                 5/7
  Erasing    : ruby-irb-1.8.7.374-5.el6.x86_64                                                                                                  6/7
  Erasing    : ruby-1.8.7.374-5.el6.x86_64                                                                                                      7/7
  Verifying  : rubygem-net-http-persistent-2.9.4-2.el6.noarch                                                                                   1/7
  Verifying  : ruby-rdoc-1.8.7.374-5.el6.x86_64                                                                                                 2/7
  Verifying  : rubygem-bundler-1.5.2-2.el6.noarch                                                                                               3/7
  Verifying  : ruby-1.8.7.374-5.el6.x86_64                                                                                                      4/7
  Verifying  : rubygem-thor-0.18.1-3.el6.noarch                                                                                                 5/7
  Verifying  : rubygems-1.3.7-5.el6.noarch                                                                                                      6/7
  Verifying  : ruby-irb-1.8.7.374-5.el6.x86_64                                                                                                  7/7

Removed:
  ruby.x86_64 0:1.8.7.374-5.el6

Dependency Removed:
  ruby-irb.x86_64 0:1.8.7.374-5.el6                        ruby-rdoc.x86_64 0:1.8.7.374-5.el6         rubygem-bundler.noarch 0:1.5.2-2.el6
  rubygem-net-http-persistent.noarch 0:2.9.4-2.el6         rubygem-thor.noarch 0:0.18.1-3.el6         rubygems.noarch 0:1.3.7-5.el6

Complete!

今度こそrubyのインストールだ。

https://qiita.com/Fendo181/items/d14ebfb148223c8e5ecb を参考にする。

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init
source ~/.bash_profile
rbenv -v
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo ~/.rbenv/plugins/ruby-build/install.sh

ストイックにコマンドを入力する。

rbenv install -l

インストール可能なバージョンの羅列。2.6.2が最新バージョンらしい。

インストールですよ。

[ ]# rbenv install 2.6.2
Downloading ruby-2.6.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.2.tar.bz2
Installing ruby-2.6.2...

BUILD FAILED (CentOS release 6.10 (Final) using ruby-build 20190320)

Inspect or clean up the working tree at /tmp/ruby-build.20190323115823.7971
Results logged to /tmp/ruby-build.20190323115823.7971.log

Last 10 log lines:
installing html-docs:               /root/.rbenv/versions/2.6.2/share/doc/ruby
installing capi-docs:               /root/.rbenv/versions/2.6.2/share/doc/ruby
The Ruby readline extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y readline-devel` to fetch missing dependencies.

Configure options used:
  --prefix=/root/.rbenv/versions/2.6.2
  LDFLAGS=-L/root/.rbenv/versions/2.6.2/lib
  CPPFLAGS=-I/root/.rbenv/versions/2.6.2/include

readline-develが無いとのこと。

yum install -y readline-devel

あ、はいはい。

もう一度お願いしますよ。

[ ]# rbenv install 2.6.2
Downloading ruby-2.6.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.2.tar.bz2
Installing ruby-2.6.2...
Installed ruby-2.6.2 to /root/.rbenv/versions/2.6.2

[ ]# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
[ ]# source ~/.bash_profile
[ ]#  rbenv global 2.6.2
[ ]# ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]

ストイックに上記コマンド実行し、rubyのインストールが終了。

先ほど、ruby削除の時についでに削除してしまったbundleをもう一度インストール

[ ]# yum install rubygem-bundler

気を取り直してhonyomiインストール継続

[ ]# bundle install --path vendor/bundle
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from http://rubygems.org/..............
Resolving dependencies...
Fetching public_suffix 3.0.3
Installing public_suffix 3.0.3
Fetching addressable 2.6.0
Installing addressable 2.6.0
Fetching io-like 0.3.0
Installing io-like 0.3.0
Fetching archive-zip 0.12.0
Installing archive-zip 0.12.0
Using bundler 1.17.2
Fetching daemons 1.3.1
Installing daemons 1.3.1
Fetching eventmachine 1.2.7
Installing eventmachine 1.2.7 with native extensions
Fetching gqtp 1.0.6
Installing gqtp 1.0.6
Fetching json 2.2.0
Installing json 2.2.0 with native extensions
Fetching groonga-command 1.4.0
Installing groonga-command 1.4.0
Fetching json-stream 0.2.1
Installing json-stream 0.2.1
Fetching groonga-command-parser 1.1.3
Installing groonga-command-parser 1.1.3
Fetching hashie 3.6.0
Installing hashie 3.6.0
Fetching groonga-client 0.6.0
Installing groonga-client 0.6.0
Fetching pkg-config 1.3.7
Installing pkg-config 1.3.7
Fetching rroonga 7.1.1
Installing rroonga 7.1.1 with native extensions
Fetching grn_mini 0.6.0
Installing grn_mini 0.6.0
Fetching temple 0.8.1
Installing temple 0.8.1
Fetching tilt 2.0.9
Installing tilt 2.0.9
Fetching haml 5.0.4
Installing haml 5.0.4
Fetching launchy 2.4.3
Installing launchy 2.4.3
Fetching rack 1.6.11
Installing rack 1.6.11
Fetching rack-protection 1.5.5
Installing rack-protection 1.5.5
Fetching sinatra 1.4.8
Installing sinatra 1.4.8
Fetching thin 1.6.4
Installing thin 1.6.4 with native extensions
Fetching thor 0.20.3
Installing thor 0.20.3
Fetching os 0.9.6
Installing os 0.9.6
Fetching sane 0.25.8
Installing sane 0.25.8
Fetching whichr 0.3.6
Installing whichr 0.3.6
Fetching honyomi 1.5.0
Installing honyomi 1.5.0
Bundle complete! 1 Gemfile dependency, 30 gems now installed.
Bundled gems are installed into `./vendor/bundle`

honyomiデータベースの作成

/var/www/html/honyomi で以下を実行する。

[ ]# HONYOMI_DATABASE_DIR=/var/www/html/honyomi/data bundle exec honyomi init
Create database to "/var/www/html/honyomi/data/db/honyomi.db"

http

apacheで設定して

http://に空く瀬宇するもページが見つかりません定なエラーが。

httpとrubuが連携取れてないのだろう。

https://qiita.com/taccaya/items/a3cb28ed17c9ab917aab

上記urlを参考にして作業を進める。

[ ]# gem install passenger
Fetching rack-2.0.6.gem
Fetching passenger-6.0.2.gem
Successfully installed rack-2.0.6
Building native extensions. This could take a while...
Successfully installed passenger-6.0.2
Parsing documentation for rack-2.0.6
Installing ri documentation for rack-2.0.6
Parsing documentation for passenger-6.0.2
Installing ri documentation for passenger-6.0.2
Done installing documentation for rack, passenger after 93 seconds
2 gems installed

 

[ ]# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.2.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.


--------------------------------------------

Which languages are you interested in?

Use  to select.
If the menu doesn't display correctly, press '!'

 > (*)  Rubyy
   (*)  Python
   ( )  Node.js
   ( )  Meteor

--------------------------------------------

Warning: some directories may be inaccessible by the web server!

The web server typically runs under a separate user account for security
reasons. That user must be able to access the Phusion Passenger files.
However, it appears that some directories have too strict permissions. This
may prevent the web server user from accessing Phusion Passenger files.

It is recommended that you relax permissions as follows:

  sudo chmod o+x "/root"

Press Ctrl-C to return to the shell. (Recommended)
After relaxing permissions, re-run this installer.
  -OR-
Press Enter to continue anyway.


--------------------------------------------

Checking for required software...

 * Checking for C compiler...
      Found: yes
      Location: /usr/bin/cc
 * Checking for C++ compiler...
      Found: yes
      Location: /usr/bin/c++
 * Checking for Curl development headers with SSL support...
      Found: no
      Error: Cannot find the `curl-config` command.
 * Checking for Zlib development headers...
      Found: yes
      Location: /usr/include/zlib.h
 * Checking for Apache 2...
      Found: yes
      Location of httpd: /usr/sbin/httpd
      Apache version: 2.2.15
 * Checking for Rake (associated with /root/.rbenv/versions/2.6.2/bin/ruby)...
      Found: yes
      Location: /root/.rbenv/versions/2.6.2/bin/ruby /root/.rbenv/versions/2.6.2/bin/rake
 * Checking for OpenSSL support for Ruby...
      Found: yes
 * Checking for RubyGems...
      Found: yes
 * Checking for Ruby development headers...
      Found: yes
      Location: /root/.rbenv/versions/2.6.2/include/ruby-2.6.0/ruby.h
 * Checking for rack...
      Found: yes
 * Checking for OpenSSL development headers...
      Found: yes
      Location: /usr/include/openssl/ssl.h
 * Checking for Apache 2 development headers...
      Found: no
 * Checking for Apache Portable Runtime (APR) development headers...
      Found: no
 * Checking for Apache Portable Runtime Utility (APU) development headers...
      Found: no

Some required software is not installed.
But don't worry, this installer will tell you how to install them.
Press Enter to continue, or Ctrl-C to abort.

--------------------------------------------

Installation instructions for required software

 * To install Curl development headers with SSL support:
   Please install it with yum install libcurl-devel

 * To install Apache 2 development headers:
   Please install it with yum install httpd-devel

 * To install Apache Portable Runtime (APR) development headers:
   Please install it with yum install apr-devel

 * To install Apache Portable Runtime Utility (APU) development headers:
   Please install it with yum install apr-util-devel

If the aforementioned instructions didn't solve your problem, then please take
a look at our documentation for troubleshooting tips:

  https://www.phusionpassenger.com/library/install/apache/
  https://www.phusionpassenger.com/library/admin/apache/troubleshooting/

 

足らないライブラリーがあるから、しくよろなんていう親切メッセージが出てきた。

yum install libcurl-devel
yum install httpd-devel
yum install apr-devel
yum install apr-util-devel

 

--------------------------------------------
Almost there!

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /root/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/passenger-6.0.2/buildout/apache2/mod_passenger.so
   
     PassengerRoot /root/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/passenger-6.0.2
     PassengerDefaultRuby /root/.rbenv/versions/2.6.2/bin/ruby
   

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing.


--------------------------------------------

Validating installation...

 * Checking whether this Passenger install is in PATH... ?
 * Checking whether there are no other Passenger installations... ?
 * Checking whether Apache is installed... ?
 * Checking whether the Passenger module is correctly configured in Apache... (!)

   You did not specify 'LoadModule passenger_module' in any of your Apache
   configuration files. Please paste the configuration snippet that this
   installer printed earlier, into one of your Apache configuration files, such
   as /etc/httpd/conf/httpd.conf.


Detected 0 error(s), 1 warning(s).
Press ENTER to continue.


--------------------------------------------

Deploying a web application

To learn how to deploy a web app on Passenger, please follow the deployment
guide:

  https://www.phusionpassenger.com/library/deploy/apache/deploy/

Enjoy Phusion Passenger, a product of Phusion速 (www.phusion.nl) :-)
https://www.phusionpassenger.com

Passenger速 is a registered trademark of Phusion Holding B.V.

意気込んでアクセスしようとするとエラーが

/var/log/httpd/error_logを確認

[ E 2019-03-24 11:12:29.0427 2580/Tw age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/html/honyomi: Unable to execute command '/root/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/passenger-6.0.2/buildout/support-binaries/PassengerAgent spawn-env-setupper /tmp/passenger.spawn.XXXXFi7dXQ --after': Permission denied (errno=13)
  Error ID: 90126ffc
  Error details saved to: /tmp/passenger-error-pkT74i.html

[ E 2019-03-24 11:12:29.0496 2580/T9 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-2] Cannot checkout session because a spawning error occurred. The identifier of the error is 90126ffc. Please see earlier logs for details about the error.

意味が分からないよね。

https://teratail.com/questions/105459

彼も悩んでいるが、結局、Rubyを再インストールしろ的な流れになっていて、面倒そうだ。

https://aclock.org/archives/262

パーミッションを変更する?/rootを751, /root/.rbenvを755ね。

dr-xr-x---.   7 root root  4096 Mar 23 12:15 root

[ ]# chmod 751 /root


drwxr-xr-x  12 root root  4096 Mar 23 12:10 .rbenv

全然スマートじゃないよね。超姑息的だ。

まあ、要は動けばいいから。

もう一度、アクセストライ。

[ E 2019-03-24 11:30:26.0116 2580/T11 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/html/honyomi: The application encountered the following error: permission denied: system call error: Permission denied: failed to open path for detecting type: </var/www/html/honyomi/data/db/honyomi.db>: #
io.c:540: grn_io_detect_type() (Groonga::PermissionDenied)
  Error ID: 068897e5
  Error details saved to: /tmp/passenger-error-jicSF8.html

またもやパーミッションのエラーだけど、/var/www/html/配下にインストールしたhonyomiのuserとgroupがrootになっていたので適宜変更。

[ ]# chown -R hoge honyomi
[ ]# chgrp -R hoge honyomi

今度は平和的に解決。

アクセスも成功した。

HONYOMIデータベースの移動

まず、ローカルサーバで運用しているdocker内のhonyomiからデータを抜き出す必要がある。

http://honyomi.nagoya/ja/install.html を参照しつつbash上で

docker exec my-honyomi tar czvf /backup.tar.gz /root/.honyomi
 コンテナmy-honyomiの/root/.honyomiに格納されているデータを圧縮し、コンテナ内の/backup.tar.gzに保存する
docker cp my-honyomi:/backup.tar.gz /(ターゲットファイル名.tar.gz)
 コンテナ内のbackup.tar.gzをローカルサーバー上の(ターゲットファイル名.tar.gz)に保存する。

ひとまず得られたtar.gzアーカイブをリモートサーバにアップロードする。

PDFを食わせるにはpdftotextが必要

yum install poppler poppler-utils

結局、、、いろいろやったがどうしてもInternal Server Errorがでてダメだ

KAGOYAのVPSはどうだ!

CentOS7をベースにしてDockerのインストールを試みたが、さいきんのバージョンはKernel 3以上が必要らしい。

OpenVZは仕組み上、ホストのKernelに引っ張られるらしく、バージョンは2よりあげることができず。KVMだったらよかったのにね。

お名前.comのVPS(KVM)はどうだ!

リーズナブル。¥1300/月なり。

書籍データ諸々で80Gはスペースをとるので、HDD 200GBでお安いところはそうない。

CentOSのバージョンはどうよ

[ ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

カーネルのバージョンはどうよ

[ ~]# cat /proc/version
Linux version 3.10.0-862.14.4.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Wed Sep 26 15:12:11 UTC 2018

大丈夫?かも。

https://docs.docker.com/install/linux/docker-ce/centos/ を参考にしつつ、インストール。

インストールあっとゆーまじゃねーか。

最初から、KVMにしておけば良かった。お名前.comバンザイ。

1. リモートからコンテナイメージを取得
docker run --name my-honyomi -it -p 9295:9295 ongaeshi/honyomi
2. 一旦crtl+Cで終了させる。
3. docker startでコンテナ起動。
docker start my-honyomi
4. webブラウザを立ち上げて、http://127.0.0.1:9295を開き動作確認。
docker stop
5. docker run --name my-honyomi -d -it -p 9295:9295 -v /(ホストのhonyomiディレクトリ/.honyomi:/root/.honyomi/ -e HONYOMI_AUTH_USERNAME=username -e HONYOMI_AUTH_PASSWORD=password_hexdigest ongaeshi/honyomi

あとはOSブートがかかってもコンテナが自動起動されるように

https://7me.oji.0j0.jp/2015/10/13/centos-docker-systemd/

に従って設定すればhonyomiライフが始まる。

まずは/etc/systemd/system/に起動スクリプトを配置すればいいんだな

[ ]# cd /etc/systemd/system
[ ]# ls
basic.target.wants
dbus-org.fedoraproject.FirewallD1.service
dbus-org.freedesktop.NetworkManager.service
dbus-org.freedesktop.nm-dispatcher.service
default.target
default.target.wants
dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants
getty.target.wants
local-fs.target.wants
multi-user.target.wants
network-online.target.wants
sockets.target.wants
sysinit.target.wants
system-update.target.wants

ここにサービスを定義する

[ ]# vi myhonyomi.service 
[ ]# cat myhonyomi.service
[Unit]
Description=myhonyomi
After=myhonyomi.service
Requires=myhonyomi.service

[Service]
ExecStart=/usr/bin/docker start my-honyomi

[Install]
WantedBy=multi-user.target

サービスは登録されていないので、エラーが出ることは想定の範囲内。

Dependancyがどうのこうの

[ ]# systemctl status myhonyomi.service -l
● myhonyomi.service - myhonyomi
   Loaded: loaded (/etc/systemd/system/myhonyomi.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Apr 01 00:27:43 v133-130-69-126.myvps.jp systemd[1]: Dependency After=myhonyomi.service dropped from unit myhonyomi.service
Apr 01 00:29:50 v133-130-69-126.myvps.jp systemd[1]: Dependency After=myhonyomi.service dropped from unit myhonyomi.service
Apr 01 00:35:52 v133-130-69-126.myvps.jp systemd[1]: Started myhonyomi.
Apr 01 00:35:52 v133-130-69-126.myvps.jp docker[22563]: my-honyomi

うるさいけど。サービスにさっさと登録

[ ]# systemctl enable myhonyomi.service
Created symlink from /etc/systemd/system/multi-user.target.wants/myhonyomi.service to /etc/systemd/system/myhonyomi.service.
[ ]# systemctl start myhonyomi.service
[ ]# systemctl status myhonyomi.service
● myhonyomi.service - myhonyomi
   Loaded: loaded (/etc/systemd/system/myhonyomi.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2019-04-01 00:38:01 JST; 4s ago
  Process: 22613 ExecStart=/usr/bin/docker start my-honyomi (code=exited, status=0/SUCCESS)
 Main PID: 22613 (code=exited, status=0/SUCCESS)

Apr 01 00:38:01 v133-130-69-126.myvps.jp systemd[1]: Started myhonyomi.
Apr 01 00:38:01 v133-130-69-126.myvps.jp docker[22613]: my-honyomi

登録はできたけど、serviceはactiveにならず、、、でもmy-honyomiコンテナは起動している。

ひとまず、シャットダウンしてみたところ、まんまとhonyomiの起動に成功した、、、Active: inactive(dead)になっているけどこれでいいんだろうかね、、、?

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください