Current location - Quotes Website - Collection of slogans - Linux has redis installed, how to start it?
Linux has redis installed, how to start it?
1. First, for the convenience of management, the conf configuration file and common commands in the Redis file are moved to a unified file.

(1) create bin and redis.conf files, and copy the code "mkdir-p/usr/local/redis/bin; mkdir-p/usr/local/redis/ect ";

(2) Execute the Linux file moving command and copy the code "mv/lamp/redis-3.0.7/redis.conf/usr/local/redis/etc; CD/lamp/redis-3 . 0 . 7/src; mv mkreleasdhdr . sh redis-benchmark redis-check-aof redis-check-dump redis-CLI redis-server/usr/local/redis/bin ";

2. Execute the Redis-server command to start the Redis service.

Note: The Redis service started by Redis-server is directly executed here, and it runs directly in the foreground (the effect is shown above). In other words, after executing this command, if Lunix closes the current session, the Redis service will be shut down immediately. Normally, starting the Redis service needs to be started from the background, and a startup configuration file is specified.

3. Start the redis service in the background.

(1) first edit the conf file, and change the daemonize attribute to yes (indicating that it needs to run in the background), with the code CD etc/; Vi redis.conf

(2) Start the redis service again, and specify the startup service configuration file with the code of redis-server/usr/local/redis/etc/redis.conf;

4. After the server is successfully started, execute redis-cli to start the redis client and check the port number.

I. Introduction to Redis

Redis is one of the most popular NOSQL systems at present. This is a key value storage system. Similar to Memcache, but it makes up for the deficiency of Memcache to a great extent. It supports more types of value storage, including strings, lists, collections, zset and hash. These data types all support push/pop, add/remove, intersection, difference set and richer operations. On this basis, Redis supports sorting in various ways.

Like Memcache, the data of Redis is cached in the computer memory, but the difference is that Memcache can only cache the data in the memory, and can't automatically write to the hard disk at regular intervals, which means that once the power is off or restarted, the memory will be emptied and the data will be lost. Therefore, the application scenario of Memcache is suitable for caching data that does not need to be persisted. Redis is different in that it will periodically write updated data to disk, or modify additional record files, so as to achieve data persistence.

Second, summarize the common commands of Linux and Redis operations.

1, Linux:cd /usr enters the superior folder usr from the subfolder; Cd is passed down from generation to generation locally; Mv /A /B is to move the file A to B; Vi usr/local/redis/redis.conf is to edit the redis.conf file;

2. redis: redis-server/usr .../redis.conf is to start the redis service and specify the configuration file; Redis-cli is to start the Redis client; Pkill redis-server is to close the redis service; Closing redis-cli is to close the Redis client: Netstat -tunpl|grep 6379 is to check the occupation of the default port number 6379 of Redis.