redis安装

编译环境安装及基础软件包

  1. yum -y install gcc gcc-c++ make vim net-tools wget

下载

  1. wget https://download.redis.io/releases/redis-6.2.7.tar.gz

解包

   1 tar zxf redis-6.2.7.tar.gz

编译安装

  1. cd redis-6.2.7
  2. make
  3. make install PREFIX=/usr/local/redis

 

配置服务器

  1. [root@localhost redis-6.2.7]# ./utils/install_server.sh #执行会报错
  2. Welcome to the redis service installer
  3. This script will help you easily set up a running redis server
  4. This systems seems to use systemd.
  5. Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
  6. [root@localhost redis-6.2.7]# vim ./utils/install_server.sh
  7. 将77行到83行内容全部注释
  8. [root@localhost redis-6.2.7]# ln -s /usr/local/redis/bin/* /usr/local/bin/ #将redis执行放入到PATH变量的搜索路径中,从而就可以直接执行里面的命令

 

 

  1. [root@localhost redis-6.2.7]# ./utils/install_server.sh #一路回车
  2. Welcome to the redis service installer
  3. This script will help you easily set up a running redis server
  4. Please select the redis port for this instance: [6379]
  5. Selecting default: 6379
  6. Please select the redis config file name [/etc/redis/6379.conf]
  7. Selected default - /etc/redis/6379.conf
  8. Please select the redis log file name [/var/log/redis_6379.log]
  9. Selected default - /var/log/redis_6379.log
  10. Please select the data directory for this instance [/var/lib/redis/6379]
  11. Selected default - /var/lib/redis/6379
  12. Please select the redis executable path [/usr/local/bin/redis-server]
  13. Selected config:
  14. Port : 6379
  15. Config file : /etc/redis/6379.conf #redis服务器的主配置文件
  16. Log file : /var/log/redis_6379.log #日志文件
  17. Data dir : /var/lib/redis/6379 #数据库存放目录
  18. Executable : /usr/local/bin/redis-server #服务器执行文件
  19. Cli Executable : /usr/local/bin/redis-cli
  20. Is this ok? Then press ENTER to go on or Ctrl-C to abort.
  21. Copied /tmp/6379.conf => /etc/init.d/redis_6379
  22. Installing service...
  23. Successfully added to chkconfig!
  24. Successfully added to runlevels 345!
  25. Starting Redis server...
  26. Installation successful!

启动redis

 

  1. redis-server& #后台运行redis服务器

显示server 1就是正常的

 使用本机进入redis数据

  1. redis-cli
  2. 127.0.0.1> set woniu wangan14 #新建一个key为woniu,value为wangan14
  3. 127.0.0.1> get woniu #获取key为woniu的value值
  4. "wangan14"

 

完成

 

 

 

 


版权声明:本文为ztx666ZTX原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。