# 启动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实例的更多相关文章

  1. 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 ...

  2. centos6.5环境下zookeeper-3.4.6集群环境部署及单机部署详解

    centos6.5环境下Zookeeper-3.4.6集群环境部署 [系统]Centos 6.5 集群部署 [软件]准备好jdk环境,此次我们的环境是open_jdk1.8.0_101 zookeep ...

  3. 【数据库开发】windows环境下通过c++使用redis

    1.Windows下Redis的安装使用 Redis是一个key-value存储系统.Redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起 ...

  4. Ubuntu图形界面环境下启动应该程序:

    1.先说下Ubuntu14.04系统开机紫框的问题: Grub theme:黑色屏幕出现紫色边框 There's a minor typo on the grub theme which produc ...

  5. CentOS6.8环境下搭建yum网络仓库

    CentOS6.8环境下搭建yum网络仓库 本文利用ftp服务,在CentOS6.8系统下搭建一个yum仓库,然后用另一台虚拟机访问该仓库.并安装程序包 安装ftp服务 查询ftp服务是否安装 [ro ...

  6. centos6.9环境下JDK安装部署

    1.准备jdk安装文件: 这里我使用的是 jdk-7u79-linux-x64.tar.gz 2.在 /usr/local 目录下创建 sotfware目录,并上传JDK文件: 解压文件并修改文件夹为 ...

  7. centos6.9环境下JDK安装

    1.准备jdk安装文件: 这里我使用的是 jdk-7u79-linux-x64.tar.gz 2.在 /usr/local 目录下创建 sotfware目录,并上传JDK文件: 解压文件并修改文件夹为 ...

  8. nginx环境下启动php-fpm

    nginx环境下启动php-fpm 1.首先查看是否安装了php-fpm 这个我试了好多命令都不行比如 rpm -qa php-fpm , rpm -ql php-fpm , which php-fp ...

  9. Win 10环境下6sV2.1模型编译心得

    最新版本6sV2.1模型是通过FORTRAN95编写的,2017年11月代码编写完成,2018年11月发布在模型官网上.通常我们在使用过程中都是调用模型的.exe可执行文件,而下载下来的是FORTRA ...

随机推荐

  1. angular8 打包时 文件过大 导致内存溢出解决方案(记录)

    在package.json 中添加 "scripts": { "ng": "ng", "start": "ng ...

  2. OneDrive,在云端

    应用场景 1.一份文档下班后还没编辑好,发送到自己的QQ/微信回家后继续编辑: 2.由于来回拷贝同一份文件,导致版本太多,忘记那个是最新版本了: 3.出门在外,客户突然需要一份重要文档,这份文件放在办 ...

  3. 接口测试“八重天”---RestAssured

    要记住每一个对你好的人,因为他们本可以不那么做. ---久节奏,慢读书 一.什么是RestAssured 偶然在逛帖子的时候发现一个接口测试框架,觉得不错,学习学习. 官方地址:http://rest ...

  4. 用BlockBoundQueue和c++11实现多线程生产者消费者问题

    // file : blockBoundQueue.h #ifndef YANG_BLOCKBOUNDQUEUE #define YANG_BLOCKBOUNDQUEUE #include <m ...

  5. 项目Alpha冲刺(团队) -- 总结及汇总

    项目Alpha冲刺(团队) --总结 1.团队信息 团队名 :男上加男 成员信息 : 队员学号 队员姓名 个人博客地址 备注 221600427 Alicesft https://www.cnblog ...

  6. Gym100739H Hard Molecules

    Hard Molecules 给定一个连通图中每个点的度数,求一个满足条件的图,图可以有重边,不能有自环. n<=5000, di<=109 题解 如果不要求图连通,那么只需要判断 \[ ...

  7. python基础语法4 文件处理

    1.什么是文件 操作系统提供给你操作硬盘的一个工具 2.为什么要用文件 因为人类和计算机要永久保存数据 3.怎么用文件 相对路径:a.txt # 必须与当前py文件在同一级目录绝对路径:D:\项目路径 ...

  8. [译] 2017 年比较 Angular、React、Vue 三剑客

    原文地址:Angular vs. React vs. Vue: A 2017 comparison 原文作者:Jens Neuhaus 译文出自:掘金翻译计划 本文永久链接:github.com/xi ...

  9. react的优点:兼容了dsl语法与UI的组件化管理

    react的优点:兼容了dsl语法与UI的组件化管理. 组件化管理的dsl描述 UI: 虚拟dom:

  10. First-class function

    https://en.wikipedia.org/wiki/First-class_function In computer science, a programming language is sa ...