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 ...
随机推荐
- angular8 配置 测试环境打包指令 生成测试环境包指令
1.angular.json 文件中在architect 下添加 buildTest指令 距离位置 projects => (你的项目名称) => architect 下和 build 指 ...
- C/C++函数调用时传参过程与可变参数实现原理
C/C++函数调用时传参过程与可变参数实现原理 C语言的经典swap问题 在学习C语言的时候,我们大都遇到过一些经典例题,这些经典例题背后所代表的是往往是C/C++背后的一些运行原理,比如下面这个示例 ...
- Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面
Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.status功能概述 status页 ...
- Nginx配置文件、优化详解
上篇<编译安装nginx>已将nginx安装好,这篇写nginx配置文件和部分优化参数. 查看nginx的配置文件路径,可以使用nginx配置文件检查命令nginx -t: [root@n ...
- zabbix--基本操作
zabbix 快速上手 示例一些zabbix的最基本的配置: 添加主机群组:添加主机:创建监控项:创建触发器 添加主机群组 参考官档:https://www.zabbix.com/documentat ...
- 纯数据结构Java实现(10/11)(2-3树&红黑树)
欢迎访问我的自建博客: CH-YK Blog.
- 剑指Offer(十七):树的子结构
剑指Offer(十七):树的子结构 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:https://blog.csdn.net/baidu_ ...
- 201671030102陈飞 实验十四 团队项目评审&课程学习总结
项目 内容 这个作业属于哪个课程 2016级计算机科学与工程学院软件工程(西北师范大学) 这个作业的要求在哪里 实验十四 团队项目评审&课程学习总结 课程学习目标 1.掌握软件项目评审会议流程 ...
- UiAutomatorViewer无法获取手机截图进行元素定位的解决办法
问题描述 本来想使用UIAutomatorView定位app页面元素的,最开始我使用的是夜神模拟器,打开UIAutomatorView连接模拟器没有问题,但是后来我使用真机时发现无法连接到真机获取真机 ...
- 通过jar包名称,获取maven的依赖信息GAV
烦恼:当我们手上有一堆三方件jar包,想要转成maven管理时,需要一个一个配置进pom文件中,而且GAV信息还得去收集. 为了快速生成如下信息,我们可以这样.... GAV:groupId + ar ...