Redis简介
什么是Redis
Redis是一种基于键值对(key-value)的NoSQL数据库,Redis中的值可以是string,hash,list,set,zset,Bitmaps,HyperLogLog,GEO等多种数据结构和算法组成。除此之外,Redia还提供了键过期、发布订阅、事务、流水线、Lua脚本等附加功能
Redis的特性
- 支持多种计算机编程语言
- 支持多种数据结构
- 读/写速度快,性能高
- 支持持久化
- 简单且功能强大
- 实现高可用主从复制,主节点做数据副本
- 实现分布式集群和高可用
Redis的应用场景
- 做缓存
- 做计数器应用
- 实现消息队列系统
- 做实时系统、消息系统
- 实现排行榜应用
- 做数据过期处理
- 做大型社交网络
- 分布式集群架构中的session分离
安装步骤
准备CenterOs6, redis(http://download.redis.io/releases/redis-6.0.8.tar.gz)
#安装命令(如果有可以不用安装)
yum install wget
#新建文件夹
mkdir soft
#进入soft
cd soft
#下载redis
wget http://download.redis.io/releases/redis-6.0.8.tar.gz
#解压缩
tar xf redis-6.0.8.tar.gz
#下载安装gcc编译器
yum install gcc
#进入redis-6.0.8
cd redis-6.0.8
#执行make命令
make
#安装到指定目录下
make install PREFIX=目录(/opt/sunchong/redis6)
#编辑profile文件
vi /etc/profile
#在最下面加上两句话
export REDIS_HOME=目录(/opt/sunchong/redis6)
export PATH=$PATH:$REDIS_HOME/bin
#执行
source /etc/profile
#在当前目录下执行
./install_server.sh
#查询redis进程
ps -fe | grep redis
在执行./install_server.sh如果报出这样的错误
This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
解决方案
#把下面代码注释掉
vi ./install_server.sh
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
一个物理机中可以有多个redis实例(进程),通过port区分
可执行程序就一份在目录,但是内存中未来的多个实例需要各自的配置文件,持久化目录等资源。