[Share Experiences] deepin UOS 编译安装 Redis
Tofloor
poster avatar
deepin小助手
Super Moderator
OM
2023-08-08 23:59
Author

转载自:李昊哲小课

升级系统

sudo apt update
sudo apt -y dist-upgrade

安装常用软件

sudo apt -y install vim net-tools wget gcc make lrzsz

下载安装包

wget https://download.redis.io/redis-stable.tar.gz

解压缩安装包

tar -zxvf redis-stable.tar.gz

进入解压目录后编译安装

cd redis-stable
sudo make PREFIX=/usr/local/redis install

创建配置文件目录

sudo mkdir -p /usr/local/redis/conf

拷贝配置文件模板

sudo cp redis.conf /usr/local/redis/conf/

修改配置文件

sudo vim /usr/local/redis/conf/redis.conf
#修改绑定IP
bind 0.0.0.0
#修改启动方式为多线程模式
daemonize yes
#设置密码 requirepass foobared
requirepass 123456

修改服务启动文件

cd /lib/systemd/system
sudo vim redis.service

服务启动文件内容

[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重新加载service文件

sudo systemctl daemon-reload 

启动redis

sudo systemctl start redis
1

开机自启动redis

sudo systemctl enable redis

测修改环境变量

sudo vim /etc/profile
1
export REDIS_HOME=/usr/local/redis
export PATH=$PATH:$REDIS_HOME/bin

测试

redis-cli
AUTH 123456
info server

连接远程服务器 -h 远程服务器地址 -p 远程服务器端口号 --raw 避免中文乱码

redis-cli -h localhost -p 6379 --raw 


#检测redis服务是否启动 正常启动后响应信息为pong
ping


#查看信息 info [section]
info


#查看服务器信息
info Server

Redis添加认证

#修改配置文件
sudo vim /etc/redis/redis.conf
#将配置文件中bing 127.0.0.1 ::1修改为bind 0.0.0.0 0:0:0:0:0:0:0:0指定任意主机都可以访问
#将配置文件中requirepass foobared 去掉注释 foobared修改为修改后的密码,例如requirepass 123456
#保存修改后的配置文件重启redis服务
sudo systemctl restart redis
#连接远程服务器 -h 远程服务器地址 -p 远程服务器端口号 -a 密码
redis-cli -h localhost -p 6379 --raw -a "123456"
#无密码连接远程服务器 -h 远程服务器地址 -p 远程服务器端口号
redis-cli -h localhost -p --raw 6379
#连接成功后 使用密码认证 auth 密码 提示OK通过认证
auth 123456

#或者使用config命令
config set requirepass 123456
config get requirepass

*风险提醒:若编译过程中遇到问题,欢迎在论坛中讨论或查阅官方文档

Reply Favorite View the author
All Replies
多啦
deepin
2023-08-09 00:11
#1

这种帖子为啥要置顶。。。百度一搜一大堆。

Reply View the author
爱开发
deepin
2023-08-09 02:32
#2

docker 打天下…

Reply View the author
来自Ubuntu的某位用户
deepin
2023-08-09 03:12
#3
多啦

这种帖子为啥要置顶。。。百度一搜一大堆。

百度搜索很难一下就搜索到一篇好资料,如果浏览器没有安装washbaidu插件,很容易满屏广告

要不是国家扶持,百度早就倒闭了

搜索引擎建议使用Fsearch,“中国版Google搜索”

Reply View the author
LuijpCN
deepin
2023-08-09 03:15
#4

其实比较好奇,apt多方便,为啥很多人喜欢编译安装...

Reply View the author
berners
deepin
2023-08-09 03:30
#5
来自Ubuntu的某位用户

百度搜索很难一下就搜索到一篇好资料,如果浏览器没有安装washbaidu插件,很容易满屏广告

要不是国家扶持,百度早就倒闭了

搜索引擎建议使用Fsearch,“中国版Google搜索”

这个不是搜索本地文件的吗?

Reply View the author
爱开发
deepin
2023-08-09 03:32
#6
LuijpCN

其实比较好奇,apt多方便,为啥很多人喜欢编译安装...

apt的版本往往不是最新的。

Reply View the author
mzcc
deepin
2023-08-09 06:55
#7
爱开发

apt的版本往往不是最新的。

但是你也没用到啥新特性呀

Reply View the author
来自Ubuntu的某位用户
deepin
2023-08-09 15:53
#8
berners

这个不是搜索本地文件的吗?

用浏览器打开这个网址

https://fsoufsou.com/

在搜索框里输入需要上网搜索的内容就可以了

Reply View the author
爱开发
deepin
2023-08-09 17:56
#9
mzcc

但是你也没用到啥新特性呀

我也没说redis啊,其它软件有些会低一个大版本…

Reply View the author
软件技术就是生产力
deepin
2023-08-09 22:56
#10
The user is banned, and the content is hidden.
软件技术就是生产力
deepin
2023-08-09 22:58
#11
The user is banned, and the content is hidden.
LuijpCN
deepin
2023-08-10 04:21
#12
软件技术就是生产力
The user is banned, and the content is hidden.

如果apt源太老,你就算是手动编译了,小版本一般问题不大,一些大版本也可能因为底层库的原因运行不起来。。。

最后docker解决了😂

Reply View the author
软件技术就是生产力
deepin
2023-08-10 23:10
#13
The user is banned, and the content is hidden.
raspbian
deepin
2023-08-13 17:53
#14
LuijpCN

其实比较好奇,apt多方便,为啥很多人喜欢编译安装...

能安装最新或者需要的版本

能把软件安装到合适的位置

Reply View the author
STAND-ALONE
deepin
2023-11-02 02:37
#15
LuijpCN

其实比较好奇,apt多方便,为啥很多人喜欢编译安装...

我看到了,一定要回复一下。

apt,yum这些是方便。

但是不能联网的苦我希望你不要尝试。

Reply View the author