2019年8月7日水曜日

mysqlのバージョンを確認する方法

まずmysqlに接続し、以下のsqlコマンドを使えばバージョン情報を確認することができます。
>select version();
出力は以下のようになります。

+-------------------------------------------+
| version()                                 |
+-------------------------------------------+
| 5.6.44-enterprise-commercial-advanced-log |
+-------------------------------------------+

2019年8月6日火曜日

aws CodeDeployによりデプロイ失敗調査メモ

CodeDeployを使ってデプロイを行ってみましたが、失敗しました。調査した経過をメモしておきます。

まず、Console上のエラーを確認します。
The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.
それをみてもよくわからないので、EC2にログインして、codedeployエージェントのログを確認します。

>less /var/log/aws/codedeploy-agent/codedeploy-agent.log
そしたら、以下のようなエラーが大量に出力されてました。

/opt/codedeploy-agent/bin/../lib/codedeploy-agent.rb:90:in `<main>'
2019-08-02 07:00:49 ERROR [codedeploy-agent(2040)]: booting child: error during start or run: SystemExit - exit - /opt/codedeploy-agent/lib/instance_agent/runner/child.rb:90:in `exit'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:90:in `rescue in with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:78:in `with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:31:in `prepare_run'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:64:in `block in prepare_run_with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:78:in `with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:63:in `prepare_run_with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:20:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:206:in `block in spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:204:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:204:in `spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:196:in `block in spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:195:in `times'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:195:in `spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:134:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:37:in `block in start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `start'
/opt/codedeploy-agent/bin/../lib/codedeploy-agent.rb:43:in `block (2 levels) in <main>'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/command_support.rb:126:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/command_support.rb:126:in `execute'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/app_support.rb:284:in `block in call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/app_support.rb:297:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/app_support.rb:297:in `call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.11.0/lib/gli/app_support.rb:79:in `run'
/opt/codedeploy-agent/bin/../lib/codedeploy-agent.rb:90:in `<main>'
2019-08-02 07:00:49 INFO  [codedeploy-agent(2036)]: master 2036: Received CHLD - cleaning dead child process
2019-08-02 07:00:49 INFO  [codedeploy-agent(2036)]: master 2036: been told to replace child 2040
2019-08-02 07:00:49 INFO  [codedeploy-agent(2036)]: master 2036: not enough child processes running - missing at least 1 - respawning
2019-08-02 07:00:49 INFO  [codedeploy-agent(2036)]: Started master 2036 with 1 children
2019-08-02 07:00:54 INFO  [codedeploy-agent(2036)]: master 2036: Spawned child 1/1
2019-08-02 07:00:54 INFO  [codedeploy-agent(2513)]: On Premises config file does not exist or not readable
2019-08-02 07:00:54 INFO  [codedeploy-agent(2513)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor: Archives to retain is: 5}
2019-08-02 07:03:06 ERROR [codedeploy-agent(2513)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl: Error during certificate verification on codedeploy endpoint https://codedeploy-commands.ap-northeast-1.amazonaws.com
2019-08-02 07:03:06 ERROR [codedeploy-agent(2513)]: Error validating the SSL configuration: Invalid server certificate
2019-08-02 07:03:06 ERROR [codedeploy-agent(2513)]: booting child: error during start or run: SystemExit - Stopping CodeDeploy agent due to SSL validation error. - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:64:in `abort'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:64:in `validate'
/opt/codedeploy-agent/lib/instance_agent/agent/base.rb:11:in `runner'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:32:in `block in prepare_run'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:78:in `with_error_handling'
どうやっらインスタンスから外部に接続が失敗したようです。

ping google.co.jp
案の定失敗しました。ネットワーク接続を確認したとろこ、ルートテーブルの設定が足りてなかったです。ルートを追加したらうまくインテーネットに接続ができて、デプロイもできるようになりました。


2019年8月1日木曜日

Amazon Linuxでredisをインストール、操作に関するメモ

Amazon Linuxでredisをインストール、操作に関するメモ

まず、インストール

# amazon-linux-extras install redis4.0

次にredisに接続する

# redis-cli -h エンドポイント -p ポート番号

メモリの使用率が気になるので、メモリの容量などを確認する

以下のコマンドをうつっと、たくさんの情報が出てきました。そのうち # Memoryの部分は今回がみたい情報
# info
# Memory
used_memory:25368088
used_memory_human:24.19M
used_memory_rss:45121536
used_memory_rss_human:43.03M
used_memory_peak:40919128
used_memory_peak_human:39.02M
used_memory_peak_perc:62.00%
used_memory_overhead:19204566
used_memory_startup:3668896
used_memory_dataset:6163522
used_memory_dataset_perc:28.40%
allocator_allocated:25576096
allocator_active:41369600
allocator_resident:44400640
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:1248854016
maxmemory_human:1.16G
maxmemory_policy:volatile-lru
allocator_frag_ratio:1.62
allocator_frag_bytes:15793504
allocator_rss_ratio:1.07
allocator_rss_bytes:3031040
rss_overhead_ratio:1.02
rss_overhead_bytes:720896
mem_fragmentation_ratio:1.78
mem_fragmentation_bytes:19795320
mem_not_counted_for_evict:0
mem_replication_backlog:1048576
mem_clients_slaves:0
mem_clients_normal:117942
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
上記の情報をみると、総容量1.16Gのうち、現に24.19Mが使われている。ピーク時に62%が使われた。
maxmemory_human:総容量
used_memory_human:現在の使用量
used_memory_peak_human:ピーク時に使用量