liunx下搭建Redis安装学习记录
Redis的官方下载网址是:http://redis.io/download (这里下载的是Linux版的Redis源码包)
下载liunx版本redis安装包redis-5.0.6.tar.gz文档包里面也有
第一先 在usr 目录下创建文件夹 redis
[root@VM-0-4-centos usr]# mkdir redis
使用xftp 把安装放到/usr/redis文件夹中
[root@VM-0-4-centos redis]# tar -zxvf redis-5.0.6.tar.gz
进入到解压目录 /usr/redis/redis-5.0.6下执行make 进行编译
[root@VM-0-4-centos redis-5.0.6]# make
如下:
安装 命令
[root@VM-0-4-centos redis-5.0.6]# make PREFIX=/usr/redis/redis-5.0.6 install
到了这里就完成安装了
Redis启动
// A code block
1启动服务器端
后台进入到这目录下 /usr/redis/redis-5.0.6/bin
注 :无法开启远程连接问题
[root@VM-0-4-centos bin]# ./redis-server redis.conf 备注:必须开启指定具体的配置文件
2 启动前端
从新打开一个控制台进入到 /usr/redis/redis-5.0.6/bin 目录下
[root@VM-0-4-centos bin]# ./redis-cli 启动前端操作
------------------------------------------------------------------------
[root@VM-0-4-centos bin]# ./redis-cli
127.0.0.1:6379> set name aaa
OK
127.0.0.1:6379> get name
"aaa"
127.0.0.1:6379> get name
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit 退出
-------------------------------------------------------------------------
redis设置后台启动
Redis后台的环境设置
// 进入到redis中的redis-5.0.6 目录下把redis.conf 拷贝到redis-5.0.6/bin 路径下
/usr/redis/redis-5.0.6
[root@VM-0-4-centos redis-5.0.6]# cp redis.conf /usr/redis/redis-5.0.6/bin/
修改redis.conf 进入redis.conf 把daemonize 改为yes
[root@VM-0-4-centos bin]# vim redis.conf
开启远程访问
然后 i 进入插入模式 修改完成后 按esc 退出编辑 然后输入wq 保存修改
然后 i 进入插入模式 修改完成后 按esc 退出编辑 然后输入wq 保存修改
查看reids有没有运行
[root@VM-0-4-centos bin]# ps -ef | grep redis
root 16661 1 0 11:36 ? 00:00:00 ./redis-server *:6379
root 16752 13609 0 11:37 pts/0 00:00:00 grep --color=auto redis
关闭redis 杀死进程
[root@VM-0-4-centos bin]# kill -9 16661
关闭redis 方法二、
[root@VM-0-4-centos bin]# ./redis-cli shutdown
#查看进程ps aux |grep redis
#杀掉进程kill -9 进程号
#查看相关文件find / -name “redis”
#删除文件rm -rf 文件
开启远程的端口号
/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
打开一个控制台进入到 /usr/redis/redis-5.0.6/bin 目录下
[root@VM-0-4-centos bin]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
用设置的redis.conf 启动redis服务器
[root@VM-0-4-centos bin]# redis-server ./redis.conf &
然后再次启动
[root@VM-0-4-centos bin]# ./redis-server
使用密码进入 客户端
[root@VM-0-4-centos bin]# ./redis-cli -h 139.199.223.230 -p 6379 -a root
客户端进入 (没有密码进入)
[root@VM-0-4-centos bin]# ./redis-cli
127.0.0.1:6379> config set requirepass root
ok
127.0.0.1:6379> set name aaaa
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth root
ok
127.0.0.1:6379> set name aaaa
OK
参考链接: https://www.cnblogs.com/hunanzp/p/12304622.html
开启远程访问参考:https://www.cnblogs.com/junjun511/p/11299575.html
RedisDesktopManager客户端连接远程/阿里云服务器(内网)的redis参考步骤:https://blog.csdn.net/xiaoguaihu12/article/details/99635907
带密码的reids登陆参考:https://www.cnblogs.com/herry52/p/5997041.html