阿里云Linux下安装Redis

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hunandexingkong/article/details/78791485
https://redis.io/download  查找最新版本

进入专用下载目录:
tar -zxvf redis-4.0.6.tar.gz
cd redis-4.0.6
make     #编译源码

mkdir -p /usr/local/redis
make PREFIX=/usr/local/redis install   #/usr/local/redis  下生成bin目录

拷贝配置文件
cp /home/downloads/redis-4.0.6/redis.conf /usr/local/redis/

vim /usr/local/redis/redis.conf
daemonize yes--开启后台守护进程

启动服务

/usr/local/redis/bin

./redis-server ../redis.conf
[root@iZ2ze2aj5tzdkvlx1frzi7Z bin]# ./redis-server ../redis.conf
6761:C 06 Dec 18:01:08.055 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6761:C 06 Dec 18:01:08.056 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=6761, just started
6761:C 06 Dec 18:01:08.056 # Configuration loaded

lsof
[root@iZ2ze2aj5tzdkvlx1frzi7Z bin]# lsof
-bash: lsof: command not found
yum install lsof   #安装
lsof -i :6379 
netstat -antup | grep 6379

[root@iZ2ze2aj5tzdkvlx1frzi7Z bin]# redis-cli
-bash: redis-cli: command not found
[root@iZ2ze2aj5tzdkvlx1frzi7Z bin]# ./redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>

开放端口

vim /etc/sysconfig/iptables  

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT     #添加 

service iptables restart   #重启防火墙  

保存退出后
    systemctl restart iptables.service #重启防火墙使配置生效
    systemctl enable iptables.service #设置防火墙开机启动

在阿里云开启入方向端口6379 

猜你喜欢

转载自blog.csdn.net/hunandexingkong/article/details/78791485