redis部署

Redis安装 yum install gcc tcl –y
tar -zxvf redis-3.0.5.tar.gz 
mv redis-3.0.5 /usr/local/redis 
cd /usr/local/redis  
make
make install 
cd  /usr/local/bin 
cd /usr/local/redis
mkdir -p /usr/local/bin
cp -p redis-server /usr/local/bin
cp -p redis-benchmark /usr/local/bin
cp -p redis-cli /usr/local/bin
cp -p redis-check-dump /usr/local/bin
cp -p redis-check-aof /usr/local/bin
ln -s  /usr/local/redis/redis.conf  /etc/redis/6379.conf 
vi /etc/redis/6379.conf  
daemonize yes  
wq! 
cd /usr/local/bin
redis-server /etc/redis/6379.conf 
启动 Redis redis-server
redis-cli
这将打开一个 Redis 
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> ping
PONG
redis-cli shutdown  
vi /etc/sysctl.conf 
vm.overcommit_memory = 1
:wq! 
sysctl -p 
设置redis开机启动 vi /etc/init.d/redis   

 chmod 755 /etc/init.d/redis 
chkconfig --add redis  
chkconfig --level 2345 redis on  
chkconfig --list redis  
service redis restart 
设置redis配置文件参数 mkdir -p /usr/local/redis/var 
vi /etc/redis.conf  
daemonize yes  
pidfile "/var/run/redis.pid"  
port 6379  
bind 127.0.0.1 
timeout 300 
loglevel verbose  
logfile stdout 
logfile "/usr/local/redis/var/redis.log"  
databases 16  
save 900 1
save 300 10
save 60 10000
900秒内,
300秒内,
60秒内,
rdbcompression yes 
dbfilename dump.rdb  
dir "/usr/local/redis/var/"  
requirepass 123456  
maxclients 10000 
maxmemory 1024MB 
appendonly yes  
appendfilename "appendonly.aof"   
appendfsync everysec 
:wq! 
service redis restart 

 
通过php程序连接redis数据库 测试代码:
<?php
$redis = new Redis();
$redis->connect('192.168.21.128',6379);
$redis->auth('123456');
$redis->select(1);
$ret = $redis->set('www.osyunwei.com', 'osyunwei');
var_dump($ret);
$allKeys = $redis->keys('*');
print_r($allKeys);
?>
把上面代码保存为test.php,打开之后会出现如下页面
bool(true) Array ( [0] => www.osyunwei.com )

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读