Reids单机版本搭建

前言

  1. 简单粗暴复制黏贴搭建好 Redis,末尾有常见问题处理方式。

步骤

  1. 第一步 下载、解压
  2. 第二步 编译前环境准备工作
  3. 第三步 编译、编译安装
  4. 第四步 执行install_server.sh
  5. 第五步 查看 Redis 已经启动
  6. 第六步 开启远程连接
  7. 第七步 常用命令
  8. 第八步 常用参数
  9. 第九步 连接工具
  10. 第十步 错误解决 经典

第一步 下载、解压

  1. 下载
wget http://download.redis.io/releases/redis-6.0.6.tar.gz
  1. 解压
tar -zxvf redis-6.0.6.tar.gz 
  1. 进reids 目录cd
cd /root/redis-6.0.6

第二步 编译前环境准备工作

  1. 更新 git 版本
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
gcc -v
  1. 修改下配置文件, 注释一部分代码
vim ./utils/install_server.sh

#bail if this system is managed by systemd
#_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

第三步 编译、编译安装

  1. 编译 make
  2. 编译安装 make install
# 安装结果
Hint: It's a good idea to run 'make test' ;)
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

第四步 执行install_server.sh

  1. 命令 utils/install_server.sh
# 配置信息记录
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

第五步 查看 Redis 已经启动

# 命令 ps -ef | grep redis

root      28206      1  0 07:51 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379
root      28454  21344  0 07:51 pts/0    00:00:00 grep --color=auto redis

第六步 开启远程连接

  1. 默认的配置文件进行修改 vim /etc/redis/6379.conf
  2. 开发远程登录 0.0.0.0 表示任意ip都可以访问。
bind 127.0.0.1  改为 bind 0.0.0.0 
  1. 后台启动
daemonize yes
  1. 重启 -> 先关闭,后启动。

第七步 常用命令

作用命令
server启动src/redis-server /etc/redis/6379.conf
server关闭src/redis-cli shutdown
client启动src/redis-cli -h 指定ip -p 指定端口 -a 指定密码

第八步 常用参数

作用命令
设置reids密码redis-cli 执行 config set requirepass password
redis-cli输入密码redis-cli 执行 auth password

第九步 连接工具

https://gitee.com/MaxBill/RedisPlus

第十步 错误解决 经典

  1. 经典 https://www.cnblogs.com/operationhome/p/10342258.html
  2. 经典 https://www.codenong.com/cs106279492
  3. 经典 http://iambigboss.top/post/76332_1_1.html

错误1

You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/root/Redis/redis-5.0.5/src'
make: *** [test] Error 2
解决:yum install tcl
make distclean  && make

错误2

make[1]: *** [server.o] 错误 1
make[1]: 离开目录“/root/redis-6.0.8/src”
make: *** [all] 错误 2
原因:GCC版本太低了

解决方法:升级到最新的 9.x.x版本
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
gcc -v

错误3

Welcome to the redis service installer
This script will help you easily set up a running redis server

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!

解决方法:修改下配置文件, 注释一部分代码

vim ./utils/install_server.sh

#bail if this system is managed by systemd
#_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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值