Introduction to Redis and Web management interface

Source: Internet
Author: User
Tags php server nginx reverse proxy redis cluster

Redis has also been used for some time, and the role is probably similar to:

One: Redis role

1: The user data cache, each HTTP access and response, will produce data, and this data, whether it will go to the data inventory table?

may wish to take an example: E-commerce network purchase platform, home daily PV 50 million or so, the front-end generated log volume of more than 400M per day, whether it can give login user account, personal center, orders are stored table?

That even optimizes the tcp-connects, Tomcatthreadpools, oracle-connects, and minute crashes of the database, even the RAC4 node database.

Project: Using Redis cache, a buffer between a Web server and a database to store user data (back-end seesion not front-end cookies), which reduces database pressure and facilitates quick return of user queries.

2: Do the Web cluster seesion share, if n tomcat do cluster, such as Nginx reverse proxy to the front-end to do login, when HTTP is load Balancer/director dispatched to 3th Tomcat, yes, But this tomcat is down,

Will the rest of the normal Tomcat return to the correct server? Seesion can all be transferred to 2th Tomcat,redis, when deploying the Tomcat cluster, you have to refer to Redis about seesion sharing

----------------------

Project: This is the configuration of the Redis cache Tomcat, in the Tomcat/conf/context.xml


<valve classname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/>

<manager classname= "Com.radiadesign.catalina.session.RedisSessionManager"

Host= "172.18.11.162" #这是redis服务器的ip地址

Port= "6379" #这里是redis的端口

database= "0"

maxinactiveinterval= "1800"/>

</Context>

Two: Start a Redis single-instance deployment, the most important is to do Web management based on PHP, in fact, you can also use Desktop management Tools Redis Manager desktop, such as operations management platform, need to integrate all management interface.

1. Download redis2.8 redis-2.8.6.tar.gz

2, compile and install, do not pass configure

Make

Make install

Tips for completing the installation process

It ' s good idea to run ' make test '

Install Install

Install Install

Install Install

Install Install

Make Test---Error need tcl 8.5 or newer in order to run the Redis test

Installing yum-y install TCL

Ok

3, Mkdir-p/opt/redis/bin

Mkdir-p/opt/redis/etc

Mkdir-p/opt/redis/data

Mkdir-p/opt/redis/log

Cp/opt/redis-2.8.6/redis.conf/opt/redis/etc

Cd/opt/redis-2.8.6/src

CP mkreleasdhdr.sh Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server/opt/redis/bin

Modify/OPT/REDIS.CONF----necessary to modify the Daemonize, the rest can not be modified, you can remember

Daemonize Yes to make Redis background run

Logfile/opt/redis/log/redis.log

dir/opt/redis/data/

4. Start Redis

./redis-server. /etc/redis.conf

[Email protected] redis]# Netstat-lntp|grep Redis

TCP 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 28569/./redis-serve

TCP 0 0::: 6379:::* LISTEN 28569/./redis-serve

You can see that port 6379 is enabled and the service is Redis

[Email protected] bin]# REDIS-CLI

127.0.0.1:6379>

The Redis client starts.

You can then use the Redis administration tool Redisdesktopmanager to implement the key operation of the Redis cache

Redis command


---------find the key value exists--------

127.0.0.1:6379> exists fm_loglist/192767813

(integer) 1

(6.20s)

---------See all the key--------

127.0.0.1:6379> keys

1) "fm_loglist/192767813"

2) "fm_loglist/172756561"

3) "fm_loglist/194292175"

4) "fm_loglist/191353234"

5) "fm_loglist/173947365"

6) "fm_loglist/165289481"



---------------------expire set expiration expire key time

127.0.0.1:6379> EXPIRE Tutorialname 60

1) (integer) 1

192.168.182.6:0>expire Chen 600

1

------------------------------------------

TTL key to see when the key expires

127.0.0.1:6379> TTL fm_80/userjinbiloglist/194361483

(integer)-1

-1 if key does not expire timeout

----------del name Delete key Name-----

127.0.0.1:6379> del fm_80/userjinbiloglist/162896690

(integer) 1

-------------Create a new key and delete a key-----

127.0.0.1:6379> set Job "Andrio"

Ok

127.0.0.1:6379> EXISTS Job

(integer) 1

----------Ping Pong Returns whether the response was successful---

127.0.0.1:6379> Ping

PONG

----------a database of select 0~15 numbers---------

127.0.0.1:6379[1]> Select 15

Ok

--------------use it carefully so that you don't need it!!! ----------------------.

FLUSHDB Delete all keys in the currently selected database

Flushall Delete a database from all databases

------------

Select 0 Choose to 0 database redis default database is 0~15 altogether 16 databases

Move confirm 1 moves the key in the current database to a different database, this is the Confire key from the current database to move to 1

Rename Key2 key3 rename Key2 to Key3

Type Key2 returns the data type of key

Move confirm 1 moves the key in the current database to a different database, this is the Confire key from the current database to move to 1

Expire Confirm 100 setting confirm this key100 second expires

------------------See how many keys are there-----------------------------

127.0.0.1:6379> dbsize

(integer) 1415502


webphp static files, need to deploy PHP

PHP Build:

1, can be divided into Yum installation and source installation, but the source installation has a variety of dependency package problems

#安装php依赖软件

Yum-y Install autoconf automake bzip2-devel freetype-devel gcc-c++ libcurl-devel libgcrypt-devel \

Libicu-devel libjpeg-turbo-devel libpng-devel libxml2-devel libxslt-devel ncurses-devel openjpeg-devel \

Openjpeg-libs openldap-devel openssl-devel pcre-devel readline-devel zlib-devel

This is only part of it, please do yum, yum-y install PHP (mandatory install PHP depends on the package, can be used)

2, the use of PHP today is the source code, PHP-5.3.0.TAR.GZ, step one also to implement, to prevent dependency on the package, Http://www.cnblogs.com/lufangtao/arc Hive/2012/12/30/2839679.html

3. Enter the unpacking package./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--enable-fpm

In fact, the system comes with the HTTP service, but the PHP needs to rely on the HTTP environment, so we download httpd-2.2.31.tar.gz Http://www.cnblogs.com/zhuque/arch Ive/2012/11/03/2763352.html

apache2 install./configure--prefix=/usr/local/apache2 the following make The following make install continues

return to PHP installation configure and then go to compile and install make and make install.

The system's HTTP service takes up 80 ports, and the HTTPD service must be canceled from boot. Prevent apache2 port collisions with post-install

4, configuration files (to meet the most basic configuration)

Edit/usr/local/apache2/conf/httpd.conf File

Find AddType application/x-compress. Z

AddType application/x-gzip. gz. tgz

Add in the following:

AddType application/x-httpd-php. PHP (enables Apcche to support PHP)

AddType Application/x-httpd-php-source. php5

Found it:

<ifmodule dir_module>

DirectoryIndex index.html

</IfModule>

Add to:

<ifmodule dir_module>

DirectoryIndex index.html index.php

</IfModule>

Found it:

#servername www.example.com:80

Modified to:

ServerName 127.0.0.1:80 or ServerName localhost:80

Remember to remove the "#" from the front.

5, visit 192.168.182.5 page show it work indicates APACHE2 installation success, access to the page from/usr/local/apache2/htdocs/index.html

Today is to be able to solve the PHP environment smoothly, I put phpredisadmin bag into/usr/local/apache2/htdocs

Access http://192.168.182.5/phpredisadmin/index.php jump Http://192.168.182.5/phpredisadmin/?overview. PHP page display is normal (if you do not have PHP installed, even if you access the PHP page, is also a code page, out of PHP page effect)

Great, PHP server built successfully


Focus, 6, PHP Server build successfully, to solve the Redis Web management problem originates from-------https://my.oschina.net/u/2416477/blog/486481

After editing, the phpredisadmin can be used directly after creating Redis!!!

The following verifies that Redis Web management is valid

Open http://192.168.182.5/phpredisadmin/index.php

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8C/C6/wKioL1h4M3OzomIqAACuBtWjGEQ997.png-wh_500x0-wm_ 3-wmp_4-s_3504007431.png "title=" Qq20170113095334.png "alt=" Wkiol1h4m3ozomiqaacubtwjgeq997.png-wh_50 "/>



Phpredisadmin



[i] [E] [i]

ADD another key

*

filter!

Type here to filter

Keys (2)----------------all keys

Chen

Wang


--------------------------------look

Click Add Another key to write a string of key,value content called Wang .... Refresh, keys do exist Wang

Go to the server to execute./REDIS-CLI Enable Redis client execution

127.0.0.1:6379> keys *

1) "Chen"

2) "Wang"

There is a Key,redis web available called Wang!!!


############## #关于

One: If more than one redis for a project, can do Redis cluster, using keepalived can also be used, in PHP phpredisadmin configuration file 192.168.182.6 to Redis cluster VIP can

Two: About multiple projects, completely not the same business Redis, how to break? Phpredisadmin gave the full answer.

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8C/C7/wKioL1h4PlWg2rnNAAEHrwvP80U547.png-wh_500x0-wm_ 3-wmp_4-s_1239134986.png "title=" 222.png "alt=" Wkiol1h4plwg2rnnaaehrwvp80u547.png-wh_50 "/>


A lot of source code such as Nginx will provide default.conf for templating solution to provide, multi-instance. Can add, not much to say here

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8C/CB/wKiom1h4PuPB15qQAAA17fhqZKI304.png-wh_500x0-wm_ 3-wmp_4-s_3286746558.png "title=" qq picture 20170113104244.png "alt=" Wkiom1h4pupb15qqaaa17fhqzki304.png-wh_50 "/>-- Landlord also not configured, you can study the next


---------------complete, messy grass manuscript, OK

Introduction to Redis and Web management interface

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.