redis部署

redis部署

一、环境

操作系统:Centos8.4 x86
操作用户:root
gcc版本:8.5.0
Redis版本:6.2.6

[root@cloud ~]# cat /etc/redhat-release 
CentOS Linux release 8.2.2004 (Core) 
[root@cloud ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) 
[root@cloud ~]# 

二、创建存放路径、下载、解压、编译安装包

1、创建存放路径

mkdir -p /usr/local/redis
cd /usr/local/redis

2、下载redis安装包

wget https://download.redis.io/releases/redis-6.2.6.tar.gz

3、解压

tar -xf redis-6.2.6.tar.gz && cd redis-6.2.6

4、编译

make
make install PREFIX=/usr/local/redis

5、复制编译后的配置文件,并修改

cp /usr/local/redis/redis-6.2.6/redis.conf /usr/local/redis/bin/
vim +75 /usr/local/redis/bin/redis.conf
75行  bind 127.0.0.1 -::1  修改为 →  bind  0.0.0.0 -::1
258行  daemonize no  修改为 →   daemonize yes 
903行 修改为自己的密码

三、通过systemctl管理redis服务,配置文件

1、添加服务管理的配置文件

vim /lib/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
#根据自己的情况修改为实际路径
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

2、启动服务、查看状态、设置开机自启

systemctl start redis.service
systemctl enable redis.service
systemctl status redis.service

四、创建软链,设置redis-cli为全局命令

ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
ln -s /usr/local/redis/bin/redis-cli /usr/sbin/redis-cli

五、验证登录Redis

redis-cli -h 127.0.0.1 -p 6379 -a "your password"

至此,部署完成。

posted @ 2023-06-21 18:08  赵财进宝  阅读(30)  评论(0编辑  收藏  举报