centos7 redis installation tutorial

1. Download unzip

  # Download to / home / install (after downloading or uploading windows system)

  mkdir /home/install

  cd /home/install

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

  # Unzip

  tar -zxvf redis-4.0.11.tar.gz 

  #mobile

  mv redis-4.0.11 /usr/local/redis

2. compile and install

  cd /usr/local/redis

  make && make install

  # Src directory to see if the tools generate redis

  ll /usr/local/redis/src/

  

3.redis.conf (details refer to the official website of each line comment)

  vim /usr/local/redis/redis.conf

  # Modify the following lines of information

  0.0.0.0 the bind # ip and does not restrict access to remote connections

  the MODE NO-protected # protected mode

  yes daemonize # running in the background thread

4. Start

  # Start command

  /usr/local/redis/src/redis-server /usr/local/redis/redis.conf

  # View is running

  ps -ax | grep Redis

  

5. Connection Test

  / usr / local / Redis / the src / CLI Redis -p-6379 --raw # Chinese display connection instruction --raw

  set name 'Ding Jie'

  set sex 'female'

  get name

  get sex

  

 

 6. boot

  (1) Edit the file redis.service

    cd / usr / lib / systemd / System  # to enter the service file directory

    vim ./redis.service #因为有的机器需部署多个redis这里以redis+端口号命名

    加入如下内容   

[Unit]

Description=redis
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecReload=/usr/local/redis/src/redis-cli -p 6379 shutdown | /usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/src/redis-cli -p 6379 shutdown
[Install]
WantedBy=multi-user.target

  (2)生效

    systemctl daemon-reload

  (3)改变文件权限

    chmod 777 ./redis.service 

  (4)建立软连接

    ln -s /usr/lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service

  (5)systemctl开机启动redis

    systemctl enable redis.service 

    或

    systemctl enable redis

  (6)systemctl取消开机启动redis

    systemctl disable redis.service

  (7)systemctl启动redis

    systemctl start redis.service

  (8)systemctl重启redis

    systemctl restart redis.service

  (9)systemctl停止redis

    systemctl restart redis.service

  (10)systemctl查看redis状态

    systemctl status redis.service

1.下载解压

  #下载至/home/install(或windows系统下载后上传)

  mkdir /home/install

  cd /home/install

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

  #解压

  tar -zxvf redis-4.0.11.tar.gz 

  #移动

  mv redis-4.0.11 /usr/local/redis

2.编译安装

  cd /usr/local/redis

  make && make install

  #查看src目录是否生成redis相关工具

  ll /usr/local/redis/src/

  

3.redis.conf(详情官网参考每行注释)

  vim /usr/local/redis/redis.conf

  #修改如下几行信息

  bind 0.0.0.0#不限制访问ip和远程连接

  protected-mode no#保护模式

  daemonize yes#后台运行线程

4.启动

  #启动命令

  /usr/local/redis/src/redis-server /usr/local/redis/redis.conf

  #查看是否运行

  ps -ax|grep redis

  

5.连接测试

  /usr/local/redis/src/redis-cli -p 6379 --raw #连接指令  --raw中文显示

  set name '丁洁'

  set sex '女'

  get name

  get sex

  

 

 6.开机启动

  (1)编辑redis.service文件

    cd /usr/lib/systemd/system #进入service文件目录

    vim ./redis.service #因为有的机器需部署多个redis这里以redis+端口号命名

    加入如下内容   

[Unit]

Description=redis
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecReload=/usr/local/redis/src/redis-cli -p 6379 shutdown | /usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/src/redis-cli -p 6379 shutdown
[Install]
WantedBy=multi-user.target

  (2)生效

    systemctl daemon-reload

  (3)改变文件权限

    chmod 777 ./redis.service 

  (4)建立软连接

    ln -s /usr/lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service

  (5)systemctl开机启动redis

    systemctl enable redis.service 

    或

    systemctl enable redis

  (6)systemctl取消开机启动redis

    systemctl disable redis.service

  (7)systemctl启动redis

    systemctl start redis.service

  (8)systemctl重启redis

    systemctl restart redis.service

  (9)systemctl停止redis

    systemctl restart redis.service

  (10)systemctl查看redis状态

    systemctl status redis.service

Guess you like

Origin www.cnblogs.com/xiaoyaojinzhazhadehangcheng/p/12163114.html