.
redis是开源的,C语言开发的,安装步骤:先下载源码,再编译(依赖gcc环境),再安装设置
检查是否安装gcc环境
-
[root@VM_0_16_centos ~]
# rpm -qa|grep gcc*
-
//无则安装。
-
[root@VM_0_16_centos ~]
# yum install gcc-c++
创建目录,下载源码(通过华为镜像),解压源码
-
[root@VM_0_16_centos redis]
# mkdir /usr/lib/redis
-
[root@VM_0_16_centos redis]
# cd /usr/lib/redis/
-
[root@VM_0_16_centos redis]
# wget https://mirrors.huaweicloud.com/redis/redis-5.0.5.tar.gz
-
[root@VM_0_16_centos redis]
# tar -zxvf redis-5.0.5.tar.gz
进入文件夹,编译
-
[root@VM_0_16_centos redis]
# cd ./redis-5.0.5/
-
[root@VM_0_16_centos redis-5.0.5]
# make
编译成功
安装,并检查是否安装了服务
-
[root@VM_0_16_centos redis-5.0.5]
# make PREFIX=/usr/local/redis install
-
//查看是否有此服务
-
[root@VM_0_16_centos bin]
# ls /usr/local/redis/bin
-
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
把解压目录下配置文件复制到安装路径下
[root@VM_0_16_centos usr]# cp /usr/lib/redis/redis-5.0.5/redis.conf /usr/local/redis/
由于前端启动模式启动后不可以随意关闭(进程断开),所以需要配置后端模式启动
修改后端启动(即守护进程开启),取消ip绑定
-
[root@VM_0_16_centos ~]
# vim /usr/local/redis/redis.conf
-
注释掉
bind 127.0.0.1
-
#bind 127.0.0.1
-
-
更改protected-mode yes为
-
protected-mode no
-
-
更改daemonize no为
-
daemonize yes
-
-
设置密码
-
requirepass 要很长的密码
启动,并指定配置文件
-
[root@VM_0_16_centos ~]
# cd /usr/local/redis/
-
[root@VM_0_16_centos redis]
# ./bin/redis-server ./redis.conf
-
1675:C 15 Sep 2019 22:50:52.157
# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
-
1675:C 15 Sep 2019 22:50:52.157
# Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1675, just started
-
1675:C 15 Sep 2019 22:50:52.157
# Configuration loaded
通过端口(6379)查看服务是否启动
-
[root@VM_0_16_centos redis]
# ps -ef|grep redis
-
root 1676 1 0 22:50 ? 00:00:00 ./bin/redis-server *:6379
-
root 1900 1219 0 22:52 pts/6 00:00:00 grep --color=auto redis
本地客户端连接和redis服务关闭
-
[root@VM_0_16_centos redis]
# ./bin/redis-cli
-
127.0.0.1:6379> eixt
-
[root@VM_0_16_centos redis]
# ./bin/redis-cli shutdown
通过外部(ip)连接,(需要开放云服务器相应端口)
-
[root@VM_0_16_centos redis]
# ./bin/redis-cli -h 49.ip.ip.2 -p 6379 -a 密码
-
Warning: Using a password
with
'-a'
or
'-u' option on the command line interface may
not be safe.
-
49.ip.ip
.2:
6379>