centos redis安装

1 下载安装包redis-5.0.5.tar.gz 到目录 /home/tools

cd /home/tools
wget https://download.redis.io/releases/redis-5.0.5.tar.gz

2 减压

tar -zxvf redis-5.0.5.tar.gz

3 安装GCC 编译环境

yum install gcc-c++ 

4 进入到redis-5.0.5 目录 进行安装

make && make install

5配置redis

1 在此/home/tools/redis-5.0.5/utils 目录下redis_init_script 拷贝到/etc/init.d 作为开机启动
 cp redis_init_script /etc/init.d/
2 创建 /usr/local/redis ,存放配置文件
mkdir /usr/local/redis
3 拷贝配置文件到 /usr/local/redis 下
cp /home/tools/redis-5.0.5/redis.conf /usr/local/redis/
4 修改redis.conf 配置文件
cd /usr/local/redis
ll
-rw-r--r--. 1 root root 61819 9月  27 21:25 redis.conf
vi redis.conf

修改 daemonize no -> daemonize yes,目的是为了让redis启动在linux后台运行

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

修改redis工作目录

# Note that you must specify a directory here, not a file name.
dir /usr/local/redis/working

修改如下内容,绑定IP改为 0.0.0.0 ,代表可以让远程连接,不收ip限制

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1
bind 0.0.0.0

最关键的是密码,默认是没有的,一定要设置

# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass redispwd

5 文件中redis_init_script的redis核心配置文件为如下:

vi /etc/init.d/redis_init_script

# 此处是配置reids开机自启动
#chkconfig: 22345 10 90
#description: Start and Stop redis

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis/redis.conf"

6 为redis启动脚本添加执行权限,随后运行启动redis:

chmod 777 redis_init_script
启动
./redis_init_script start
Starting Redis server...
36390:C 29 Sep 2022 17:18:18.327 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
36390:C 29 Sep 2022 17:18:18.327 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=36390, just started
36390:C 29 Sep 2022 17:18:18.327 # Configuration loaded

ok nice

你可能感兴趣的:(centos redis安装)