linux下centos7.2下安装redis 4.0.6
发布日期:2021-05-13 19:18:24 浏览次数:17 分类:精选文章

本文共 2137 字,大约阅读时间需要 7 分钟。

installation and startup of Redis

Installation of Redis

Step 1: Download Redis Installation Package

Use wget to download the latest Redis installation package:

wget http://download.redis.io/releases/redis-4.0.6.tar.gz

Step 2: Unzip the Compressed Package

Unzip the downloaded file using tar:

tar -zxvf redis-4.0.6.tar.gz

Step 3: Install GCC Dependencies

Install GCC using yum:

yum install gcc

Step 4: Enter the Redis Installation Directory

Move to the directory where Redis was unzipped:

cd redis-4.0.6

Step 5: Compile and Install Redis

Compile Redis with specific MALLOC library support and install:

make MALLOC=libccd src && make install

Redis Startup Methods

Method 1: Direct Startup

Run Redis in interactive mode:

./redis-server

This method requires constant screen attention.

Method 2: Running as a Daemon

Modify the Redis configuration (redis.conf) to enable daemon mode:

echo 'daemonize yes' >> redis.conf

Start Redis in daemon mode:

./redis-server /etc/redis/redis.conf

Method 3: Setting Redis to Start Automatically

  • Create a Redis directory in /etc/:
  • mkdir /etc/redis
    1. Create a configuration file in /etc/redis/6379.conf:
    2. cp /usr/local/redis-4.0.6/redis.conf /etc/redis/6379.conf
      1. Create a startup script in /etc/init.d/redisd:
      2. cp /usr/local/redis-4.0.6/utils/redisd /etc/init.d/redisd
        1. Enable Redis to start automatically:
        2. # Modify the first line of /etc/init.d/redisdecho '# chkconfig:2345 90 10' > /etc/init.d/redisdecho '# description: Redis is a persistent key-value database' >> /etc/init.d/redisd# Enable servicechkconfig redisd on

          Now Redis can be started and stopped using:

          service redisd start651service redisd stop

          Common Issues

          ###Port Access Issues

        3. Modify the Redis configuration to remove binding restrictions:
        4. # Remove or comment out bind 127.0.0.1# in /usr/local/redis-4.0.6/redis.conf
          1. Start Redis and ensure the port is accessible. If needed, adjust firewall rules:
          2. systemctl stop firewalld.servicesystemctl disable firewalld.service

            Service Management

            If the service fails to start due to PID file issues:

            rm /var/run/redis_6379.pid

            Note

            Refer to official Redis documentation for more details: Redis Documentation

    上一篇:vue部署在nginx后刷新404,nginx.conf一行代码解决掉
    下一篇:解决 MySQL 8.0 客户端连接 caching_sha2_password 问题

    发表评论

    最新留言

    留言是一种美德,欢迎回访!
    [***.207.175.100]2025年04月15日 17时29分20秒