centos6.10环境下启动多个redis实例
# 启动redis端口6379的配置 [root@newcms:/usr/local/nginx/conf]# egrep -v '^#|^$' /usr/local/redis-2.8./etc/redis.conf
daemonize yes
pidfile /usr/local/redis-2.8./redis.pid
port
tcp-backlog
timeout
tcp-keepalive
loglevel notice
logfile "/usr/local/redis-2.8.7/var/redis.log"
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_data.rdb
dir /data/redis_data
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority
maxclients
maxmemory <>
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-entries
list-max-ziplist-value
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes # 启动脚本 [root@newcms:/usr/local/nginx/conf]# cat /etc/init.d/redis-server
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: -
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /usr/local/redis/etc/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit redis="/usr/local/redis/bin/redis-server"
prog=$(basename $redis) REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf" [ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis lockfile=/var/lock/subsys/redis start() {
[ -x $redis ] || exit
[ -f $REDIS_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $redis $REDIS_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
stop
start
} reload() {
echo -n $"Reloading $prog: "
killproc $redis -HUP
RETVAL=$?
echo
} force_reload() {
restart
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit
esac # 启动redis端口 的配置
# mkdir -p /data/redis_data_9376
[root@newcms:/usr/local/nginx/conf]# egrep -v '^#|^$' /usr/local/redis-2.8.24_9376/etc/redis.conf
daemonize yes
pidfile /usr/local/redis-2.8.24_9376/redis.pid
port
tcp-backlog
timeout
tcp-keepalive
loglevel notice
logfile "/usr/local/redis-2.8.24_9376/var/redis.log"
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_data.rdb
dir /data/redis_data_9376
masterauth pass
requirepass pass
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command shutdown ""
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority
maxclients
maxmemory <>
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-entries
list-max-ziplist-value
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes # 添加开机自动启动
chkconfig --add redis9376-server # 启动脚本
[root@newcms:/usr/local/nginx/conf]# cat /etc/init.d/redis9376-server
#!/bin/sh
#chkconfig:
#description: Startup and shutdown script for Redis PROGDIR=/usr/local/redis-2.8.24_9376/bin #安装路径
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/usr/local/redis-2.8.24_9376/etc/redis.conf
PIDFILE=/usr/local/redis-2.8.24_9376/redis.pid
DESC="redis daemon"
SCRIPTNAME=/etc/rc.d/init.d/redis_9376 start()
{
if test -x $DAEMON
then
echo -e "Starting $DESC: $PROGNAME"
if $DAEMON $CONFIG
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "Couldn't find Redis Server ($DAEMON)"
fi
} stop()
{
if test -e $PIDFILE
then
echo -e "Stopping $DESC: $PROGNAME"
if kill `cat $PIDFILE`
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "No Redis Server ($DAEMON) running"
fi
} restart()
{
echo -e "Restarting $DESC: $PROGNAME"
stop
start
} list()
{
ps aux | grep $PROGNAME
} case $ in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
list)
list
;; *)
echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&
exit
;;
esac
exit # 新增监控 <?php /*
redis_monitor.php
通过类似 http://127.0.0.1/php/redis_monitor.php?func_name='store_redis' php web的访问来判断redis的可用性 */
//通过获取/data/www/machine_no/.machine_no获取机房进行redis的判断 function conn_redis($redis_domain, $redis_port, $redis_pass){
//创建 Redis 对象
$redis = new Redis();
// global $redis;
$redis->connect($redis_domain, $redis_port);
$redis->auth($redis_pass); //设置 redis 字符串数据,并返回该设置的字符串
$redis->set("tutorial-name", "Redis-tutorial"); $result = $redis->get("tutorial-name");
return $result;
} function cms_redis_6379() {
global $machine_no; $res = conn_redis('192.168.11.53', , ''); if ($res == "Redis-tutorial") {
echo "success_6379";
}else {
echo "fail_6379";
}
} function cms_redis_9376() {
global $machine_no; $res = conn_redis('192.168.11.53', , 'pass'); if ($res == "Redis-tutorial") {
echo "success_9376";
}else {
echo "fail_9376";
}
} // 通过get参数获取不同的应用redis
$func_name = $_GET['func_name']; if ($func_name == "cms_redis_6379") {
cms_redis_6379();
}elseif($func_name == "cms_redis_9376"){
cms_redis_9376();
} ?> # 修改 nginx.conf 配置 location ~ ^/php {
root /data/www/html;
location ~ php(.+\.php)(.*)$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
expires -;
if ($request_uri ~ "^(.*)(\?.*)$") {
set $path_info $;
}
fastcgi_param PATH_INFO $path_info;
set $path_info $request_uri;
}
index watchphp.php;
} # 新增监控项
# vim /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/redis_monitor.conf
UserParameter=redis.cms_redis_6379,/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_6379'
UserParameter=redis.cms_redis_9376,/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_9376' # 测试
/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_6379'
# 启动redis端口6379的配置
[root@newcms:/usr/local/nginx/conf]# egrep -v '^#|^$' /usr/local/redis-2.8.7/etc/redis.conf
daemonize yes
pidfile /usr/local/redis-2.8.7/redis.pid
port 6379
tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile "/usr/local/redis-2.8.7/var/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_data.rdb
dir /data/redis_data
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
maxclients 10000
maxmemory <5368709120>
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
# 启动脚本
[root@newcms:/usr/local/nginx/conf]# cat /etc/init.d/redis-server
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /usr/local/redis/etc/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
redis="/usr/local/redis/bin/redis-server"
prog=$(basename $redis)
REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf"
[ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
lockfile=/var/lock/subsys/redis
start() {
[ -x $redis ] || exit 5
[ -f $REDIS_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $redis $REDIS_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $prog: "
killproc $redis -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
# 启动redis端口 9376 的配置
# mkdir -p /data/redis_data_9376
[root@newcms:/usr/local/nginx/conf]# egrep -v '^#|^$' /usr/local/redis-2.8.24_9376/etc/redis.conf
daemonize yes
pidfile /usr/local/redis-2.8.24_9376/redis.pid
port 9376
tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile "/usr/local/redis-2.8.24_9376/var/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_data.rdb
dir /data/redis_data_9376
masterauth pass
requirepass pass
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command shutdown ""
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
maxclients 10000
maxmemory <536870912>
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
# 添加开机自动启动
chkconfig --add redis9376-server
# 启动脚本
[root@newcms:/usr/local/nginx/conf]# cat /etc/init.d/redis9376-server
#!/bin/sh
#chkconfig: 345 86 14
#description: Startup and shutdown script for Redis
PROGDIR=/usr/local/redis-2.8.24_9376/bin #安装路径
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/usr/local/redis-2.8.24_9376/etc/redis.conf
PIDFILE=/usr/local/redis-2.8.24_9376/redis.pid
DESC="redis daemon"
SCRIPTNAME=/etc/rc.d/init.d/redis_9376
start()
{
if test -x $DAEMON
then
echo -e "Starting $DESC: $PROGNAME"
if $DAEMON $CONFIG
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "Couldn't find Redis Server ($DAEMON)"
fi
}
stop()
{
if test -e $PIDFILE
then
echo -e "Stopping $DESC: $PROGNAME"
if kill `cat $PIDFILE`
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "No Redis Server ($DAEMON) running"
fi
}
restart()
{
echo -e "Restarting $DESC: $PROGNAME"
stop
start
}
list()
{
ps aux | grep $PROGNAME
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
list)
list
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2
exit 1
;;
esac
exit 0
# 新增监控
<?php
/*
redis_monitor.php
通过类似 http://127.0.0.1/php/redis_monitor.php?func_name='store_redis' php web的访问来判断redis的可用性
*/
//通过获取/data/www/machine_no/.machine_no获取机房进行redis的判断
function conn_redis($redis_domain, $redis_port, $redis_pass){
//创建 Redis 对象
$redis = new Redis();
// global $redis;
$redis->connect($redis_domain, $redis_port);
$redis->auth($redis_pass);
//设置 redis 字符串数据,并返回该设置的字符串
$redis->set("tutorial-name", "Redis-tutorial");
$result = $redis->get("tutorial-name");
return $result;
}
function cms_redis_6379() {
global $machine_no;
$res = conn_redis('192.168.11.53', 6379, '');
if ($res == "Redis-tutorial") {
echo "success_6379";
}else {
echo "fail_6379";
}
}
function cms_redis_9376() {
global $machine_no;
$res = conn_redis('192.168.11.53', 9376, 'pass');
if ($res == "Redis-tutorial") {
echo "success_9376";
}else {
echo "fail_9376";
}
}
// 通过get参数获取不同的应用redis
$func_name = $_GET['func_name'];
if ($func_name == "cms_redis_6379") {
cms_redis_6379();
}elseif($func_name == "cms_redis_9376"){
cms_redis_9376();
}
?>
# 修改 nginx.conf 配置
location ~ ^/php {
root /data/www/html;
location ~ php(.+\.php)(.*)$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
expires -1;
if ($request_uri ~ "^(.*)(\?.*)$") {
set $path_info $1;
}
fastcgi_param PATH_INFO $path_info;
set $path_info $request_uri;
}
index watchphp.php;
}
# 新增监控项
# vim /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/redis_monitor.conf
UserParameter=redis.cms_redis_6379,/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_6379'
UserParameter=redis.cms_redis_9376,/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_9376'
# 测试
/usr/bin/curl -s http://127.0.0.1/php/redis_monitor.php?func_name='cms_redis_6379'
centos6.10环境下启动多个redis实例的更多相关文章
- Windows环境下启动Redis报错:Could not create server TCP listening socket 127.0.0.1:6379: bind: 操作成功完成。(已解决)
问题描述: 今天在windows环境下启动Redis时启动失败报错: 解决方案: ①运行命令:redis-cli.exe ②退出Redis ③运行命令:redis-server.exe redis.w ...
- centos6.5环境下zookeeper-3.4.6集群环境部署及单机部署详解
centos6.5环境下Zookeeper-3.4.6集群环境部署 [系统]Centos 6.5 集群部署 [软件]准备好jdk环境,此次我们的环境是open_jdk1.8.0_101 zookeep ...
- 【数据库开发】windows环境下通过c++使用redis
1.Windows下Redis的安装使用 Redis是一个key-value存储系统.Redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起 ...
- Ubuntu图形界面环境下启动应该程序:
1.先说下Ubuntu14.04系统开机紫框的问题: Grub theme:黑色屏幕出现紫色边框 There's a minor typo on the grub theme which produc ...
- CentOS6.8环境下搭建yum网络仓库
CentOS6.8环境下搭建yum网络仓库 本文利用ftp服务,在CentOS6.8系统下搭建一个yum仓库,然后用另一台虚拟机访问该仓库.并安装程序包 安装ftp服务 查询ftp服务是否安装 [ro ...
- centos6.9环境下JDK安装部署
1.准备jdk安装文件: 这里我使用的是 jdk-7u79-linux-x64.tar.gz 2.在 /usr/local 目录下创建 sotfware目录,并上传JDK文件: 解压文件并修改文件夹为 ...
- centos6.9环境下JDK安装
1.准备jdk安装文件: 这里我使用的是 jdk-7u79-linux-x64.tar.gz 2.在 /usr/local 目录下创建 sotfware目录,并上传JDK文件: 解压文件并修改文件夹为 ...
- nginx环境下启动php-fpm
nginx环境下启动php-fpm 1.首先查看是否安装了php-fpm 这个我试了好多命令都不行比如 rpm -qa php-fpm , rpm -ql php-fpm , which php-fp ...
- Win 10环境下6sV2.1模型编译心得
最新版本6sV2.1模型是通过FORTRAN95编写的,2017年11月代码编写完成,2018年11月发布在模型官网上.通常我们在使用过程中都是调用模型的.exe可执行文件,而下载下来的是FORTRA ...
随机推荐
- Linux命令head
1.命令简介 head (head) 用来显示档案的开头至标准输出中.如果指定了多于一个文件,在每一段输出前会给出文件名作为文件头.如果不指定文件,或者文件为"-",则从标准输入读 ...
- css透明度、毛玻璃效果
透明度: 1.opacity 背景颜色和字体同时透明 2.background:rgba(255,255,255,0.2); 只是背景颜色透明,字体不透明 代码: .info{ backgr ...
- 【Mysql】Mysql root用户误删了或只剩下没有任何操作权限的用户怎么办
一.操作步骤 1.停止mysql服务:在mysql安装目录下找到mysqld.cnf:在mysqld.cnf中找到以下片段[mysqld]:另起一行加入代码:skip-grant-tables 并保 ...
- yum localinstall 解决本地 rpm 包的依赖问题
yum localinstall 解决本地 rpm 包的依赖问题 本文原始地址:https://sitoi.cn/posts/13384.html 使用命令: sudo rpm -ivh xxx.rp ...
- Centos7部署LAMP平台之架构之路
部署LAMP平台搭建 一.源码安装LAMP 1. 安装apache [root@localhost ~]# yum -y install gcc* apr-devel apr-util-devel p ...
- Redis持久化 - RDB和AOF
原文:https://segmentfault.com/a/1190000016021217 一.持久化的作用 1. 什么是持久化 持久化(Persistence),即把数据(如内存中的对象)保存到可 ...
- elastic-job-lite-console后台以服务形式运行
原文:https://blog.csdn.net/u012637358/article/details/84846923 方式1:命令让程序一直在后台运行 nohup ./bin/start.sh & ...
- 计算机 KB,MB,GB,TB,PB,EB 计算
ASCII码:一个英文字母(不分大小写)占一个字节的空间.一个二进制数字序列,在计算机中作为一个数字单元,一般为8位二进制数.换算为十进制,最小值-128,最大值127.如一个ASCII码就是一个字节 ...
- C# 只允许运行一个程序实例
using System; using System.Windows.Forms; using System.Runtime.InteropServices;//使用DllImport的必须. usi ...
- A and B and Lecture Rooms(LCA)
题目描述 A and B are preparing themselves for programming contests. The University where A and B study i ...