MySQL, Oracle, Linux, 软件架构及大数据技术知识分享平台

网站首页 > 精选文章 / 正文

redis安装(源码编译安装)(redis 编译安装)

2025-03-28 17:03 huorong 精选文章 2 ℃ 0 评论

删除安装的redis

#这个命令用于检查系统中是否已经安装了 Redis

rpm -qa|grep -i redis

#若有,删除。 xxx 代表的是待删除的 Redis 相关软件包的名称

yum remove xxx

安装

#安装 GCC 编译器,可能是为了后续编译 Redis 时使用

yum install gcc

#解压 redis 的源代码包文件

tar -zxvf redis-6.2.1.tar.gz

#redis 源代码文件夹移动到 /usr/local 目录下并进入该目录

mv redis-6.2.1 /usr/local/

cd /usr/local/redis-6.2.1/

#编译(使用 jemalloc编译redis)、安装

make MALLOC=jemalloc && make install

#查看脚本,注释掉systemd服务的相关判断,采用service + chkconfig方式进行服务配置

vi install_server.sh

#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
#unset _pid_1_exe

#运行服务化管理

运行服务化管理,可以使用统一的一套命令、管理服务的生命周期开机启动,监控

cd utils/ && sh install_server.sh

#编辑系统文件

vi /etc/systemd/system/redis_6379.service

[Unit]
Description =Redis on port 6379
[Service]
Type=forking #启动后立即退出,但仍然在后台运行
ExecStart=/etc/init.d/redis_6379 start #启动服务时执行的命令
ExecStop=/etc/init.d/redis_6379 stop #停止服务时执行的命令
[Install]
WantedBy=multi-user.target

#编辑配置文件

vi /etc/redis/6379.conf

bind 0.0.0.0 # 接受所有来自于可用网络接口的连接
requirepass xxxxxx #密码
port 6379 #端口
daemonize yes #守护进程

#创建客户端命令的软连接(redis 的redis-cli工具 添加到系统的可执行路径中

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

#启动服务、停止服务

service redis_6379 start

service redis_6379 stop

#通过redis客户端连接redis服务

redis-cli -a 密码(本地连接)

redis-cli -h ip地址 -p 6379-a xxxxxx

#关闭连接

>shutdown

Tags:redis客户端

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言