NoSQL介绍(五)
Redis安全设置
vim /etc/redis.conf
bind 127.0.0.1 192.168.221.10 //设置监听ip
port 10000 //设置监听端口
requirepass 123 //设置密码为123
rename-command CONFIG apeng //将config命令修改为apeng
rename-command CONFIG "" //禁掉config命令
重启redis服务
killall redis-server
redis-server /etc/redis.conf
客户端连接redis服务器
redis-cli -p 10000 -a ‘123‘ -h 127.0.0.1
Redis慢查询日志
vim /etc/redis.conf
slowlog-log-slower-than 1000 //单位ms,表示慢于1000ms记录日志
slowlog-max-len 128 //定义日志长度,表示最多存128条
命令行中的关于慢日志的命令
slowlog get //列出所有的慢查询日志
slowlog get 2 //列出最近2条记录
slowlog len //查看慢查询日志条数
PHP中使用redis--安装扩展模块
cd /usr/local/src/
wget https://coding.net/u/aminglinux/p/yuanke_centos7/git/raw/master/21NOSQL/phpredis.zip
yum install unzip -y
unzip phpredis.zip
cd phpredis-develop/
yum install autoconf -y
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vim /usr/local/php/etc/php.ini //增加extension=redis.so
/usr/local/php/bin/php -m|grep redis
PHP中使用redis--存储session(与memcached存储session步骤差不多)
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
php_value session.save_handler "redis"
php_value session.save_path "tcp://127.0.0.1:6379"
vim /usr/local/php-fpm/etc/php.ini
session.save_handler = "redis"
session.save_path = "tcp://127.0.0.1:6379"
vim /usr/local/php-fpm/etc/php-fpm.d/default.conf
php_value[session.save_handler] = redis
php_value[session.save_path] = "tcp://127.0.0.1:6379"
http://blog.51cto.com/13480443/2084481
原文地址:http://blog.51cto.com/13480443/2085190
时间: 2024-10-08 10:08:59