月別アーカイブ: 2017年4月

/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の動作確認していないけど、本番機(という名の残骸)に明日は直接設定。
動作確認は元々動いていないので難しいかな。。。