(一)Redis学习—安装Redis
一、介绍
官网介绍(英文)
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster
官网介绍(中文)
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件。 它支持多种类型的数据结构,如 字符串(strings), 散列(hashes), 列表(lists), 集合(sets), 有序集合(sorted sets) 与范围查询, bitmaps, hyperloglogs 和 地理空间(geospatial) 索引半径查询。 Redis 内置了 复制(replication),LUA脚本(Lua scripting), LRU驱动事件(LRU eviction),事务(transactions) 和不同级别的 磁盘持久化(persistence), 并通过 Redis哨兵(Sentinel)和自动 分区(Cluster)提供高可用性(high availability)。
二、安装
-
安装
yum install wget
-
下载redis压缩包
wget https://download.redis.io/releases/redis-6.2.5.tar.gz
-
在redis目录下
make
-
可以直接启动
./reids-server
-
但是一版都是把redis变成服务 开机自启动
-
把服务安装到指定目录下
make install PREFIX=/opt/redis6
-
设置REDIS_HOME
vi /etc/profile
- 在最下面添加这两行
export REDIS_HOME=/opt/redis6
export PATH= P A T H : PATH: PATH:REDIS_HOME/bin - 刷新
source /etc/profile
- 查看是否配置采购
echo $PATH
我这显示结果/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/redis6/bin
-
cd到redis下的utils目录下
./install_server.sh
此时会报错Welcome to the redis service installer This script will help you easily set up a running redis server 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!
处理方式:
-
打开install_server.sh,注释掉下面的内容
vi install_server.sh
#_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 #unset _pid_1_exe
-
-
继续
./install_server.sh
这里一路回车就是使用默认端口6379和默认路径
[root@zhow utils]# ./install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] Selected default - /etc/redis/6379.conf Please select the redis log file name [/var/log/redis_6379.log] Selected default - /var/log/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] Selected default - /var/lib/redis/6379 Please select the redis executable path [/opt/redis6/bin/redis-server] Selected config: Port : 6379 Config file : /etc/redis/6379.conf Log file : /var/log/redis_6379.log Data dir : /var/lib/redis/6379 Executable : /opt/redis6/bin/redis-server Cli Executable : /opt/redis6/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful!
-
这里安装完就已经启动了,可以使用
ps -ef|grep redis
查看是否启动,也可以使用service redis_6379 status/start/stop
查看、开关