redis 3.2コンパイルインストールメモ
4344 ワード
MySQLに比べて、redisはメモリベースの操作でより良い速度体験を提供し、持続的なストレージを提供することができ、データ型が豊富で、アクセスが便利で、キャッシュとして使用する価値があります.
Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, HyperLogLogs, Bitmaps.
インストールGithub内容豊富; 偶数は安定版、例えば3.2、最新3.2.4; make後、コンパイルされたファイルを実行することができる. make[PROFIX=/some/other/directory]installを指定ディレクトリにインストールする.デフォルトは/usr/local/binにインストールされます.
redis.conf構成フラグメントdir永続化データ格納ディレクトリ/var/lib/redis/; slabeof構成後、このredisインスタンスはslaveであり、slave状態で動作することを示す. slaveにアクセスする場合、slaveがslave-read-onlyに設定されている場合、アクセス方法; プロファイルを/etc/下、または/usr/local/redis/下に格納する. プロファイル名redis_6379.conf、6379はサービスポートです. bind命令指定自機(127.0.0.1)とイントラネットアドレス(192.168.*.*.*、通常はredisサービスを公開しない)bind命令(つまりすべてのネットワークアドレスをバインドする)を使用していない場合、認証パスワードを設定していない場合、自機でのみそのサービスにアクセスできます. (error) DENIED. Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. 機器がイントラネットipアドレスを変更する場合はredisの変更に注意する.confファイルを再起動し、サービスを再起動します.
起動停止起動 redis-cliを閉じてインタフェースに入る
永続化CAP定理(CAP theorem)Consistence、Availability、Partition toleranceを知る; Master/Slave Replicationの動作原理slave起動時、マスターに接続し、PSYNCコマンドを送信する. masterは命令を受け、バックグラウンドプロセスを起動してrdbファイルにデータを保存する. マスターとslaveの間でrdbファイルを転送する. slaveファイルをメモリにロードする. 初期ファイルデータ転送完了後の転送がコマンドフローである. slaveは再接続をサポートする;再接続後はインクリメンタルコンテンツのみ転送(partial resynchronization); slave configuration オプション: オプション: マスターauthマスターがrequirepassで認証を設定した場合、slaveはマスターauthで認証に必要なパスワードを与えることができる.コマンドライン:
redis-cli レビューライブラリ2に期限切れのkeysが設定されていない.
Redis Administrationset the Linux kernel overcommit memory setting to 1
redisコマンドの説明redis-benchmark:性能テストツール redis-check-aof:データ修復 redis-check-dump:導出ツールの点検 redis-check-rdb: redis-cli:コマンドラインツール;インタラクティブな操作インタフェースを提供します.-n database numberを指定する. redis-sentinel redis-server:サービスプログラム;
Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, HyperLogLogs, Bitmaps.
インストール
cd /home/tools
wget http://download.redis.io/releases/redis-3.2.4.tar.gz
tar xzf redis-3.2.4.tar.gz
cd redis-3.2.4
make
make PREFIX=/usr/local/redis install
make PREFIX=/usr/local install
make PREFIX=/usr install
cp redis.conf /usr/local/redis/redis_example.conf
src/redis-server
src/redis-client
redis.conf構成フラグメント
dir /var/lib/redis/
slave-read-only yes
起動停止
redis-server /usr/local/redis/redis_6379.conf
redis-server /usr/local/redis/redis_6380.conf
shutdown
でよい.永続化
slaveof 192.168.1.1 6379
slaveのプロファイルで、slaveeofを使用してマスターのip&portを指定すればよい.コマンドラインslaveof
コマンドで指定したマスターを一時的に接続できます.slave-read-only yes
yesはデフォルト設定;config set masterauth
仮設定可能;redis-cli
redis-cli -p 6380
redis-cli -n 2 keys '*' | while read LINE ; do TTL=\
redis-cli -n 2 ttl $LINE`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done;` Redis Administration
echo vm.overcommit_memory = 1 >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
即効;redisコマンドの説明