LinuxでのRedisダウンロードのインストールと構成
19718 ワード
redis nosql( ) , memcached 。
key-value : Redis ,memcached,ttserver
: Mongodb
: Neo4J
: HBase
nosql : , 。
redis :string( ),hash( ),list( ),set( ),
sort set( )。
redis 2 :
1. , 。 , 。
2. mysql binlog , 。
, , , , 。
. redis
wget http://download.redis.io/releases/redis-3.2.12.tar.gz
tar xf redis-3.2.12.tar.gz
cd redis-3.2.12
make
make install # /usr/local/bin
make PREFIX=/usr/local/redis-3.2.12 install # ( )
ln -s /usr/local/redis-3.2.12 /usr/local/redis # ,
:
6 , :
redis-check-rdb # rdb
redis-benchmark #redis , redis
redis-server #redis deamon
redis-sentinel # redis-server
redis-cli #redis 。
redis-check-aof # applendonly.aof 。
echo ‘path=$PATH:/usr/local/redis/bin/’ >> /etc/profile
. redis
mkdir /usr/local/redis/conf –p
cp redis.conf /usr/local/redis/conf/
redis
redis-server /usr/local/redis/conf/redis.conf& # , redis
,
1. WARNING: The TCP backlog setting of 511 cannot be enforced because
/proc/sys/net/core/somaxconn is set to the lower value of 128.
:echo 1000 > /proc/sys/net/core/somaxconn # ,
, /etc/rc.loacl 。
2. WARNING overcommit_memory is set to 0! …..
:
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl –p sysctl vm.overcommit_memory=1
redis-cli shutdown
redis-server /usr/local/redis/conf/redis.conf&
redis
ps –ef | grep redis | grep –v grep
lsof –i :6379
. redis
redis–cli # redis
redis–cli –h 10.0.0.70 –p 6379 # redis
set id 5 # key id,value 5
redis–cli –h 10.0.0.70 –p 6379 set id 5 # , key value
get id # key id value。
redis–cli –h 10.0.0.70 –p 6379 get id # , key value
del id # key id ( key value)
keys * # key value。
quit #
. redis
redis.conf , requirepass , requirepass 123456( , )
redis
redis-cli shutdown
redis-server /usr/local/reids/conf/redis.conf
redis-cli # redis
set name tom
, 。
, : auth 123456 。
, redis, redis-cli shutdown , , 。
redis-cli -a 123456 shutdown
. php-redis
php :/usr/local/php
php.ini :/usr/local/php/lib/php.ini
Nginx :/usr/local/nginx
Nginx :/usr/local/nginx/html
1. phpredis
wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
tar xf 2.2.4.tar.gz
cd phpredis-2.2.4/
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
:/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
vim /usr/local/php/lib/php.ini
:
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/redis.so
nginx,php-fpm
2.
vim /usr/local/nginx/html/index.php
:
phpinfo();
?>
phpinfo redis 。