linux环境下redis安装和启动

redis安装

redis下载方式

  1. 进入到/usr/local目录后使用wget从网上下载redis安装包
wget http://download.redis.io/releases/redis-4.0.1.tar.gz
  1. 从官网下载 https://redis.io/download 拷贝到/usr/local 目录

解压下载下来的压缩包

cd /usr/local
tar redis-4.0.1.tar.gz

进入目录安装

cd /usr/local/redis-4.0.1
make test
make install

执行完上诉命令安装后,redis所有的相关文件都会安装到当前目录下,其中,可执行文件redis-server或者redis-cli等都位于src目录下。

启动redis服务

  • . 在src目录下直接执行redis-server即可启动服务,这种方式启动的redis服务是在前台运行的,退出命令行工具后,redis服务就停止了。我们希望redis在后台运行。
[root@redis_01 redis]# redis-server /etc/redis/sentinel.conf --sentinel
7980:X 23 Nov 18:02:41.348 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 7980
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               
 
7980:X 23 Nov 18:02:41.355 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
7980:X 23 Nov 18:02:41.355 # Sentinel runid is 43de323d55627d896b2caf1da2e305f0eb59dcee
7980:X 23 Nov 18:02:41.356 # +monitor master mymaster 127.0.0.1 6379 quorum 1
^C7980:signal-handler (1448273325) Received SIGINT scheduling shutdown...
7980:X 23 Nov 18:08:45.618 # User requested shutdown...
7980:X 23 Nov 18:08:45.618 # Sentinel is now ready to exit, bye bye...

  • . 通过nohub方式启动,
nohub redis-server /etc/redis/sentinel.conf --sentinel >> /var/log/redis.log&

启动服务后,命令行会退出,并且将日志文件输出到/var/log目录下的redis.log文件中

  • . 修改配置文件在sentinel.conf文件中加入下面的配置
daemonize yes
logfile "/var/log/sentinel_log.log"

然后通过sentinel启动redis-server /usr/local/redis-4.0.1/sentinel.conf --sentinel

后面的两种启动方式都会以后台的方式启动。如果不需要--sentinel通过sentinel启动,修改的配置文件就是redis.conf

你可能感兴趣的:(linux环境下redis安装和启动)