当前位置:网站首页>Redis (I) -- getting to know redis for the first time

Redis (I) -- getting to know redis for the first time

2022-07-07 06:24:00 yutao_ five hundred and seventeen

brief introduction

Redis It's based on key value pairs (key-value) Of NoSQL database

SQL and NoSQL difference

SQLNoSQL
data structure structured Unstructured
Data Association The associated Unrelated
A query SQL Inquire about Not SQL
Transaction features ACID No transaction ( Cannot satisfy strong consistency )
storage disk Memory
Extensibility vertical level
Use scenarios The data structure is fixed ; Relevant businesses have high data consistency and security The data structure is not fixed ; The data consistency and security of related businesses are not high ; Performance requirements

Redis characteristic

  • Data structure server based on key value pairs ,value Support a variety of different data structures , Rich in functions
  • Single thread . Each command is consistent
  • Low latency , Fast ( Memory based 、IO Multiplexing 、 Good coding )
  • Support data persistence
  • Support the master-slave cluster , Fragmentation cluster
  • Support for multilingual clients

install

Default startup mode

yum install gcc tcl -y
wget https://download.redis.io/releases/redis-6.2.7.tar.gz
mv redis-6.2.7.tar.gz /usr/local/src/
tar -zxvf redis-6.2.7.tar.gz
cd redis-6.2.7
make && make install
redis-server

 Insert picture description here

Background startup mode

cp redis.conf redis.conf.default
vim redis.conf
# Modify the following configuration 
bind 0.0.0.0
daemonize yes
# Daemon , It is amended as follows yes Background start 
requirepass 123456
# Set up redis Access code for 
redis-server /usr/local/src/redis-6.2.7/redis.conf
ps -ef|grep redis

 Insert picture description here

Write service startup

vim /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-6.2.7/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Then reload the system services

systemctl daemon-reload

Now? , We can use the following set of commands to operate redis 了 :

#  start-up 
systemctl start redis
#  stop it 
systemctl stop redis
#  restart 
systemctl restart redis
#  Check the status 
systemctl status redis

Execute the following command , It can make redis Boot from boot :

systemctl enable redis
redis-cli -h 127.0.0.1 -p 6379 -a 123456

 Insert picture description here

原网站

版权声明
本文为[yutao_ five hundred and seventeen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070141147504.html