First, Redis Introduction
Redis is one of the most popular NoSQL systems today, and it is a key-value storage system. Similar to memcache, but largely compensates for the lack of memcache, which supports storing more value types, including string, list, set, Zset, and hash. These data types support Push/pop, Add/remove, and intersection sets and differences, and richer operations. Based on this, Redis supports sorting in a variety of different ways.
Like Memcache, Redis data is cached in the computer's memory, except that memcache can only cache data in memory and not automatically write to the hard disk periodically, which means that a power outage or restart, memory emptying, and data loss. So Memcache's application scenario is for caching data that does not need to be persisted. The difference between redis is that it periodically writes the updated data to the disk or writes the modified operation to the appended record file, which makes the data persistent.
Second, the installation of Redis
The following is a description of the installation and deployment of Redis under the Linux environment
1, First officer network Download Redis compressed package, address: Http://redis.io/download Download stable version 3.0.7 can.
2, through the Remote management tool, the compressed package copy to the Linux server, to perform the decompression operation
3. Perform make to compile files after Redis decompression
After compiling, you can see that the extracted file redis-3.0.7 will have the corresponding SRC, conf and other folders, which is the same as installing the extracted files under Windows, most of the installation packages will have corresponding class files, configuration files and some command files.
4, after the successful compilation, enter the SRC folder, execute make install for Redis installation
5, the installation is complete, the interface is as follows
Iii. Deployment of Redis
After the installation is successful, Redis is deployed below
1, first for the convenience of management, the Redis file in the Conf configuration files and common commands to move to the unified file
A) Creating Bin and redis.conf files
Mkdir-p/usr/local/redis/-p/usr/local/redis/etc
b) Execute the Linux file Move command:
mv/lamp/redis-3.0.7/redis.conf/usr/local/redis//lamp/redis-3.0.7/SRCMV mkreleasdhdr.sh redis- Benchmark Redis-check-aof redis-check-dump REDIS-CLI Redis-server/usr/local/redis/bin
2, execute Redis-server command, start Redis service
Note: The Redis service, which executes the redis-server boot directly, is run directly in the foreground (as an effect), that is, if LUnix closes the current session after executing the command, the Redis service is closed. Under normal circumstances, starting the Redis service requires booting from the background and specifying a startup configuration file.
3. Back-up Redis service
A) First edit the Conf file and change the Daemonize property to Yes (indicating that you need to run in the background)
CD etc/VI redis.conf
b) Start the Redis service again and specify the startup service profile
Redis-server/usr/local/redis/etc/redis.conf
4. After the server starts successfully, execute REDIS-CLI to start the Redis client and view the port number.
Iv. Summary of common commands for Linux and Redis operations
Linux:
Cd/usr from subfolders into parent folder usr
CD local from parent to child
mv/a/b Moves file A to B
VI usr/local/redis/redis.conf Edit redis.conf file
: Wq Save the changes and exit
Redis:
redis-server/usr..../redis.conf start the Redis service and specify the configuration file
REDIS-CLI starting the Redis client
Pkill redis-server off Redis service
REDIS-CLI Shutdown Close Redis Client
Netstat-tunpl|grep 6379 View Redis default port number 6379 occupancy
Redis Set Password login under Linux
Redis Set Password access
Your redis will not be accessible in real-world environments, so you must set a password
The process for setting the password is as follows:
Vim /etc/redis.conf#requirepass foobared get rid of comments, foobared change to their own password, I changed here 123456
Then save, restart the service
cd/usr/local/bin. /redis-server/etc/redis.conf
Test connection:./redis-cli
The input command will prompt (error) Noauth authentication required. This is a normal phenomenon.
We enter auth 123456# the password you just set
Redis installation successful, external inaccessible problem?
Cause: The listening address of the Redis port is 127.0.0.1 causing the external network not to connect
Workaround: Modify the redis.conf configuration file bind 127.0.0.1 to bind 101.200.166.125 (true IP address)
Summary of commands used by the resolution process:
① viewing the listening status of a specified port
NETSTAT-ANP | grep 9000
③ external test port for normal access
101.200.189.125 6379
④redis Startup method
Redis-server/etc/redis.conf
⑤redis Shutdown method
Redis-cli-p Port-a password Shutdowneg:redis-cli-p 6379-a mypassword shutdown
⑥ Modifying the Redis port number and setting the password
------Open redis.conf configuration file Modify Port 6379 to port 9999 (default = 6379 port)
------Open redis.conf Configuration file Modify Requirepass mypassword (set Redis password)
⑦ Viewing port status
/etc/init.d/iptables status
Installation and deployment of Redis under Linux