当前位置:网站首页>Redis series - redis startup, client day1-2

Redis series - redis startup, client day1-2

2022-06-26 07:09:00 Concise programming

Redis start-up

The front desk starts

The front desk startup is actually that we are day1-1 See the last startup mode
If we close terminal Will shut down

redis-server
redis-cli

Background start

Even if it turns off terminal It won't shut down redis
First we need to find reids Configuration file for related configuration

find redis The configuration file

redis The configuration file for is redis.comf Position in /etc/redis Next
You can find

whereis redis

 Insert picture description here

Copy redis.conf

We will redis.conf The original configuration is copied to redis_copy.conf

cp redis.conf redis_copy.conf

 Insert picture description here

Modify the configuration file

Change the listening address to 0.0.0.0

Originally 127.0.0.1 Indicates local access , It is amended as follows 0.0.0.0 Can be used in any IP Visit , because 0.0.0.0(unspecified) Indicates the total broadcast address of the machine , yes IP Address set ( You can understand it this way ), arbitrarily IP All are accessible

bind 0.0.0.0

Modify the daemon to yes

Indicates that background startup is allowed

daemonize yes

Change Password ( It's up to you )

requirepass 123456

Other configuration

// Modify the port 
port 6379
// Modify working directory 
dir .
// Modify the number of databases ,1 Means to use the first library , share 16 Databases (0--15)
databases 1
// Set the maximum memory 
maxmemory 512mb
// Set log file location 
logfile "redis.log"

start-up ( Plus configuration files )

redis-server /etc/redis/redis.conf

Boot up ( recommend )

Edit service file

cd /etc/systemd/system
vim redis.service

The contents are as follows :

[Unit]
Description=redis-server
After=network.target

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

[Install]
WantedBy=multi-user.target

Reload service

systemctl daemon-reload

Boot up ( If the startup fails, you can restart it )

systemctl start redis
systemctl enable redis

 Insert picture description here

client ( This refers to the command-line client )

Namely redis-cli

redis-cli [options] [commonds]

options:

  1. -h 127.0.0.1 : Indicates the specified to connect redis Node IP Address
  2. -p 6379: Specify port number
  3. -a 123456: Specify the access password as 123456

commonds

  1. ping: Perform a heartbeat test , Normal return pong

GUI

https://github.com/lework/RedisDesktopManager-Windows/releases
 Insert picture description here
Then you can install it normally

原网站

版权声明
本文为[Concise programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260700562745.html

随机推荐