惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

SangSir丨艺术界的一朵奇葩丨至一网络科技

Windows 使用 Hyper-V 网络上传速度异常慢解决方案 Mac homebrew 升级导致的 php 不能正常启动 dyld[40013]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuio Uniapp h5部署到服务器刷新页面出现404 Uniapp中plus.contacts.getAddressBook获取通讯录为返回type:0解决方案 天地图修改主题颜色修改背景色 Part.Three. 前端JOB MODEL Part Two. 前端面试题库 Part One. 前端react方向 阿里巴巴前端暑期实习面经
宝塔服务器多站点配置多个redis节点以及自启动方案
博主: SangSir · 2020-08-16 · via SangSir丨艺术界的一朵奇葩丨至一网络科技

目前存在的问题点:

一台服务器部署多个站点时,第一个网站装了Redis插件,连接成功。由于只有一个redis端口,当第二个、第三个网站装了Redis扩展后自动跳转到第一个站点了。所以在多个网站部署后会产生冲突,因此导致在一台电脑上访问同一个服务器上不同的网站,就会把另一个网站的redis节点给弹出去,真心的不爽!

需要解决的问题点:

同一台服务器上部署不同的站点时,需要启动多个Redis实例:一台Redis服务器,分成多个节点,每个节点分配一个端口(6380,6381…),默认端口是6379。每个节点对应一个Redis配置文件,如:redis6380.conf、redis6381.conf。

解决方案如下:

第一步:拷贝多个redis.conf并修改配置,这个自己想怎么搞就这么搞……

#cd /www/server/regis
#cp redis.conf redis6380.conf
#vi redis6380.conf           #注:修改redis6380.conf这一步可以进宝塔面板修改,只修改以下几项哦
port 6380
pidfile /www/server/redis/redis_6380.pid
logfile "/www/server/redis/redis_6380.log"
dbfilename dump_6380.rdb

第二步:进入/etc/init.d目录,拷贝多个redis启动项并修改配置,这个自己严格按照要求来搞……

#cd /etc/init.d
#cp redis redis6380
#vi redis6380

修改下面脚本中的REDIS_PORT端口号

#!/bin/sh
# chkconfig: 2345 56 26
# description: Redis Service

### BEGIN INIT INFO
# Provides:          Redis
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts Redis
# Description:       starts the BT-Web
### END INIT INFO

# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDIS_PORT="6380"
CONF="/www/server/redis/redis${REDIS_PORT}.conf"
REDISPORT=$(cat $CONF |grep port|grep -v '#'|awk '{print $2}')
REDISPASS=$(cat $CONF |grep requirepass|grep -v '#'|awk '{print $2}')
REDISHOST=$(cat $CONF |grep bind|grep -v '#'|awk '{print $2}')
if [ "$REDISPASS" != "" ];then
    REDISPASS=" -a $REDISPASS"
fi
if [ -f "/www/server/redis/start${REDIS_PORT}.pl" ];then
    STARPORT=$(cat /www/server/redis/start${REDIS_PORT}.pl)
else
    STARPORT="${REDIS_PORT}"
fi
EXEC=/www/server/redis/src/redis-server
CLIEXEC="/www/server/redis/src/redis-cli -h $REDISHOST -p $STARPORT$REDISPASS"
PIDFILE=/var/run/redis_${REDIS_PORT}.pid

redis_start(){
    if [ -f $PIDFILE ]
    then
            echo "$PIDFILE exists, process is already running or crashed"
    else
            echo "Starting Redis server..."
            nohup sudo -u redis $EXEC $CONF >> /www/server/redis/logs${REDIS_PORT}.pl 2>&1 &
            echo ${REDISPORT} > /www/server/redis/start${REDIS_PORT}.pl
    fi
}
redis_stop(){
        echo "Stopping ..."
        $CLIEXEC shutdown
        sleep 1
        PID=`ps aux|grep "sudo -u redis"|grep -v "grep"|grep -v "/etc/init.d/redis${REDIS_PORT}"|awk '{print $2}'`
        if [ "${PID}" != "" ];then
                sleep 3
                pkill -9 redis-server
                rm -f $PIDFILE
        fi
        echo "Redis stopped"
}


case "$1" in
    start)
        redis_start
        ;;
    stop)
        redis_stop
        ;;
    restart|reload)
        redis_stop
        sleep 0.3
        redis_start
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

第三步:把redis6380……添加到自启动项,查看启动项

#cd /etc/init.d
#chkconfig --add redis6380    或    #chkconfig redis6380 on
#chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

bt              0:关    1:关    2:开    3:开    4:开    5:开    6:关
bt_syssafe      0:关    1:关    2:开    3:开    4:开    5:开    6:关
memcached       0:关    1:关    2:开    3:开    4:开    5:开    6:关
mysqld          0:关    1:关    2:开    3:开    4:开    5:开    6:关
netconsole      0:关    1:关    2:关    3:关    4:关    5:关    6:关
network         0:关    1:关    2:开    3:开    4:开    5:开    6:关
nginx           0:关    1:关    2:开    3:开    4:开    5:开    6:关
php-fpm-54      0:关    1:关    2:开    3:开    4:开    5:开    6:关
php-fpm-56      0:关    1:关    2:开    3:开    4:开    5:开    6:关
redis           0:关    1:关    2:开    3:开    4:开    5:开    6:关
redis6380       0:关    1:关    2:开    3:开    4:开    5:开    6:关
redis6381       0:关    1:关    2:开    3:开    4:开    5:开    6:关

同样的方法,你想要加N多个都行,接下来就随便搞吧…

加入启动项后,立即启动方法:

cd /etc/init.d
./redis6380 start
本文未经允许不能转载,如需转载请注明出处 https://www.scit028.com/post-260.html