docker-machineが古かった

docker-machineでCentOS7に入れたdockerが起動しなかった。

インストール元

Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with centos...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Error creating machine: Error running provisioning: exit status 5

インストール先

[root@testsv system]# systemctl status docker.service -l
 * docker.service - Docker Application Container Engine
 Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)
 Active: inactive (dead) since Wed 2017-05-10 18:15:08 JST; 28min ago
 Main PID: 13716 (code=exited, status=0/SUCCESS)

May 10 18:15:03 testsv dockerd[13716]: time="2017-05-10T18:15:03.609609938+09:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
 May 10 18:15:04 testsv dockerd[13716]: time="2017-05-10T18:15:04.102333287+09:00" level=info msg="Loading containers: done."
 May 10 18:15:04 testsv dockerd[13716]: time="2017-05-10T18:15:04.124630882+09:00" level=info msg="Daemon has completed initialization"
 May 10 18:15:04 testsv dockerd[13716]: time="2017-05-10T18:15:04.124714583+09:00" level=info msg="Docker daemon" commit=89658be graphdriver=overlay version=17.05.0-ce
 May 10 18:15:04 testsv dockerd[13716]: time="2017-05-10T18:15:04.146221898+09:00" level=info msg="API listen on /var/run/docker.sock"
 May 10 18:15:04 testsv systemd[1]: Started Docker Application Container Engine.
 May 10 18:15:07 testsv systemd[1]: Stopping Docker Application Container Engine...
 May 10 18:15:07 testsv dockerd[13716]: time="2017-05-10T18:15:07.527842954+09:00" level=info msg="Processing signal 'terminated'"
 May 10 18:15:07 testsv dockerd[13716]: time="2017-05-10T18:15:07.53054844+09:00" level=info msg="stopping containerd after receiving terminated"
 May 10 18:15:08 testsv systemd[1]: Stopped Docker Application Container Engine.

症状をみるとこれっぽい。日付けをみるとだいぶ古いけど、masterには取り込まれているから〜といっている。ちゅうことは、docker-machineが古いな。

日本語ドキュメントのワンライナー手順で入れたけど、リリースページを確認するとにほんご頁よりも大分バージョンが上がっている。
リリースページの手順で再インストール。

Provisioning with centos...
Error creating machine: Error running provisioning: something went wrong running an SSH command
command : sudo systemctl -f restart docker
err     : exit status 5
output  : Failed to restart docker.service: Unit not found.

そのままもう一回docker-machine rm -> docker-machine createは失敗。
インストール先で
rm /etc/systemd/system/docker.service

yum remove docker-engine
したら取り敢えず入った。

動作確認はこれから

Dockerの消せないイメージが残っていた

[root@localhost yoshitake]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest f753707788c5 6 months ago 127MB
[root@localhost yoshitake]# docker rmi ubuntu
Error response from daemon: No such image: ubuntu:latest
[root@localhost yoshitake]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              f753707788c5        6 months ago        127MB
[root@localhost yoshitake]# docker rmi f753707788c5
Error response from daemon: reference does not exist

何か消せないdocker imageがいた。こちらをみてファイルがあった/var/lib/docker/image/devicemapper/imagedb/contentのしただけ削除

rm /var/lib/docker/image/devicemapper/imagedb/content/sha256/f753707788c5c100f194ce0a73058faae1a457774efcda6c1469544a114f8644
rm: 通常ファイル `/var/lib/docker/image/devicemapper/imagedb/content/sha256/f753707788c5c100f194ce0a73058faae1a457774efcda6c1469544a114f8644' を削除しますか? y

とりあえず、消えてくれた。きちんと動くかな??

/etc/sudoers.dの#

vagrantのsudo設定
/etc/sudoers.d/vagrant
にしかなさそうだけど/etc/sudoersコメントアウトアウトされてるよねと必死に設定探していたら

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

!! コメントじゃない。

これはみな一度は騙されるに違いない。。。。

 

knife zero移行でぼちぼちエラー

今迄、knife soloを使っていたけれどもメインサーバ移設に併せてknife zeroに移行しようと試験中。
基本はDockerになるのでDockerを動かす基盤としてのプロビジョニングのみ。なので、さくっと終わるかと思ったらそこそこてまどっています。簡単に解決できたものも含めてメモ。

 

ChefDKとrbenb併用しているとrubyのパスがrbenvを向いている(ことが多い)。knife zeloをgemで入れてもrbenvの方を向いてしまいknife zeroが動かない。
Knife-ZeroをマスターしてChef Soloの引退に備えよう!」を参考に修正。
自分はrubyの開発は今のところしないのでrbenvを削除。

knife zero bootstrap ホスト名 だとパーミッションではじかれる。

base7 and any other relevant details that might help us with troubleshooting.
base7 
base7 mkdir: ディレクトリ `/etc/chef' を作成できません: 許可がありません
base7 sh: 行 179: /etc/chef/validation.pem: そのようなファイルやディレクトリはありません

–sudoオプションが必要

 

vagrantで(名前解決しないで?)Nオプションをつけないと、nodes/localhost.jsonになる。名前解決できない状態では、host名をnode名.jsonから(?)逆引きする設定をしないと動かないようなのでlocalhostとしてしまうと2つvagfrantをあげると混乱する。

knife zero bootstrap base7 -N base7 --sudo

 

名前解決していない状態ではホスト名指定のconvergeでは動かない。

knife zero converge base7 --sudo
FATAL: No nodes returned from search

※ base7は~/.ssh/config に設定

knife soloではbase7はsshの接続情報だったが、knife zeloではデフォルトでは一度ホスト名として名前解決にいっているということか??

nodesのjsonを見てやるようにオプション指定をすることで回避

knife zero converge -a knife_zero.host "name:base7"   --sudo
base7 [2017-04-26T02:34:28+00:00] INFO: Forking chef instance to converge...
base7 Starting Chef Client, version 12.19.36

name:ホスト名でknife zeloで設定されているもの(node/json)を使用するらしい。
同じサーバに名前を付けてlocalhost.jsonとbase7_2.jsonがあった状態で”name:localhost”を指定したらbase7_2.jsonが読み込まれたと思われる動きをした。jsonファイル名を見ている訳ではなさそうなので注意。(いま深堀りする必要ないので、取り敢えず名前付きのみで運用)

 

[2017-04-26T02:47:09+00:00] INFO: Running queued delayed notifications before re-raising exception
base7 
base7 Running handlers:
base7 [2017-04-26T02:47:09+00:00] ERROR: Running exception handlers
base7 Running handlers complete
base7 [2017-04-26T02:47:09+00:00] ERROR: Exception handlers complete
base7 Chef Client failed. 0 resources updated in 13 seconds
base7 [2017-04-26T02:47:09+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
base7 [2017-04-26T02:47:09+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
base7 [2017-04-26T02:47:09+00:00] ERROR: yum_package[nginx] (nginx::default line 10) had an error: Chef::Exceptions::Package: No candidate version available for nginx
base7 [2017-04-26T02:47:09+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

パッケージない時のエラーメッセージ、結構下の方に出ているのでぱっとみ見落としやすい

 

 

 

 

Portが埋まっている。

SpringBootの勉強でSTSから出力したjarをWindowsのコマンドプロンプトから実行。

原因調査中だけどメモ代わりに

単に実行可能jarデスクトップ上でダブルクリックしていたのが残っていただけでした。。。。

java -jar C:\Users\epea.pc01\Desktop\mrs-0.0.1-SNAPSHOT.jar

すると、portが埋まっていると言われて起動できなかった。

2017-04-20 17:08:24.561 ERROR 10048 --- [           main] o.a.coyote.http11.Http11NioProtocol      : 
 Failed to start end point associated with ProtocolHandler [http-nio-8080]

java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_131]
        at sun.nio.ch.Net.bind(Unknown Source) ~[na:1.8.0_131]
        at sun.nio.ch.Net.bind(Unknown Source) ~[na:1.8.0_131]

確認すると確かに使用されている。

PS C:\Users\epea.pc01> netstat -oan|Select-String "8080"

  TCP         0.0.0.0:8080           0.0.0.0:0              LISTENING
  TCP         [::]:8080              [::]:0                 LISTENING


PS C:\Users\epea.pc01> Get-Process -Id "2664"

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    380      39   570384     365884      34.33   2664   1 javaw
PS C:\Users\epea.pc01>  Get-Process javaw | Form


Name                       : javaw
Id                         : 2664
PriorityClass              : Normal
FileVersion                : 8.0.1310.11
HandleCount                : 376
WorkingSet                 : 57143296
PagedMemorySize            : 588607488
PrivateMemorySize          : 588607488
VirtualMemorySize          : -427937792
TotalProcessorTime         : 00:00:34.5312500
SI                         : 1
Handles                    : 376
VM                         : 3867029504
WS                         : 57143296
PM                         : 588607488
NPM                        : 40056
Path                       : C:\Program Files\Ja
Company                    : Oracle Corporation
CPU                        : 34.53125
ProductVersion             : 8.0.1310.11
Description                : Java(TM) Platform S
Product                    : Java(TM) Platform S
__NounName                 : Process
BasePriority               : 8
ExitCode                   :
HasExited                  : False
ExitTime                   :
Handle                     : 1564
SafeHandle                 : Microsoft.Win32.Saf
MachineName                : .
MainWindowHandle           : 0
MainWindowTitle            :
MainModule                 : System.Diagnostics.
MaxWorkingSet              : 1413120
MinWorkingSet              : 204800
Modules                    : {System.Diagnostics
                             ), System.Diagnosti
                             ELBASE.dll)...}
NonpagedSystemMemorySize   : 40056
NonpagedSystemMemorySize64 : 40056
PagedMemorySize64          : 588607488
PagedSystemMemorySize      : 207872
PagedSystemMemorySize64    : 207872
PeakPagedMemorySize        : 668753920
PeakPagedMemorySize64      : 668753920
PeakWorkingSet             : 454303744
PeakWorkingSet64           : 454303744
PeakVirtualMemorySize      : -357683200
PeakVirtualMemorySize64    : 3937284096
PriorityBoostEnabled       : True
PrivateMemorySize64        : 588607488
PrivilegedProcessorTime    : 00:00:03.6250000
ProcessName                : javaw
ProcessorAffinity          : 15
Responding                 : True
SessionId                  : 1
StartInfo                  : System.Diagnostics.
StartTime                  : 2017/04/20 16:51:46
SynchronizingObject        :
Threads                    : {10604, 11860, 7328
UserProcessorTime          : 00:00:30.9062500
VirtualMemorySize64        : 3867029504
EnableRaisingEvents        : False
StandardInput              :
StandardOutput             :
StandardError              :
WorkingSet64               : 57143296
Site                       :
Container                  :

スレッドダンプ

2017-04-20 18:31:47
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode):

"DestroyJavaVM" #24 prio=5 os_prio=0 tid=0x000000001ac06000 nid=0x2e54 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"http-nio-8080-AsyncTimeout" #22 daemon prio=5 os_prio=0 tid=0x000000001ac09000 nid=0x1e0 waiting on condition [0x000000002459f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.coyote.AbstractProtocol$AsyncTimeout.run(AbstractProtocol.java:1138)
	at java.lang.Thread.run(Unknown Source)

"http-nio-8080-Acceptor-0" #21 daemon prio=5 os_prio=0 tid=0x000000001ac08800 nid=0x2080 runnable [0x000000002449f000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
	at sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source)
	at sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source)
	- locked  (a java.lang.Object)
	at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:443)
	at java.lang.Thread.run(Unknown Source)

"http-nio-8080-ClientPoller-1" #20 daemon prio=5 os_prio=0 tid=0x000000001ac07800 nid=0x12b8 runnable [0x000000002439f000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
	- locked  (a sun.nio.ch.Util$3)
	- locked  (a java.util.Collections$UnmodifiableSet)
	- locked  (a sun.nio.ch.WindowsSelectorImpl)
	at sun.nio.ch.SelectorImpl.select(Unknown Source)
	at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:775)
	at java.lang.Thread.run(Unknown Source)

"http-nio-8080-ClientPoller-0" #19 daemon prio=5 os_prio=0 tid=0x000000001ac0d000 nid=0x2a8c runnable [0x000000002429f000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
	- locked  (a sun.nio.ch.Util$3)
	- locked  (a java.util.Collections$UnmodifiableSet)
	- locked  (a sun.nio.ch.WindowsSelectorImpl)
	at sun.nio.ch.SelectorImpl.select(Unknown Source)
	at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:775)
	at java.lang.Thread.run(Unknown Source)

"NioBlockingSelector.BlockPoller-1" #18 daemon prio=5 os_prio=0 tid=0x000000001ac0b800 nid=0x12a0 runnable [0x000000002419e000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
	- locked  (a sun.nio.ch.Util$3)
	- locked  (a java.util.Collections$UnmodifiableSet)
	- locked  (a sun.nio.ch.WindowsSelectorImpl)
	at sun.nio.ch.SelectorImpl.select(Unknown Source)
	at org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller.run(NioBlockingSelector.java:339)

"Tomcat JDBC Pool Cleaner[791452441:1492674713173]" #17 daemon prio=5 os_prio=0 tid=0x000000001a5ec800 nid=0x2478 in Object.wait() [0x0000000020a1f000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.util.TimerThread.mainLoop(Unknown Source)
	- locked  (a java.util.TaskQueue)
	at java.util.TimerThread.run(Unknown Source)

"container-0" #16 prio=5 os_prio=0 tid=0x0000000018f8e000 nid=0x1c9c waiting on condition [0x00000000207af000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer$1.run(TomcatEmbeddedServletContainer.java:174)

"ContainerBackgroundProcessor[StandardEngine[Tomcat]]" #15 daemon prio=5 os_prio=0 tid=0x0000000019690000 nid=0x15a4 waiting on condition [0x00000000206af000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1355)
	at java.lang.Thread.run(Unknown Source)

"Service Thread" #9 daemon prio=9 os_prio=0 tid=0x0000000018cf8800 nid=0x2500 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #8 daemon prio=9 os_prio=2 tid=0x0000000018c86000 nid=0x275c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x000000001766d800 nid=0x27e8 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x000000001766a800 nid=0x21e0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x0000000017669000 nid=0x528 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x0000000017668800 nid=0x2a60 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x00000000175fa800 nid=0x1e6c in Object.wait() [0x000000001897f000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on  (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	- locked  (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x00000000015bf000 nid=0x254c in Object.wait() [0x000000001887e000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on  (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Unknown Source)
	at java.lang.ref.Reference.tryHandlePending(Unknown Source)
	- locked  (a java.lang.ref.Reference$Lock)
	at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)

"VM Thread" os_prio=2 tid=0x00000000175d7800 nid=0x2600 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00000000014e7000 nid=0x1ca0 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00000000014e8800 nid=0x1428 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00000000014ea000 nid=0x1950 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00000000014ec800 nid=0x10cc runnable 

"VM Periodic Task Thread" os_prio=2 tid=0x0000000018d55800 nid=0xaec waiting on condition 

JNI global references: 288

2017-04-20 18:31:47
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode):

"DestroyJavaVM" #24 prio=5 os_prio=0 tid=0x000000001ac06000 nid=0x2e54 waiting on condition [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"http-nio-8080-AsyncTimeout" #22 daemon prio=5 os_prio=0 tid=0x000000001ac09000 nid=0x1e0 waiting on condition [0x000000002459f000]
 java.lang.Thread.State: TIMED_WAITING (sleeping)
 at java.lang.Thread.sleep(Native Method)
 at org.apache.coyote.AbstractProtocol$AsyncTimeout.run(AbstractProtocol.java:1138)
 at java.lang.Thread.run(Unknown Source)

"http-nio-8080-Acceptor-0" #21 daemon prio=5 os_prio=0 tid=0x000000001ac08800 nid=0x2080 runnable [0x000000002449f000]
 java.lang.Thread.State: RUNNABLE
 at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
 at sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source)
 at sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source)
 - locked <0x00000000e4d21c20> (a java.lang.Object)
 at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:443)
 at java.lang.Thread.run(Unknown Source)

"http-nio-8080-ClientPoller-1" #20 daemon prio=5 os_prio=0 tid=0x000000001ac07800 nid=0x12b8 runnable [0x000000002439f000]
 java.lang.Thread.State: RUNNABLE
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
 at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
 - locked <0x00000000e4d221b0> (a sun.nio.ch.Util$3)
 - locked <0x00000000e4d221a0> (a java.util.Collections$UnmodifiableSet)
 - locked <0x00000000e4d22040> (a sun.nio.ch.WindowsSelectorImpl)
 at sun.nio.ch.SelectorImpl.select(Unknown Source)
 at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:775)
 at java.lang.Thread.run(Unknown Source)

"http-nio-8080-ClientPoller-0" #19 daemon prio=5 os_prio=0 tid=0x000000001ac0d000 nid=0x2a8c runnable [0x000000002429f000]
 java.lang.Thread.State: RUNNABLE
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
 at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
 - locked <0x00000000e4d25e00> (a sun.nio.ch.Util$3)
 - locked <0x00000000e4d25df0> (a java.util.Collections$UnmodifiableSet)
 - locked <0x00000000e4d25c90> (a sun.nio.ch.WindowsSelectorImpl)
 at sun.nio.ch.SelectorImpl.select(Unknown Source)
 at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:775)
 at java.lang.Thread.run(Unknown Source)

"NioBlockingSelector.BlockPoller-1" #18 daemon prio=5 os_prio=0 tid=0x000000001ac0b800 nid=0x12a0 runnable [0x000000002419e000]
 java.lang.Thread.State: RUNNABLE
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)
 at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
 at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
 - locked <0x00000000e4d2a6f0> (a sun.nio.ch.Util$3)
 - locked <0x00000000e4d2a6e0> (a java.util.Collections$UnmodifiableSet)
 - locked <0x00000000e4d2a590> (a sun.nio.ch.WindowsSelectorImpl)
 at sun.nio.ch.SelectorImpl.select(Unknown Source)
 at org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller.run(NioBlockingSelector.java:339)

"Tomcat JDBC Pool Cleaner[791452441:1492674713173]" #17 daemon prio=5 os_prio=0 tid=0x000000001a5ec800 nid=0x2478 in Object.wait() [0x0000000020a1f000]
 java.lang.Thread.State: TIMED_WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 at java.util.TimerThread.mainLoop(Unknown Source)
 - locked <0x0000000081412b20> (a java.util.TaskQueue)
 at java.util.TimerThread.run(Unknown Source)

"container-0" #16 prio=5 os_prio=0 tid=0x0000000018f8e000 nid=0x1c9c waiting on condition [0x00000000207af000]
 java.lang.Thread.State: TIMED_WAITING (sleeping)
 at java.lang.Thread.sleep(Native Method)
 at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer$1.run(TomcatEmbeddedServletContainer.java:174)

"ContainerBackgroundProcessor[StandardEngine[Tomcat]]" #15 daemon prio=5 os_prio=0 tid=0x0000000019690000 nid=0x15a4 waiting on condition [0x00000000206af000]
 java.lang.Thread.State: TIMED_WAITING (sleeping)
 at java.lang.Thread.sleep(Native Method)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1355)
 at java.lang.Thread.run(Unknown Source)

"Service Thread" #9 daemon prio=9 os_prio=0 tid=0x0000000018cf8800 nid=0x2500 runnable [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #8 daemon prio=9 os_prio=2 tid=0x0000000018c86000 nid=0x275c waiting on condition [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x000000001766d800 nid=0x27e8 waiting on condition [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x000000001766a800 nid=0x21e0 waiting on condition [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x0000000017669000 nid=0x528 waiting on condition [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x0000000017668800 nid=0x2a60 runnable [0x0000000000000000]
 java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x00000000175fa800 nid=0x1e6c in Object.wait() [0x000000001897f000]
 java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on <0x0000000080bbf448> (a java.lang.ref.ReferenceQueue$Lock)
 at java.lang.ref.ReferenceQueue.remove(Unknown Source)
 - locked <0x0000000080bbf448> (a java.lang.ref.ReferenceQueue$Lock)
 at java.lang.ref.ReferenceQueue.remove(Unknown Source)
 at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x00000000015bf000 nid=0x254c in Object.wait() [0x000000001887e000]
 java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on <0x0000000080b2dda8> (a java.lang.ref.Reference$Lock)
 at java.lang.Object.wait(Unknown Source)
 at java.lang.ref.Reference.tryHandlePending(Unknown Source)
 - locked <0x0000000080b2dda8> (a java.lang.ref.Reference$Lock)
 at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)

"VM Thread" os_prio=2 tid=0x00000000175d7800 nid=0x2600 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00000000014e7000 nid=0x1ca0 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00000000014e8800 nid=0x1428 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00000000014ea000 nid=0x1950 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00000000014ec800 nid=0x10cc runnable 

"VM Periodic Task Thread" os_prio=2 tid=0x0000000018d55800 nid=0xaec waiting on condition 

JNI global references: 288

FinalizerとReference HandlerのオブジェクトIDが同じなのはそんなものらしい。

Springのエラー

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'reservationForm' available as request attribute
 at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
 at org.thymeleaf.spring4.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:401) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
 at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:328) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
 at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:294) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
 
Spring徹底入門の写経をしていたら上記のエラー。
reservationFormがAttributeとしてバインドできないといっているっぽい。

見直すとコントローラーでの@ModelAttributeの設定漏れ。


Dockerサポート外

会社用メインサーバは秘伝のたれが詰まったCentOS6でミドルも都度都度足していったもので構成よくわからなくなっている。取りあえず、よく使うやつらだけでもDockerに切り出しておこうかと思ったらCentOS6系はもうサポート対象外なのね。昔からあるサーバは特にいじっていなかったから知らなかった。

このまま使い続けるのもより、いっそのこと今OSもCentOS7にあげてしまった方がいいかな。Docker用OSも考えたけど、何かあったときにミドルをコンテナでなくホストに慌ててインストールとか時間かかりそうなので、メインサーバは無難にCentOSにしとく。

 

取り急ぎのメンテナンス画面(実作業)

昨日の
・一般の人が見ると「まだOPENしてませんよ」に飛ばす
・業者はものを見れるようにしておく。
・触ると色々巻き込まれそうなのでできるだけ今あるものには手を加えたくない
という感じの告知画面追加の実作業。

まずは、dockerのopenresty使って、クッキーチェック付きのリバースプロキシを表に出す。
SSLもプロキシを通そうとしたけど、ECCubeが乗っているapacheのhtaccessに告知画面への302リダイレクト追加

コンテナからグローバルIPの8081ポートを指定したのでファイヤウォールを開けてやる。
稼働予定の本番環境では内部のネットワークのみにしてやらんといけんけどそのままもりっと。
で、apacheのポートやらを変えてやって取りあえずいったん終了。

取り急ぎのメンテナンス画面

前提

前の業者が完成せずに中途半端に本番環境にのっているECCube、認証もかけずに放置していたらプレスリリースしていた関係かURL直打ちでものが売れてしまったとさ。。
というわけで、慌てて一般の人は見れないようにしてほしいとの電話が。
でも、次の業者は物を見てほしいので業者は見れるようにしてほしいと。

色々突っ込みどころはあるけれども取り急ぎ満たさなければいけない(?)要件は
・一般の人が見ると「まだOPENしてませんよ」に飛ばす
・業者はものを見れるようにしておく。
・触ると色々巻き込まれそうなのでできるだけ今あるものには手を加えたくない

ということで、認証付きのリバースプロキシを経由して認証していない人は告知画面に飛ばすことにする。
業者さんが見る目的なのでSSL証明書はそのままでhttpでアクセスしてもらえば既存webサーバのport番号を変えるだけで既存のものには影響でないつもり。
プロキシは認証処理あるので、インストール/アンインストールを考えるとdockerのopenrestyで作るのがよさそうかな。
同一ホスト上にあるので決裁モジュール等もきっと動いてくれるだろう。

という方針で作業開始。

試験機で

nginx周り

本番機はCentOS7.2。
portやらやら触るのでグルーバルIPあるやつでやらんと混乱しそう。
バックアップ機になる予定で契約だけしているさくらVPSにOSインストールして動作確認からはいる。

yum -y install docker
systemctl start docker
systemctl enable docker
docker pull openresty/openresty
docker run -d -p 80:80 --name proxy openresty/openresty:trusty

きっと公式っぽいopenrestyのイメージ。最初タグ無し(latest)でpullしたけれどもUsageにはopenresty/openresty:trustyとなっていたのでこっちを利用。

ここでサーバのIPでhttpアクセスすると、起動はしている。
とりあえず中に入って確認。

docker exec -it proxy /bin/bash

多分、/usr/local/openresty/nginx/conf/nginx.conf
だけいじれば大丈夫そう。そのままいじってもいいけど、入っているエディタがvimでなくviで嫌いなのでコピー

docker cp proxy:/usr/local/openresty/nginx/conf/nginx.conf nginx.conf
vi nginx.conf

中身はこんな感じ

    server {
        listen       80;
        server_name  localhost;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location /auth.html {
          access_by_lua_block{
            ngx.header['Set-Cookie'] = 'gyousya=desu; path=/'
          }
          root   html;
        }

        location /kokuchi.pdf {
          root   html;
        }

        location / {
            root   html;

            rewrite_by_lua_block{
              local cookie_val = ngx.var.cookie_gyousya
              if (not cookie_val) then
                return ngx.redirect("https://www.rocher.kyoto.jp/")
              end
            }
            proxy_pass http://49.212.208.218:8081;
        }

location /auth.htmlに来た時にクッキーセットして
location / でクッキーがNilだとよそに飛ばす。
本来だとkokuchi.pdfに飛ばすけど告知分まだできていないということで自分の店に。

上の方のproxy_set_header系は後ろにあるapacheがリモートアドレス拾えるように。

proxy_passはhostのグローバルIP直接指定。

docker cp nginx.conf proxy:/usr/local/openresty/nginx/conf/nginx.conf

コンテナにコピー。コンテナへのコピーも今はできるのね。。

apache

apacheの設定も一応。ECCubeのドキュメントチラ見した感じだと必要なさそうな気もするけど元のIPもapache本体でも。実際にはheaderにX-Forwarded-For系がついていれば大丈夫そう。

#httpd -M | grep remoteip
 remoteip_module (shared)

yumで取りあえず入れたやつだけどmod_remoteip入っている。
本番機もyum(chefでpackage install)でやっているのできっと入っているはず。(未確認)

こちら参考に設定。

SSL止めてないけど明日。
EC-Cubeの動作確認していないけど、本番機(という名の残骸)に明日は直接設定。
動作確認は元々動いていないので難しいかな。。。

SSLで怒られてた

このブログをChromeでみてたらSSLのマークのところが緑ではない時が。

クリックすると

「このサイトで目にする画像は、悪意のあるユーザーによって差し替えられたものである可能性があります。」と。

httpで画像をよそから持ってきていると出るらしい。特に身に覚えがないとソースを見てみると。

<“img style=”margin: 2px;” title=”商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。お買い物される際には、必ず商品ページの情報を確認いただきますようお願いいたします。また商品ページが削除された場合は、「最新の情報が表示できませんでした」と表示されます。” src=”http://hbb.afl.rakuten.co.jp

と楽天アフリエイトがおりました。

https指定ができないならSEO的に悪そうなのでアフリエイト辞めるかな。取りあえず今日は遅いので放置決定

2017/4/17追記

楽天がSSL対応していたのでアフリエイト張りなおせました。数が少なかったから手作業で。