CentOS7.5安裝Redis3.0.0

redis,咱們經常使用來作緩存,也是著名的nosql存儲中間件。html

信息統計

  • 下載地址:暫無。
  • 軟件版本: redis-3.0.0
  • 安裝地址: /usr/setup/redis-3.0.0
  • 配置文檔地址: /usr/setup/redis-3.0.0/redis.conf
  • 佔用端口:6379
  • 用戶名和密碼:無

安裝

  • 安裝gcc編譯工具包
[root@redis01 ~]# yum update -y
[root@redis01 ~]# yum install -y gcc
複製代碼
  • 解壓
[root@redis01 ~]# tar zxf /opt/packages/redis-3.0.0.tar.gz -C /opt/unziped/
複製代碼
  • 建立文件夾
[root@redis01 ~]# mkdir -p /usr/setup/redis-3.0.0
[root@redis01 ~]# mkdir /usr/setup/redis-3.0.0/log
[root@redis01 ~]# mkdir /usr/setup/redis-3.0.0/data
複製代碼
  • 進入解壓後的redis目錄並執行make命令
[root@redis01 ~]# cd /opt/unziped/redis-3.0.0/
[root@redis01 redis-3.0.0]# make
複製代碼
  • 執行安裝命令
[root@redis01 redis-3.0.0]# make install PREFIX=/usr/setup/redis-3.0.0
cd src && make install
make[1]: 進入目錄「/opt/unziped/redis-3.0.0/src」

Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: 離開目錄「/opt/unziped/redis-3.0.0/src」 複製代碼
  • 拷貝配置文件
[root@redis01 redis-3.0.0]# cp /opt/unziped/redis-3.0.0/redis.conf /usr/setup/redis-3.0.0
複製代碼
  • 打開守護進程運行模式
// 修改配置文件,將daemonize的值改成yes
[root@redis01 redis-3.0.0]# vi /usr/setup/redis-3.0.0/redis.conf
daemonize yes
複製代碼
  • 加入開機自啓
[root@redis01 redis-3.0.0]# cd /opt/unziped/redis-3.0.0/utils/
[root@redis01 utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/setup/redis-3.0.0/redis.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/setup/redis-3.0.0/log/redis.log
Please select the data directory for this instance [/var/lib/redis/6379] /usr/setup/redis-3.0.0/data/6379
Please select the redis executable path [] /usr/setup/redis-3.0.0/bin/redis-server
Selected config:
Port           : 6379
Config file    : /usr/setup/redis-3.0.0/redis.conf
Log file       : /usr/setup/redis-3.0.0/log/redis.log
Data dir       : /usr/setup/redis-3.0.0/data/6379
Executable     : /usr/setup/redis-3.0.0/bin/redis-server
Cli Executable : /usr/setup/redis-3.0.0/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
複製代碼
  • 開啓端口,並重啓防火牆
$ firewall-cmd --zone=public --permanent --add-port=6379/tcp
$ firewall-cmd --reload
複製代碼
  • 重啓後測試
1. 本機鏈接測試
$ cd /usr/setup/redis-3.0.0/bin/
$ ./redis-cli
127.0.0.1:6379> info

2. 開發機鏈接測試
cmd: redis-cli.exe -h 10.168.0.120 -p 6379
複製代碼

簡單使用

./redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set a 10
OK
127.0.0.1:6379> get a
"10"
127.0.0.1:6379> incr a
(integer) 11
127.0.0.1:6379> get a
"11"
127.0.0.1:6379> decr a
(integer) 10
127.0.0.1:6379> keys *
1) "a"
127.0.0.1:6379> del a
(integer) 1
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> exit // 關閉客戶端
複製代碼

參考連接

  1. www.cnblogs.com/zhang-ke/p/…
  2. blog.csdn.net/sjhuangx/ar…
  3. redis.io/
  4. www.ruanyifeng.com/blog/2016/0…
  5. blog.csdn.net/amandalm/ar…

推薦閱讀

送你一本Java程序員運維技能手冊。在這程序員

相關文章
相關標籤/搜索