Redis for the installation and configuration LInux (on remote connection)

Redis for the installation and configuration LInux (on remote connection)

Impossible with today, tomorrow, it will not do.
 

What is redis?

1. Core Concepts

Redis is a key high-performance C language developed for the storage of non-relational databases. Redis type of data stored are the following: Character (String), hash (Hash), list (List), the set (Set), ordered collection (ZSet)

2. Historical Development

In 2008, an Italian start-up companies Merzia introduced a MySQL-based site system LLOOGG real-time statistics, however, was not long before the company's founder Salvatore Sanfilippo will be disappointed with the performance of MySQL, so he decided to personally tailor LLOOGG a database, developed and completed in 2009, this database is Redis. However, Salvatore Sanfilippo is not satisfied with only the Redis for LLOOGG This is a product, but I hope more people use it, so in the same year Salvatore Sanfilippo will Redis open source releases, and began another major code contributions Redis together with the continued development of Redis by Pieter Noordhuis, until today.   SalvatoreSanfilippo had no idea, just a few years time, Redis to have a large user base. HackerNews released a survey of the use of the database in 2012 showed that nearly 12% of companies are using Redis. Domestic as Sina Weibo, roadside network, Redis users know almost all networks abroad such as GitHub, Stack Overflow, Flickr and so on.

VMware Inc. from 2010 sponsored the development of Redis, Salvatore Sanfilippo and Pieter Noordhuis were also joined VMware in March and May, the full development of Redis.

 

reis application scenarios

  • Cache (data queries, short connections, news content, goods, content, etc.). (Most used)

  • Distributed cluster architecture session separation.

  • Online chat room buddy list.

  • Task queue. (Spike, buy, 12306, etc.)

  • Application list.

  • Website statistics.

  • Processing data has expired (accurate to milliseconds)

    redis mounted under linux

    installation

    # Install the C language environment (installed skippable) 
    yum the install-GCC C ++ # the download package 
    wget http://download.redis.io/releases/redis-4.0.1 .tar.gz
     # decompression 
    tar -zxvf redis- 4.0.1 .tar.gz
     # to enter decompression and build your Redis 
    cd-Redis 4.0.1 # compile the make
     # install Redis 
    the make install PREFIX = / usr / local / Redis
    
    
    

    PREFIX behind the / usr / local / redis is the installation path, we start redis documents are here, you can also customize. There are suggested the installation was successful:

make[1]: Entering directory `/root/redis-3.0.6/src'
​
Hint: It's a good idea to run 'make test' ;)
​
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/root/redis-3.0.6/src
​
 

Copy the configuration file and run

Took our profile redis.conf manually copied to the installation path ,, to turn on running in the background and remote access.

# Copy redis.conf file 
cp -r redis.conf / usr / local / redis / bin /

bin directory structure of the installation path

Well now we can enter the command to run redis

# Turn on the server 
./redis- Server redis.conf
 

 
# Open a new window, run the client to connect
cd /usr/redis/
#链接此redis
./redis-cli  或者  ./redis-cli -h 127.0.0.1 -p 6379
 

-h:指定主机IP-p:指定主机端口默认主机IP是127.0.0.1 默认端口 6379不填则使用默认值

 

成功并进行如下测试

但不可能每次都开两个窗口,我们需要配置后台运行;同时我们用程序连接也需要远程连接,接下来我们进行设置

设置后台进行和远程连接

接下里我们在配置文件redis.conf中进行相关的配置

#打开配置文件
vim redis.conf
 

在vim编辑模式下,输入行数+gg可以快捷跳行。例如跳到第138行,输入:138gg

设置后台启动

将第138行的daemonize no修改为daemonize yes即可

开启远程访问

将第70行的bind注释,第90行将protected-mode改为no

https://img-blog.csdn.net/20181006165948551?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTkyOTAw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70

设置密码

取消第502行的注释,并修改密码

接下来重启redis:

#首先查询到redis的pid后,kill掉,然后重启
[root@localhost bin]# ps -ef|grep redis
root      20940      1  0 12:12 ?        00:00:18 ./redis-server *:6379 
[root@localhost bin]# kill 20940
[root@localhost bin]# ./redis-server redis.conf 

后台启动成功如下:

最后我们使用redis客户端通过密码远程连接:

#远程连接
./redis-cli -h 你服务器的ip -p 6379 -a 你的密码

 

 

 

虽然不输入密码也能登陆,但是无法进行get set操作

 

 

Guess you like

Origin www.cnblogs.com/junjun511/p/11299575.html