当前位置:网站首页>centos 安装redis
centos 安装redis
2022-08-08 09:48:00 【java-zh】
一、下载redis
1)可以去官网手动下载
2)可以通过wget进行下载
#创建目录
mkdir /usr/redis
cd redis
wget http://download.redis.io/releases/redis-6.0.3.tar.gz
二、解压
tar -zxvf redis-6.0.3.tar.gz
三、编译
进入到解压的目录下面执行,比如我的目录
cd redis-6.0.3
make
1)、可能会出现错误1
该错误仅仅说明未安装gcc
2)安装gcc
yum install gcc
安装gcc中途会询问你是安装这个吗,输入y之后回车进行继续安装
安装好gcc以后继续执行make
3)可能会出现错误2
原因:CentOS7默认安装的是4.8.5,而redis6.0只支持5.3以上版本,这里将gcc升级到9
4)升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
5)gcc版本切换
scl enable devtoolset-9 bash
#查看gcc版本是否切换成功
gcc -v
6)重新编译
make install
四、启动redis
进入src文件夹,执行命令
./redis-server
五、安装后配置
安装成功之后这里建议你进行端口的修改,redis默认端口容易受到黑客攻击,进行挖矿行动,so,为了服务器的安全,还是修改端口号吧(别问我为什么知道,默默跟着改就行,我是不会骗你的)
把redis.conf 下载到本地进行修改简单方便
1)更改默认端口
由port 6379 改为 你自己定义的端口
2)以后台进程方式启动
修改daemonize no 为daemonize yes
3、设置redis远程连接
(1)先放行你设置的端口号,比如7000
#开放7000端口号
firewall-cmd --zone=public --add-port=7000/tcp --permanent
#配置立即生效
firewall-cmd --reload
(2)注释掉bind 127.0.0.1
(3)设置redis连接密码:在requirepass foobard改为requirepass 123456
123456就是你的密码,个人建议,密码可以设置复杂一点
4、启动redis,若你的redis已经启动,则先关闭,关闭方式有两种
#方式一
#关闭默认端口
./redis-cli shutdown
#方式二
#查看redis是否在运行
ps -aux | grep redis
kill -9 '线程号'
redis的启动,指定配置文件启动,进src目录下,输入命令
./redis-server /usr/redis/redis-6.0.3/redis.conf
本地进行连接测试
边栏推荐
- 【Collection】3. Wallpaper collection
- hdu4635 Strongly connected(tarjan计算强连通通分量+缩点+思想)
- 语音聊天app开发——对用户更具吸引力的设计
- Feign应用及源码剖析
- English token preprocessing, used to process English sentences into words
- A concise tutorial on expanding (increasing capacity) of VMWare Esxi virtual system data storage
- 移动端/嵌入式-CV模型-2018:MobileFaceNets
- Bytes and Characters and Common Encodings
- MySQL redo log和undo log
- ACWing 198. Antiprime Problem Solution
猜你喜欢
随机推荐
数据库不推荐使用外键的9个理由!
软考证书含金量
VPP静态映射实现DNAT
Recommended download software
MySQL中的锁机制详解
渗透测试-xss的三种类型讲解
English token preprocessing, used to process English sentences into words
Categorized input and output, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, go lang basic data types and input and output EP03
Detailed Explanation of Gradient Vanishing and Gradient Explosion Problems
Mysql数据库架构介绍
Excel中text函数5中常用方法
Pinia(一)初体验快速安装与上手
图像分割 总结
字节与字符与常见编码方式
Practical Case: Building Churn Prediction Models with PySpark ML
The keys of the Flutter storage database
实体List转为excel
Go 匿名字段与实现重写方法
记一次生产内存溢出分析解决
To make people's consumption safer, more assured and more satisfied