Linux(debian)安装Redis教程

版权声明:创业:https://shop120085695.taobao.com https://blog.csdn.net/zxf1242652895/article/details/82771698

1.下载redis压缩包 

  http://download.redis.io/releases/redis-4.0.9.tar.gz(如果是其他版本的话可以直接修改后面的版本编号就可以)

2.将压缩包放在你需要安装的目录

3 。解压 压缩包

cd /opt/  tar xzf redis-4.0.9.tar.gz

4.解压后 就会如上图一样 生成一个redus-4.0.10文件夹

5 cd /opt/redis-4.0.10/make(这里需要差不多20s)

6.等make 编译后 进入src 目录

分别执行下:  /opt/redis-4.0.10/src$ ./mkreleasehdr.sh

                       /opt/redis-4.0.10/src$ ./redis-benchmark

                      /opt/redis-4.0.10/src$ ./redis-check-aof

                      /opt/redis-4.0.10/src$ ./redis-cli

                       /opt/redis-4.0.10/src$ ./redis-server

7.应该会出现下面个图形界面

cd /usr/local/redis/bin/
./redis-server
18847:C 28 May 19:14:10.117 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18847:C 28 May 19:14:10.118 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=18847, just started
18847:C 28 May 19:14:10.118 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 4.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 18847
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

18847:M 28 May 19:14:10.120 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18847:M 28 May 19:14:10.120 # Server initialized
18847:M 28 May 19:14:10.120 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
18847:M 28 May 19:14:10.120 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
18847:M 28 May 19:14:10.120 * Ready to accept connections

将redis作为linux service启动

systemctl管理Redis启动、停止、开机启动

  • 在/lib/systemd/system目录下创建一个脚本文件redis.service
vim /lib/systemd/system/redis.service

#表示基础信息
[Unit]
#描述
Description=Redis
#在哪个服务之后启动
After=syslog.target network.target remote-fs.target nss-lookup.target

#表示服务信息
[Service]
Type=forking
#和redis.conf配置文件中的信息一致
PIDFile=/var/run/redis_6379.pid
#启动服务的命令
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

#安装相关信息
[Install]
WantedBy=multi-user.target

猜你喜欢

转载自blog.csdn.net/zxf1242652895/article/details/82771698
今日推荐