安装配置

予早 2024-07-01 21:58:57
Categories: Tags:

安装

Redis for Windows

https://github.com/dmajkic/redis/releases

https://github.com/tporadowski/redis/releases

Redis from Source

注:Redis官方只有Linux版本,Redis for Windows为三方构建

yum install -y gcc tcl
yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
wget https://download.redis.io/releases/redis-6.2.7.tar.gz
tar -xzf redis-6.2.7.tar.gz
cd redis-6.2.7
make MALLOC=libc
make & make install
# 如果缺少依赖就编译一下依赖
make install_bin install_include install_lib


# 如果根目录下没有
# redis-server
# redis-benchmark
# redis-cli
# 就清理后重新执行make过程
# make clean
# 默认端口6379
# 下载源码解压,redis.conf为配置文件
# 需要gcc进行编译
# 需要make
# 在redis文件夹中使用make
# make install验证
# 默认安装路径
# /usr/local/bin
# 复制配置文件到当前目录
# 可以配置改为守护进程
# redis-server redis.conf
# reis-cli -p 6379
# ps -ef|grep redis
# ps -aux|grep redis

默认的安装路径是在/usr/local/bin目录下

Redis Docker Image

docker pull redis:6.2.7

Redis From Binary

注意Ubuntu的Codename,使用lsb_release -a查看

https://redis.io/download/#redis-stack-downloads

配置

# 新建一个系统服务文件
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-6.2.6/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重载系统服务

systemctl daemon-reload

启动开机自启

# 启动
systemctl start redis
# 停止
systemctl stop redis
# 重启
systemctl restart redis
# 查看状态
systemctl status redis
# 开机自启
systemctl enable redis