Install Redis to Ubuntu18.04 LTS
Install Redis to Ubuntu18.04 LTS
Install
ubuntu@chengdu:~$ apt list |grep redis
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
erlang-redis-client/bionic 1.1.0-2 amd64
freeradius-redis/bionic 3.0.16+dfsg-1ubuntu3 amd64
golang-github-alicebob-miniredis-dev/bionic,bionic 2.2.1-3 all
golang-github-go-redis-redis-dev/bionic,bionic 6.9.2-2 all
golang-github-siddontang-goredis-dev/bionic,bionic 0.0~git20150324.0.760763f-4 all
golang-github-stvp-tempredis-dev/bionic,bionic 0.0~git20160122.0.83f7aae-1 all
golang-github-xyproto-simpleredis-dev/bionic,bionic 2.0-1 all
golang-gopkg-redis.v2-dev/bionic,bionic 2.3.2-2 all
kamailio-redis-modules/bionic 5.1.2-1ubuntu2 amd64
libanyevent-redis-perl/bionic,bionic 0.24-2 all
libchi-driver-redis-perl/bionic,bionic 0.10-1 all
libhiredis-dev/bionic 0.13.3-2.2 amd64
libhiredis0.13/bionic 0.13.3-2.2 amd64
libphp-predis/bionic 0.8.3-1ubuntu1 amd64
libpocoredis50/bionic 1.8.0.1-1ubuntu4 amd64
libredis-perl/bionic,bionic 2:1.9910-1 all
libtest-mock-redis-perl/bionic,bionic 0.20-1 all
libtest-redisserver-perl/bionic,bionic 0.21-1 all
libvibe-redis-dev/bionic 0.8.2-1build1 amd64
libvibe-redis0/bionic 0.8.2-1build1 amd64
lua-nginx-redis/bionic,bionic 0.26-1 all
lua-nginx-redis-connector/bionic,bionic 0.06-1 all
lua-redis/bionic,bionic 2.0.5~git20141117.880dda9-1 all
lua-redis-dev/bionic,bionic 2.0.5~git20141117.880dda9-1 all
node-redis/bionic,bionic 0.12.1-2 all
opensips-redis-module/bionic 2.2.2-3build4 amd64
php-nrk-predis/bionic 1.0.0-1 amd64
php-redis/bionic 3.1.6-1build1 amd64
python-django-redis/bionic,bionic 4.9.0-1 all
python-django-redis-admin/bionic,bionic 1.4.0-1 all
python-django-redis-sessions/bionic,bionic 0.6.1-1 all
python-django-websocket-redis/bionic,bionic 0.4.7-1 all
python-fakeredis/bionic,bionic 0.9.0-1 all
python-hiredis/bionic 0.2.0-3 amd64
python-redis/bionic,bionic 2.10.6-2ubuntu1 all
python-rediscluster/bionic,bionic 1.3.3-1 all
python-rediscluster-doc/bionic,bionic 1.3.3-1 all
python-trollius-redis/bionic,bionic 0.1.4-2 all
python3-aioredis/bionic,bionic 1.0.0-1 all
python3-asgi-redis/bionic,bionic 1.4.3-1 all
python3-django-redis/bionic,bionic 4.9.0-1 all
python3-django-redis-admin/bionic,bionic 1.4.0-1 all
python3-django-redis-sessions/bionic,bionic 0.6.1-1 all
python3-django-websocket-redis/bionic,bionic 0.4.7-1 all
python3-fakeredis/bionic,bionic 0.9.0-1 all
python3-hiredis/bionic 0.2.0-3 amd64
python3-redis/bionic,bionic 2.10.6-2ubuntu1 all
python3-rediscluster/bionic,bionic 1.3.3-1 all
redis/bionic,bionic 5:4.0.9-1 all
redis-redisearch/bionic 1.0.8-1 amd64
redis-redisearch-doc/bionic,bionic 1.0.8-1 all
redis-sentinel/bionic 5:4.0.9-1 amd64
redis-server/bionic 5:4.0.9-1 amd64
redis-tools/bionic,now 5:4.0.9-1 amd64 [installed,auto-removable]
rsyslog-hiredis/bionic 8.32.0-1ubuntu4 amd64
ruby-em-hiredis/bionic,bionic 0.3.1-1 all
ruby-em-hiredis-doc/bionic,bionic 0.3.1-1 all
ruby-em-redis/bionic,bionic 0.3.0+gh-2 all
ruby-fakeredis/bionic,bionic 0.5.0-1 all
ruby-hiredis/bionic 0.6.1-1build4 amd64
ruby-peek-redis/bionic,bionic 1.2.0-1 all
ruby-redis/bionic,bionic 3.3.3-1 all
ruby-redis-actionpack/bionic,bionic 5.0.1-2 all
ruby-redis-activesupport/bionic,bionic 5.0.4-1 all
ruby-redis-namespace/bionic,bionic 1.5.2-3 all
ruby-redis-rack/bionic,bionic 2.0.2-2 all
ruby-redis-rails/bionic,bionic 5.0.2-3 all
ruby-redis-store/bionic,bionic 1.3.0-3 all
syslog-ng-mod-redis/bionic 3.13.2-3 amd64
ubuntu@ali8000:~$ sudo apt install redis-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
redis-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/35.4 kB of archives.
After this operation, 172 kB of additional disk space will be used.
Selecting previously unselected package redis-server.
(Reading database ... 209707 files and directories currently installed.)
Preparing to unpack .../redis-server_5%3a4.0.9-1_amd64.deb ...
Unpacking redis-server (5:4.0.9-1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up redis-server (5:4.0.9-1) ...
Job for redis-server.service failed because a timeout was exceeded.
See "systemctl status redis-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript redis-server, action "start" failed.
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: timeout) since Mon 2018-11-05 12:06:41 CST; 8ms ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 2740 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
dpkg: error processing package redis-server (--configure):
installed redis-server package post-installation script subprocess returned error exit status 1
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Errors were encountered while processing:
redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
ubuntu@chengdu:~$ sudo systemctl status redis-server.service
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
Active: activating (start) since Mon 2018-11-05 12:06:41 CST; 53s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 3031 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/redis-server.service
Nov 05 12:06:41 ali8000 systemd[1]: Starting Advanced key-value store...
Nov 05 12:06:41 ali8000 systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
ubuntu@chengdu:~$ ll /var/run/redis/
total 0
drwxr-sr-x 2 redis redis 40 Nov 5 13:56 ./
drwxr-xr-x 27 root root 860 Nov 5 13:56 ../
ubuntu@chengdu:~$ ll /etc/redis/
total 68
drwxr-xr-x 2 root root 4096 Nov 5 13:53 ./
drwxr-xr-x 103 root root 4096 Nov 5 13:53 ../
-rw-r----- 1 redis redis 58837 Apr 3 2018 redis.conf
ubuntu@ali8000:~$
problem
編輯檔案/etc/redis/redis.conf,將bind 127.0.0.1 ::1
修改為bind 127.0.0.1
ubuntu@chengdu:~$ sudo vim /etc/redis/redis.conf
ubuntu@chengdu:~$ sudo systemctl restart redis-server
ubuntu@chengdu:~$ sudo systemctl status redis-server
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2018-11-05 14:01:48 CST; 11s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 25232 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
Main PID: 25233 (redis-server)
Tasks: 4 (limit: 4915)
CGroup: /system.slice/redis-server.service
└─25233 /usr/bin/redis-server 127.0.0.1:6379
Nov 05 14:01:48 chengdu systemd[1]: Starting Advanced key-value store...
Nov 05 14:01:48 chengdu systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
Nov 05 14:01:48 chengdu systemd[1]: Started Advanced key-value store.
ubuntu@chengdu:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set k1 helloworld
OK
127.0.0.1:6379> get k1
"helloworld"
127.0.0.1:6379>
configuration
這個時候僅能從本地訪問,如果要從遠端訪問,需要編輯檔案/etc/redis/redis.conf,將bind 127.0.0.1
修改為bind 0.0.0.0
。
這時即可從遠端訪問了。
lwk@qwfys:~$ redis-cli -h chengdu
chengdu:6379> ping
PONG
chengdu:6379> get k1
"helloworld"
chengdu:6379>
lwk@qwfys:~$
Authentication
這裡我們為redis新增一個密碼。
首先我們用如下密碼生成一個密碼:
lwk@qwfys:~$ echo "exchange" |sha256sum
dc6cb8c594733ee798d0f9a9df67cd795ff3917582bde56254c9ad8803f0e5d3 -
編輯檔案/etc/redis/redis.conf,找到# requirepass foobared
,去掉註釋,然後將其改為requirepass dc6cb8c594733ee798d0f9a9df67cd795ff3917582bde56254c9ad8803f0e5d3
,重啟redis伺服器,然後用客戶端工具去連線。
lwk@qwfys:~$ redis-cli -h chengdu
chengdu:6379> ping
(error) NOAUTH Authentication required.
chengdu:6379> auth dc6cb8c594733ee798d0f9a9df67cd795ff3917582bde56254c9ad8803f0e5d3
OK
chengdu:6379> keys *
1) "k1"
ali8000.xms.com:6379> exit
lwk@qwfys:~$
相關文章
- Install erlang to Ubuntu 18.04 LTSUbuntu
- Install Rabbitmq to Ubuntu 18.04 LTSMQUbuntu
- Install Docker CE for Ubuntu 18.04 LTSDockerUbuntu
- Install linux mint apt to Ubuntu 18.04 LTSLinuxAPTUbuntu
- Ubuntu18.04 LTS 使用CUDA11.1編譯TensoFlow-GPU版本Ubuntu編譯GPU
- 02. Install redis on LinuxRedisLinux
- 在 Ubuntu18.04 下 安裝 RedisUbuntuRedis
- How to Install and Secure Redis on Centos7RedisCentOS
- Linux安裝Redis 6.0.5 ./install_server.sh報錯LinuxRedisServer
- go install: no install location for directory outside GOPATHGoIDE
- semantic-ui@2.4.2 install: `gulp install`UI
- pip install 提示:Could not install packages due to an EnvironmentErrorPackageError
- install qdrant
- Install clickhouse
- habitat install
- Ubuntu18.04 修改hostnameUbuntu
- TiDB 6.5 LTS 發版TiDB
- Python:conda install 和pip install的區別Python
- before install octave package you must be install gcc-fortranPackageGC
- mvn install 命令
- KubeSphere 3.3.2 install
- kubernetes 1.25.9 install
- openwrt install lsblk
- pip install METIS
- postgreSQL install pgvectorSQL
- etcd install & configuration
- Deepin Qt InstallQT
- ubuntu18.04安裝dockerceUbuntuDocker
- ubuntu18.04 安裝jenkinsUbuntuJenkins
- ubuntu18.04 安裝dockerUbuntuDocker
- Ubuntu18.04安裝NginxUbuntuNginx
- Ubuntu18.04安裝GhostUbuntu
- Ubuntu18.04安裝WikijsUbuntuJS
- ubuntu18.04安裝timeshiftUbuntu
- Ubuntu18.04安裝BeyondCompareUbuntu
- Laravel 6.0 lts版本安裝Laravel
- Ubuntu 22.04.1 LTS 安裝 MinIOUbuntu
- Ubuntu 18.04 LTS安裝numbaUbuntu