Redis slow query log PHP using redis– to install the extension module

Source: Internet
Author: User
Tags one more line redis cluster

Redis Slow Query log

Editing a configuration file/etc/redis.conf
For the slow query log, you can set two parameters, one is the execution length, the unit is microseconds, and the other is the length of the slow query log. When a new command is written to the log, the oldest one is removed from the command log queue.
Slowlog-log-slower-than 1000//unit MS, which indicates logging is slower than 1000ms
Slowlog-max-len 128//define log length, representing up to 128 entries
Slowlog Get//List all slow query logs
Slowlog get 2//List only 2
Slowlog len//View the number of slow query log bars

Using redis– to install the extension module in PHP

Cd/usr/local/src
wget Https://coding.net/u/aminglinux/p/yuanke_centos7/git/raw/master/21NOSQL/phpredis.zip
Unzip Phpredis.zip
CD Phpredis-develop
/usr/local/php-fpm/bin/phpize
./configure--with-php-config=/usr/local/php-fpm/bin/php-config
Make
Make install

vim/usr/local/php.ini//Increase extension=redis.so
/usr/local/php-fpm/bin/php-m|grep redis//See if there is a Redis module
Restart PHP-FPM Service

Use redis– to store session in PHP
vim/usr/local/php-fpm/etc/php.ini//Change or increase
Session.save_handler = "Redis"
Session.save_path = "tcp://127.0.0.1:6379"

Or this can be configured in the Apache virtual host configuration file:
Php_value Session.save_handler "Redis" Php_value session.save_path "tcp://127.0.0.1:6379"?

Or the PHP-FPM configuration file corresponds to the pool added:
Php_value[session.save_handler] = Redis
Php_value[session.save_path] = "tcp://127.0.0.1:6379"

Vim/etc/redis.conf

WGT Http://study.lishiming.net/.mem_se.txt
mv. mem_se.txt/usr/local/apache2/htdocs/session.php
Where session.php content can be referenced https://coding.net/u/aminglinux/p/yuanke_centos7/git/blob/master/21NOSQL/session.php
Curl localhost/session.php//results similar to 1443702394<br><br>1443702394<br><br> i44nunao0g3o7vf2su0hnc5440
The command line connects to Redis, and you can see the key and the corresponding value
If you want to connect Redis cluster with PHP, you need to use the Predis extension
The installation method is similar to Phpredis,predis extension address Https://github.com/nrk/predis

Redis Master-Slave configuration
To conserve resources, we can launch two Redis services on a single machine
Cp/etc/redis.conf/etc/redis2.conf
vim/etc/redis2.conf//need to modify Port,dir,pidfile,logfile
and add one more line
slaveof 127.0.0.1 6379
If your Lord sets a password, you also need to add
Masterauth aminglinux>com//Set Master's password
Do not forget to create a new dir directory before starting
Redis-server/etc/redis2.conf
Test: Create a new key in the Lord, view from the top
Note: Redis master and slave MySQL are never the same, the Redis master does not synchronize the data beforehand, it will automatically synchronize the past

Redis slow query log PHP using redis– to install the extension module

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.