Redis ubutnu18 04單機安裝配置

2021-09-25 05:47:23 字數 2851 閱讀 9031

安裝redis服務端

# apt-get install redis-server
檢查redis伺服器系統程序

# ps -agx|grep redis

13614 ? ssl 0:00 /usr/bin/redis-server 127.0.0.1:6379

13746 pts/6 s+ 0:00 grep --color=auto redis

檢視redis預設埠

# netstat -nlt|grep 6379

tcp 0 0 127.0.0.1:6379 0.0.0.0:* listen

tcp6 0 0 ::1:6379 :::* listen

通過啟動命令檢查redis伺服器狀態

# /etc/init.d/redis-server status

● redis-server.service - advanced key-value store

loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)

active: active (running) since sat 2019-07-13 12:55:35 cst; 14min ago

docs:

man:redis-server(1)

main pid: 13614 (redis-server)

tasks: 4 (limit: 4915)

cgroup: /system.slice/redis-server.service

└─13614 /usr/bin/redis-server 127.0.0.1:6379

7月 13 12:55:34 master systemd[1]: starting advanced key-value store...

7月 13 12:55:35 master systemd[1]: redis-server.service: can't open pid file /var/run/redis/redis-server.pid (yet?) after start: no such file or directory

7月 13 12:55:35 master systemd[1]: started advanced key-value store.

命令列客戶端訪問redis

# redis-cli

127.0.0.1:6379> help

redis-cli 4.0.9

to get help about redis commands type:

"help @" to get a list of commands in "help " for help on "help " to get a list of possible help topics

"quit" to exit

to set redis-cli preferences:

":set hints" enable online hints

":set nohints" disable online hints

set your preferences in ~/.redisclirc

預設情況下,訪問redis伺服器是不需要密碼的,為了增加安全性我們需要設定redis伺服器的訪問密碼。這裡我設定密碼為root506

# vim /etc/redis/redis.conf

#取消注釋requirepass

requirepass root506

讓redis伺服器被遠端訪問

# vim /etc/redis/redis.conf

#注釋bind

#bind 127.0.0.1

之後重啟redis

#  /etc/init.d/redis-server restart
不使用密碼登入redis

可以登入,但無法執行命令

# redis-cli

127.0.0.1:6379> keys *

(error) noauth authentication required.

使用密碼登入後,一切正常

# redis-cli -a root506

127.0.0.1:6379> keys *

1) "key1"

檢查埠發現由127.0.0.1變為0.0.0.0,表示可以遠端登入

# netstat -nlt|grep 6379

tcp 0 0 0.0.0.0:6379 0.0.0.0:* listen

tcp6 0 0 :::6379 :::* listen

另一台機器登入

# redis-cli -a root506 -h 192.168.1.11          

192.168.1.11:6379> keys *

1) "key1"

192.168.1.11:6379>

Ubuntu18 04 系統安裝

swap 4096 55g 需要放各種軟體 sudo apt get update sudo apt get install openssh server 無法獲得鎖 var lib dpkg lock open 11 資源暫時不可用 e 無法鎖定管理目錄 var lib dpkg 是否有其他程序正...

ubuntu18 04映象製作

一 配置網路 ip addr add dev eth0 ip link set dev eth0 up ip route add default via 二 修改dns systemctl stop systemd resolved systemctl disable systemd resolve...

ubuntu 18 04搭建testlink伺服器

安裝xampp chmod 755 xampp linux x64 7.3.6 2 installer.run sudo xampp linux x64 7.3.6 2 installer.run,全部選擇y,預設安裝在 opt lampp中 啟動xampp sudo opt lampp lampp...