当前位置:网站首页>Redis ubuntu18.04.6 intranet deployment

Redis ubuntu18.04.6 intranet deployment

2022-06-23 17:39:00 Common_ youmen

1 brief introduction

Redis Is the key value storage in memory , With its flexibility 、 Performance and extensive language support . In this guide , We will show you how to Ubuntu 18.04.6 Install and configure Redis.

2 Install build and test dependencies

In order to get Redis Latest version , We will compile and install the software from the source . Before downloading the code , We need to satisfy our build dependencies , So that the software can be compiled .

sudo apt-get install gcc make

#  Download the deb Package in this directory 
/var/cache/apt/archives

#  If you want to deploy in a netless environment, you can take it offline deb The package is copied to the server and 
sudo dpkg -i *.deb

3 download , Compile and install redis

wget http://download.redis.io/releases/redis-6.0.1.tar.gz
tar xf redis-6.0.1.tar.gz
cd redis-6.0.1/
make && make MALLOC=libc

3.1 To configure Redis

sudo mkdir /data/jsdesign/apps/redis/{data,bin,conf} -p
sudo cp /tmp/redis-6.0.1/redis.conf  /data/jsdesign/apps/redis/conf/
sudo vim /data/jsdesign/apps/redis/conf/redis.conf
 216 supervised systemd
 345 dir /data/jsdesign/apps/redis/data

3.2 Create a Redis System unit files

sudo vim /lib/systemd/system/redis.service
[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/data/jsdesign/apps/redis/bin/redis-server /data/jsdesign/apps/redis/conf/redis.conf
ExecStop=/data/jsdesign/apps/redis/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

3.3 establish redis user , Group

sudo adduser --system --group --no-create-home redis
sudo chown -R redis:redis /data/jsdesign/apps/redis

4 Start and test redis

4.1 start-up redis service

sudo systemctl start redis

[email protected]:~/redis-6.0.1$ sudo systemctl status redis
● redis.service - Redis In-Memory Data Store
   Loaded: loaded (/etc/systemd/system/redis.service; static; vendor preset: enabled)
   Active: active (running) since Thu 2022-01-06 07:41:16 UTC; 1h 9min ago
 Main PID: 9034 (redis-server)
    Tasks: 4 (limit: 4656)
   CGroup: /system.slice/redis.service
           └─9034 /data/jsdesign/apps/redis/bin/redis-server 127.0.0.1:6379

Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 # Server initialized
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 # WARNING overcommit_memory i
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 # WARNING you have Transparen
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 * Loading RDB produced by ver
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 * RDB age 0 seconds
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 * RDB memory usage when creat
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 * DB loaded from disk: 0.000
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 * Ready to accept connections
Jan 06 07:41:16 ubuntu-test-240 redis-server[9034]: 9034:M 06 Jan 2022 07:41:16.041 # systemd supervision request
Jan 06 08:50:26 ubuntu-test-240 systemd[1]: redis.service: Current command vanished from the unit file, execution
lines 1-18/18 (END)

sudo systemctl enable redis

5 test Redis Instance function

[email protected]:~/redis-6.0.1$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set test "redsi is ok"
OK
127.0.0.1:6379> get test
"redsi is ok"

[email protected]:~/redis-6.0.1$ sudo systemctl restart redis
[email protected]:~/redis-6.0.1$ redis-cli
127.0.0.1:6379> get test
"redsi is ok"
原网站

版权声明
本文为[Common_ youmen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201061942102452.html