# 启动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. .Net core3.0 集成swagger5.0上传文件

    .Net core 3.0已经更新了,相信有挺多博主大佬们都更新了如何在.Net core3.0使用swagger,这里就不详细说了. 我们知道,如果.net core 2.x使用swagger上传文 ...

  2. 洛谷 P1522 牛的旅行 Cow Tours

    题目链接:https://www.luogu.org/problem/P1522 思路:编号,然后跑floyd,这是很清楚的.然后记录每个点在这个联通块中的最远距离. 然后分连通块,枚举两个点(不属于 ...

  3. Java Spring Boot 一些调试技巧

    配置文件的管理 有的时候我们希望开发环境和测试环境的配置文件放在一起可以快速切换 spring boot 为我们提供了很方便的的选项 在 application.properties 中只需要添加属性 ...

  4. Controller的激活(1)

    Public interface IController { void Execute(RequestContext requestContext) } Public abstract Class C ...

  5. .net 异常

    ArgumentNullException 当将空引用(在 Visual Basic 中为 Nothing)传递给不接受它作为有效参数的方法时引发的异常.

  6. 2019牛客暑期多校训练营(第八场)A:All-one Matrices(广告牌问题 单调队列)

    题意:给出N*M的01矩阵,求矩阵个数,满足矩阵内全是‘1’,,而且被至少一个’0‘围住.(假设边界外是‘0’.(N,M<3000) 思路:这类问题,一般解决就是两个方向: A:压缩一维,即枚举 ...

  7. 软件测试之Monkey 初步了解(入门级II)

    1. 先熟悉monkey基本命令: cls   清除 首先测试设备是否连接成功,在命令行中输入:adb devices 查看adb版本: adb version 查看虚拟机版本:nox_adb ver ...

  8. layoutSubviews的缺省实现是使用约束进行布局

    Discussion The default implementation of this method does nothing on iOS 5.1 and earlier. Otherwise, ...

  9. kuma 学习四 策略

    通过策略我们可以构建灵活的service mesh 应用策略 我们可以通过kumactl 以及kubectl 应用策略 kumactl 格式 echo " type: .. spec: .. ...

  10. CF 900D Unusual Sequences

    题目链接 \(Description\) 给定\(x,y\),求有多少个数列满足\(gcd(a_i)=x且\sum a_i=y\).答案对\(10^9+7\)取模. \(1≤x,y≤10^9\) \( ...