Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of redis installation, setup, start and stop under mac

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you the example analysis of redis installation, settings, start and stop under mac, I believe most people still don't know how to understand, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go and understand it together!

You need to download the release version, download address:

http://download.redis.io/releases/

What I downloaded here:

http://download.redis.io/releases/redis-3.2.5.tar.gz

Extract it to/usr/local/redis and execute the following commands:

cd /usr/local/redissudo make test

sudo make install

Start redis-server

redis-server

As shown above, redis-server starts successfully and listens on port 6379.

Description of common commands

redis-server redis

redis-cli redis client

redis-benchmark redis performance testing tool

redis-check-aof AOF file repair tool

redis-check-rdb RDB file repair tool

Start and Stop Server Start

default startup

As above, the command redis-server starts the redis server. and accept client connections.

Start according to settings

Create three directories bin, etc, db under/usr/local/redis directory

Copy mkreleasehdr.sh, redis-benchmark, redis-check-rdb, redis-cli, redis-server from/usr/local/redis/src directory to bin directory

Under etc, create a new configuration redis.conf as follows.

Create a log file log-redis.log under/usr/local/redis and modify the permissions of the current user. sudo chown -R shoren /usr/local/redis/

Start server: redis-server /usr/local/redis/etc/redis.conf

#modify to daemonize yes#set process lock file pidfile /usr/local/redis/redis.pid#port 6379#client timeout 300#log level debug#log file location logfile /usr/local/redis/log-redis.log#set the number of databases, the default database is 16, you can use SELECT command to specify database iddatabases on the connection 16##specify how many update operations occur within a certain period of time, You can synchronize data to a data file with multiple conditions #save#Three conditions are provided in the Redis default configuration file: save 900 1save 300 10save 60 10000#Specify whether to compress data when saving to local database, default is yes, Redis uses LZF compression, if in order to save CPU time,#can turn off this #option, rdbcompression yes#Specify the local database file name dbfilename dump.rdb#Specify the local database path dir /usr/local/redis/db/#Specify whether to log after each update operation. Redis writes data to disk asynchronously by default. If not turned on, it may cause data loss for a period of time during power failure. Because redis itself synchronizes data files according to the above save conditions, so there are #data will only exist in memory for a period of time appendonly no#Specify the update log condition, there are 3 optional values: #no: indicates that the operating system synchronizes the data cache to disk (fast)#always: indicates that fsync() is manually called to write data to disk after each update operation (slow, safe)#everysec: indicates synchronization once per second (compromise, default) appendfsync everysec

Next, you can view the log as follows, indicating that the startup was successful:

_._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.5 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._| '` _.- '| Port: 6379 | `-._ `._ / _.- ' | PID: 14447 `-._ `-._ `-./ _.- ' _.- ' |`-._`-._ `-.__.- ' _.- '_.- '| | `-._`-._ _.- '_.- ' | http://redis.io `-._ `-._`-.__.- '_.- ' _.- ' |`-._`-._ `-.__.- ' _.- '_.- '| | `-._`-._ _.- '_.- ' | `-._ `-._`-.__.- '_.- ' _.- ' `-._ `-.__.- ' _.- ' `-._ _.- ' `-.__.- ' 14447:M 24 Apr 17:57:33.215 # Server started, Redis version 3.2.514447:M 24 Apr 17:57:33.215 * The server is now ready to accept connections on port 637914447:M 24 Apr 17:57:33.215 - 0 clients connected (0 slaves), 956832 bytes in use 1447:M 24 Apr 17:57:38.257 - 0 clients connected (0 slaves), 956832 bytes in use Close Server forcibly closed

Forcibly terminating the redis process may result in data loss because redis may be synchronizing memory data to the hard disk.

ps axu| grep redis ##Find PID kill -9 PID command for redis-server Close

Send the SHUTDOWN command to redis, redis-cli SHUTDOWN. After Redis receives the command, the server will disconnect all client connections, then perform persistence according to the configuration, and finally exit.

##Start redis-server, background thread AT8775:redis shoren$ redis-server /usr/local/redis/etc/redis.conf ##Start successfully AT8775:redis shoren$ ps axu| grep redisshoren 14948 0.0 0.0 2434840 760 s000 S+ 10: 18am 0:00.00 grep redisshoren 14946 0.0 0.0 2452968 1492 ?? Ss 10:18 AM 0:00.01 redis-server *:6379 ##shutdown server AT8775:redis shorn $ redis-cli shutdown##shutdown succeeded AT8775:redis shorn $ ps axu| grep redisshoren 14952 0.0 0.0 2435864 772 s000 S+ 10:19 AM 0:00.01 grep redis Start Client Default Start

Start the client with the command redis-cli and connect to Redis (127.0.0.1: 6379) according to the default configuration.

Specify address and port number

Use the command redis-cli -h 127.0.0.1-p 6379

Turn off client interaction mode using quitAT8775:redis shoren$ redis-cli -h 127.0.0.1-p 6379##Simply use set, get command 127.0.0.1: 6379> set key value12OK127.0.1:6379> get key"value12"##Exit 127.0.0.1: 6379> quitAT8775:redis shoren$Above is "Example analysis of redis installation, setting, starting and stopping under mac" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report