Fedora安装Redis

80 篇文章 0 订阅
12 篇文章 0 订阅
[color=red]管理工具:[/color]
centos6.3下安装phpredisadmin,以及配置文件 [url]http://wktdhe.blog.51cto.com/4764978/1144514[/url]

[color=red]关于命令:[/color]
redis-cli 命令总结 [url]http://www.178-go.com/archives/redis-cli-%E5%91%BD%E4%BB%A4%E6%80%BB%E7%BB%93.html[/url]

[color=red]关于配置密码:[/color]
[url]http://blog.csdn.net/zyz511919766/article/details/42268219[/url]
修改redis.conf
[color=darkblue]requirepass 12345[/color]
然后启动服务器
[color=darkblue]./redis-server ../redis.conf[/color]
登录
[color=darkblue]./redis-cli -h 127.0.0.1 -p 6379 -a 12345[/color]


[color=red][b]几个命令:[/b][/color]
keys * : 查看所有key信息
keys PANDY* : 查看所有PANDY开头的key
exists(key):确认一个key是否存在
del(key):删除一个key
type(key):返回值的类型
flushdb:删除当前选择数据库中的所有key
flushall:删除所有数据库中的所有key


[color=red]安装测试[/color]
[color=darkblue]wget http://download.redis.io/releases/redis-2.8.24.tar.gz
tar xzf redis-2.8.24.tar.gz
cd redis-2.8.24
make

#启动服务器
cd src
./redis-server

#客户端链接测试
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

[/color]

输出:
......
......
[18380] 03 May 21:02:31.295 * The server is now ready to accept connections on port 6379
表示安装成功


package com.pandy.test;

import redis.clients.jedis.Jedis;

/**
* 项目名称: wp_idea_linux
* 功能说明:
* 创建者: Pandy,
* 邮箱: panyongzheng@163.com, 1453261799@qq.com
* 版权:
* 官网:
* 创建日期: 15-5-11.
* 创建时间: 下午12:55.
* 修改历史:
* -----------------------------------------------
*/

/**
* Redis的测试程序
*/
public class RedisTest {
public static void main(String[] args) {
Jedis jedis = new Jedis("192.168.0.198",6379);
jedis.auth("12345"); //如果有密码,则设定密码
jedis.set("foo", "这个是中文");
String value = jedis.get("foo");
System.out.println(value);
}
}




安装sh
#!/bin/bash
# From here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# Based on: https://github.com/saxenap/install-redis-amazon-linux-centos
# Thanks to https://raw.github.com/gist/2776679/b4f5f5ff85bddfa9e07664de4e8ccf0e115e7b83/install-redis.sh
# Uses redis-server init script from https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server
###############################################
# To use:
## wget https://raw.github.com/jorgerc/install-redis-amazon-linux-centos/master/redis-install-script.sh
## chmod 777 redis-install-script.sh
## ./redis-install-script.sh
###############################################
# Set up SO:
####
yum -y update
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
yum -y install gcc gcc-c++ make
####
# Download and install Redis:
####
version=2.8.12
wget -q http://download.redis.io/releases/redis-$version.tar.gz
tar xzf redis-$version.tar.gz
rm -f redis-$version.tar.gz
cd redis-$version
make
make install
####
# Set up Redis
####
rm -rf /etc/redis /var/lib/redis
mkdir /etc/redis /var/lib/redis
cp src/redis-server src/redis-cli /usr/local/bin
cp redis.conf /etc/redis
sed -e "s/^daemonize no$/daemonize yes/" -e "s/^# bind 127.0.0.1$/bind 0.0.0.0/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel verbose$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
####
# Redis correctly installed.
# Download script for running Redis
####
wget -q https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server
mv redis-server /etc/init.d
chmod 755 /etc/init.d/redis-server
chkconfig --add redis-server
chkconfig --level 345 redis-server on
####
# To start Redis just uncomment this line
####
#service redis-server start
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值