2019年8月30日金曜日

Visual Studioを使ってGolang開発時に、覚えておけば開発スピードがだいぶ上がれるショートカットキー一覧

Golangの開発エディターといえば、Visual Studioはかなりおすすめです。
しかも無料です。
最小限に以下のショートカットキーを覚えておけば開発スピードがだいぶ上げられます。

1. Ctrl + TAB

開いたタブを切り替え

2. Ctrl+SHIFT+TAB

前回開いたタブを開く

3. Ctrl+Shift+S 

全保存

4. Command+F

検索

5. Command+Shift+F

全ファイルから検索

6. F3

次を検索

7. Shift+F3

前を検索

8. Shift+Option+左クリック

矩形選択

9. Ctrl+G

指定行へジャンプ

10. Ctrl+E

行末に移動

11. Ctrl+-

直前に参照した行に移動

12. Command+p

指定したファイルを開く

13. Command+-

縮小

14. Command+Shift++

拡大





2019年8月29日木曜日

AWSの外部からAWSのredisに接続可能にする方法

ローカル開発環境構築するため、自分のローカルPC(AWSの外)からAWS redisに接続する必要になりました。
調べたところ、aws redisはVPCのプライベートサブネットに作られているため、外部からの直接接続は不可能です。
踏み台用インスタンス(NATインスタンス)を立てて、アクセス転送の仕組みを使えばなんとかなることがわかりました。
具体的なやり方は以下にまとめました。

NAT用セキュリティグループを作成

EC2コンソール画面から「セキュリティグループ」/「セキュリティグループの作成」の順に操作します。
「インバウンド」タブから「ルールの追加」をクリックして、以下の2つルールを追加します。
・SSH TCP  22 自分のローカルIP
・カスタムTCP TCP 6379 自分のローカルIP

NAT用インスタンスを作成

「AMIの選択」画面、左メニュー「コミュニティAMI」を選択、「amzn-ami-vpc-nat-hvm」を入れて検索します。

出てきた一番最新バージョンのamiを選択します。
PS:自分は最初普通のインスタンスを使っていたが、iptablesの設定など結構苦戦して結局設定できなかったです。やはり用意されたものを使うのが一番です。もしiptablesの設定に詳しいなら、通常のインスタンスでも大丈夫かと思います。


「インスタンス詳細の設定画面」、「自動割当てパブリックIP」を有効にします。

セキュリティグループの設定

前のステップで作成したNAT用セキュリティグループと「default VPC security group」を両方選びます。(2つ同時設定するのは大事!)

NAT インスタンスのSrcDestCheck属性を無効にします。

インスタンス一覧に対象インスタンスをチェックし、「アクション」/「ネットワーキング」/「送信元/送信先の変更チェック」の順に無効化します。





NATインスタンスにiptablesルールを追加

ローカルから作成したNATインスタンスにsshします。
NATインスタンスからのアクセスをRedisに転送するため、以下のiptablesルールを追加します。
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6379 -j DNAT --to redisサーバのIPアドレス:6379
redisサーバのIPアドレスを知る方法はまずElastiCacheダッシュボード/Redis/対象クラスター名の画面からredisサーバのホスト名を取得します。次にhostコマンドでサーバのIPアドレスを取得します。ドメインからIPアドレスを逆引き方法について

service iptables statusコマンドでルールが追加されたことを確認します。
# service iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination      
1    DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:6379 to:172.31.78.185:6379

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination      

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination      

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination      
1    MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0

ローカルから接続確認

これで準備が整いましたので、ローカルから接続してみます。
telnet NATインスタンスのパブリックIP 6379

2019年8月28日水曜日

macにTerraformをインストールする方法

まず、Terraformの公式ダウンロードページから対応OSのパッケージをダウンロードします。

ファイルダウンロード後解凍します。そしたらterraformという名前のファイルが表示されます。

前のステップで獲得した「terraform」ファイルを自分のPATHディレクトリーにコピーあるいは移動します。

PATHディレクトリーを確認するには、echo $PATHコマンドを使います。


$ echo $PATH
 /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
上記のように、PATHディレクトリーが表示されました。
自分の場合はファイルを/usr/local/binにコピーしました。

最後動作確認


terraform --versionをうつとバージョン情報が表示されるはずです。


$ terraform --version
 Terraform v0.12.7

ドメイン名からIPアドレスを調べる方法

ドメイン名からIPアドレスを調べるには、以下の2つ方法があります。

方法1、digコマンドを使います。 yahoo.co.jpのIPアドレスを調べることを例とします。
$ dig +short yahoo.co.jp
182.22.59.229
183.79.135.206
方法2、hostコマンドを使います。同じくyahoo.co.jpを例とします。
$ host yahoo.co.jp
yahoo.co.jp has address 183.79.135.206
yahoo.co.jp has address 182.22.59.229
yahoo.co.jp mail is handled by 10 mx2.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx5.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx3.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx1.mail.yahoo.co.jp.

2019年8月26日月曜日

aws オートスケーリング時に追加されたインスタンスに名前を自動設定

awsのオートスケール機能を使ってインスタンスが立ち上げられた時に、名前が設定されてないことに気づきました。どうずればオートスケーリングで追加されたインスタンスに自動的に名前をつけられるのかを調べてみました。

結論からいうと、Auto Scalingのタグ機能を使えばインスタンスが立ち上げられ時に自動的に名前を作られることができます。

やり方は以下の通りです。
・管理コンソールからEC2の管理画面を開きます。
・Auto Scalingグループから対象Auto Scalingグループを選択します。
・「タグ」タブをクリックし、以下のタグを追加します。
キー:Name、値:インスタンスのName

2019年8月22日木曜日

phpのexec関数でコマンド実行時に、エラーが発生した場合はエラーが表示されていません

phpのexec関数でawsのコマンドを実行したら、エラーが発生したが、何も表示されませんでした。


<?php

$ret = exec("aws s3 ls", $out, $status);
var_dump($ret);
var_dump($out);
var_dump($status);

$statusの値を確認したところ、0ではないことをわかりました。ただ、エラーも何も出力されてないので、どこか駄目なのかさっぱりです。

そんなとき、標準エラーも標準出力へ吐き出すように設定すれば解決できます。

標準エラー出力も標準出力へ吐き出すには2>&1を使います。
改修後、以下になります。


<?php

$ret = exec("aws s3 ls 2>&1", $out, $status);
var_dump($ret);
var_dump($out);
var_dump($status);
再度実行後、ようやくエラーが表示されるようになりました。


Unable to locate credentials. You can configure credentials by running "aws configure
httpdはapacheユーザーとして実行されていますが、apacheユーザーのaws設定がうまくできてないことがわかりました。

2019年8月21日水曜日

php CondeIgniterでmysqlの「INSERT INTO ... ON DUPLICATE KEY UPDATE」を実現する

Mysqlの「INSERT...ON DUPLICATE KEY UPDATE構文」を使えば、レコードがなければ新規作成、あればアップデートを簡単に実現できます。

php CondeIgniterなら、同じような構文がないかを調べてみました。
幸いreplaceを使えば、同等な機能を得られます。 例:↓

$data = array(
        'title' => 'My title',
        'name'  => 'My Name',
        'date'  => 'My date'
);

$this->db->replace('table', $data); 

mysqlテーブルのプライマリーキーを削除

まず、テーブルの構造を表示

show create table テーブル名;

次に、テーブルの主キーを削除
alter table テーブル名 drop PRIMARY KEY;
最後、削除されたことを確認のため、再びテーブル構造の表示:
show create table テーブル名;

mysql文字化けのエラーがおきました。Warning (Code 1300): Invalid ujis character string: '\xE3\x83\xA1\xE3\x83\xBC...'

久々にmysqlに接続して、テーブルを作成しようとしたら、以下のエラーがおきました。
Warning (Code 1300): Invalid ujis character string: '\xE3\x83\xA1\xE3\x83\xBC...'
Warning (Code 1300): Invalid ujis character string: '\xE6\x9B\xB4\xE6\x96\xB0...'
Warning (Code 1300): Invalid ujis character string: '\xE4\xBD\x9C\xE6\x88\x90...'
Warning (Code 1300): Invalid ujis character string: '\xE6\x9B\xB4\xE6\x96\xB0...'
更に、select文で検索してみたら、文字化けしてしまいました。 一番手っ取り早い方法はset names utf8;コマンドをうつことです。
早速実行してみたら、文字化けは解消できました。
>set names utf8;
設定ファイルなど変更も色々方法がありますが、暫定対応としてここまでにしておきます。

2019年8月20日火曜日

centosにopencv-pythonをインストールする方法

pythonとpipがインストールされている前提とします。
pythonで画像ファイルを圧縮機能を作るため、opencv-pythonを使うことに決めました。

早速、pip install opencv-pythonをうってっみたら、なんとエラーが発生しました。
 ERROR: Complete output from command /usr/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-592jsl_n/numpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2romtc2a/install-record.txt --single-version-externally-managed --compile:
    ERROR: Running from numpy source directory.
 
    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:
 
      - `pip install .`       (from a git repo or downloaded source
                               release)
      - `pip install numpy`   (last NumPy release on PyPi)
 
 
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib']
      NOT AVAILABLE
...略

python3.4-devが足りてないようです。 早速python3.4-devをインストールします。

yum list python34-devel*
yum install python34-devel
ようやく準備が整ったようで、再度pip install opencv-pythonをうったら、今度無事にインストールできました。

2019年8月19日月曜日

apacheアカウントに切り替え時に、「This account is currently not available.」エラーが発生しました。

#su - apache
apacheアカウントに切り替えようとして、以下のエラーが発生しました。

This account is currently not available.
/sbin/nologinユーザーが設定されているようです。
それでも切り替えしたい。--shell=/bin/bashをつければ、nologinのユーザーにも切り替えることができます。


su - apache --shell=/bin/bash

2019年8月16日金曜日

macにJmeterを入れる一番簡単な方法

brewを使って、コマンドラインで入れるもありですが、バージョン管理など結構面倒なので、直接ダウンロードするのは一番簡単です。

まず、Jmeterのダウロードページにアクセス、「https://jmeter.apache.org/download_jmeter.cgi」、Binariesのところから最新バージョンをダウンロードします。
ダウンロード後に、解凍して「bin」フォルダに移動します。
ファイル「ApacheJMeter.jar」をダブルクリックしてJmeterを起動します。
初回の場合は、「ApacheJMeter.jar”は、開発元が未確認のため開けません。」のメッセージが表示されることがまります。
もしそうでしたら、「右上のアップルマーク」/「システム環境設定」/「セキュリティとプライバシー」/「一般」/「ダウンロードしたアプリケーションの実行許可:」/「そのまま実行」の順に実行を許可します。

さらに、もしJDKがまだインストールされていない場合、以下のメッセージが表示されることがあります。
"java -jar ApacheJMeter.jar"コマンドラインツールを使用するには、JDKをインストールする必要がります。
そのまま「詳しい情報...」を押して、JDKダウンロードページに遷移します。

Mac用「jdk-12.0.2_osx-x64_bin.dmg」(https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_osx-x64_bin.dmg)ファイルをダウンロードしてインストールします。

JDKをインストール後再度ApacheJMeter.jarを実行したら、ようやく実行画面が表示できるようになりました。



aws s3、とあるバケット、特定のIPからのみを許可する方法


コンソールから対象バケットを選んで、「アクセス権限」→「バケットポリシー」の順にポリシーエディターを開きます。
以下の内容を入力して保存します。
{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "IPAllow",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::対象バケット名前/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": "192.168.143.3/24"
                }
            }
        }
    ]
}


設定画面は以下のように↓

さらに、複数IPからのみを許可するの場合「IpAddress」のところに以下のように複数を入れます。

"IpAddress": {
                    "aws:SourceIp": [
                        "192.168.143.3/24",
                        "202.3.245.201/32"
                    ]
                }

pythonとseleniumを使用して確実にページの先頭にスクロールする方法

調べればたくさん方法があると思いますが、何回試したがうまくいかなかったです。
最後辿り着くのが以下の通りでした。

driver = webdriver.Firefox()
driver.execute_script("window.scrollTo(0, 0);")

2019年8月13日火曜日

Centosでxzファイルの解凍方法

centosでxzファイルを解凍してみたら、以下のエラーが発生しました。

[root@18f0e71a757a ~]# tar xf gtk+-3.24.0.tar.xz
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
どうやら、パッケージが足りてないようで、xzツールをまずインストール

[root@18f0e71a757a ~]# yum install xz
再度「tar xf」コマンドをうったら無事にインストールできました。

ゾンビプロセスの消し方

ある日とあるプロセス消しても消えなかったので、よくみたらゾンビになっていた
以下の通りに、最後「defucnt」がついてる
[root@18f0e71a757a 528]# ps aux | grep 'firefox'
root       638  0.2  0.0      0     0 pts/0    Z    09:48   0:06 [firefox] <defunct>
root       936  0.8  0.0      0     0 pts/0    Z    10:21   0:07 [firefox] <defunct>
root      1087  1.1  0.0      0     0 pts/0    Z    10:24   0:08 [firefox] <defunct>
root      1234  0.9  0.0      0     0 pts/0    Z    10:24   0:07 [firefox] <defunct>
root      1372  0.7  0.0      0     0 pts/0    Z    10:25   0:05 [firefox] <defunct>
root      1511  0.8  0.0      0     0 pts/0    Z    10:26   0:06 [firefox] <defunct>
root      1668  1.0  0.0      0     0 pts/0    Z    10:28   0:06 [firefox] <defunct>
root      2041  0.0  0.0 103376  2028 pts/0    S+   10:37   0:00 grep firefox
どうにかして消したいので、調査したところ、親プロセスも一緒に消せば消えるらしい
早速、以下のコマンドで親プロセスも表示してみた

[root@18f0e71a757a 528]# ps -ef | grep defunct
root       638   622  0 09:47 pts/0    00:00:06 [firefox] <defunct>
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
root      1087  1071  0 10:24 pts/0    00:00:08 [firefox] <defunct>
root      1234  1218  0 10:24 pts/0    00:00:07 [firefox] <defunct>
root      1372  1356  0 10:25 pts/0    00:00:05 [firefox] <defunct>
root      1511  1495  0 10:26 pts/0    00:00:06 [firefox] <defunct>
root      1668  1652  0 10:28 pts/0    00:00:06 [firefox] <defunct>
root      2045    26  0 10:39 pts/0    00:00:00 grep defunct
親プロセスも一緒に消してみる
[root@18f0e71a757a 528]# kill -9 638 622
[root@18f0e71a757a 528]# ps -ef | grep defunct
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
root      1087  1071  0 10:24 pts/0    00:00:08 [firefox] <defunct>
root      1234  1218  0 10:24 pts/0    00:00:07 [firefox] <defunct>
root      1372  1356  0 10:25 pts/0    00:00:05 [firefox] <defunct>
root      1511  1495  0 10:26 pts/0    00:00:06 [firefox] <defunct>
root      1668  1652  0 10:28 pts/0    00:00:06 [firefox] <defunct>
root      2047    26  0 10:40 pts/0    00:00:00 grep defunct
見事に消すことができた

PS:ps -ef | grep defunctの説明

UID          PID     PPID       C    STIME      TTY          TIME              CMD
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
PIDは該当プロセスのID、PPIDは親プロセスのID

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:ピーク時に使用量