redis、rabbitMQ等cache安装与配置
详细列表
ip地址 | 主机名 | 服务 | 端口 | 脚本 |
---|---|---|---|---|
172.168.1.40 | iscache01-host-sh.dzhan.net | redis | 6379|26379 | 见/etc/rc.local |
172.168.1.41 | iscache02-host-sh.dzhan.net | redis | 6379|26379|26380 | 见/etc/rc.local |
172.168.1.40 | iscache01-host-sh.dzhan.net | RabbitMQ | 5672|25672|15672 | 见/etc/rc.local |
172.168.1.41 | iscache02-host-sh.dzhan.net | RabbitMQ | 5672|25672|15672 | 见/etc/rc.local |
redis安装
基础包安装
yum install tcl make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC-devel build-essential m4 wget vim libxslt zip unzip nc xmlto jemalloc-devel -y
目录创建
for i in /server/software /server/source;do if [ ! -d "$i" ];then mkdir -p $i ;fi done
安装包准备
cd /server/source
wget http://download.redis.io/releases/redis-stable.tar.gz
安装
tar zxvf redis-stable.tar.gz
cd redis-stable/
make -j 8
make test -j 8
make PREFIX=/server/software/redis install
mkdir -p /server/software/redis/{etc,logs,data}
cp -a redis.conf /server/software/redis/etc/
cp -a sentinel.conf /server/software/redis/etc/
修改redis.conf为后台启动
sed -i 's/^daemonize.*$/daemonize yes/g' /server/software/redis/etc/redis.conf
sentinel配置
cat > /server/software/redis/etc/sentinel.conf <<EOF
port 26379
dir "/tmp"
daemonize yes
logfile "/server/software/redis/logs/sentinel.log"
sentinel monitor mymaster 172.16.1.40 6379 2
sentinel down-after-milliseconds mymaster 600
sentinel failover-timeout mymaster 1800
sentinel parallel-syncs mymaster 1
EOF
增加用户并赋权
useradd -r -s /sbin/nologin redis -M
chown -R redis.redis /server/software/redis
启动
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/redis.conf
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/sentinel.conf --sentinel
添加随即启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.local <<EOF
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/redis.conf
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/sentinel.conf --sentinel
EOF
添加环境变量
cat >>/etc/bashrc <<EOF
export PATH=$PATH:/server/software/redis/bin
EOF
source /etc/bashrc
- redis salve添加配置
cat >>/server/software/redis/etc/redis.conf <<EOF
slaveof 172.16.1.40 6379
EOF
- 在salve主机再启动一个sentinel实例,增加salve权重
配置文件准备
cat > /server/software/redis/etc/sentinel_26380.conf <<EOF
port 26380
dir "/tmp"
daemonize yes
logfile "/server/software/redis/logs/sentinel_26380.log"
sentinel monitor mymaster 172.16.1.40 6379 2
sentinel down-after-milliseconds mymaster 600
sentinel failover-timeout mymaster 1800
sentinel parallel-syncs mymaster 1
EOF
启动并随机启动
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/sentinel_26380.conf --sentinel
cat >>/etc/rc.local <<EOF
sudo -u redis /server/software/redis/bin/redis-server /server/software/redis/etc/sentinel_26380.conf --sentinel
EOF
RabbitMQ安装
erlang虚拟机安装
cd /server/source/
wget http://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm
rpm -Uvh erlang-17.4-1.el6.x86_64.rpm
rabbitMQ安装
cd /server/source/
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.6/rabbitmq-server-3.5.6.tar.gz
tar zxvf rabbitmq-server-3.5.6.tar.gz
cd rabbitmq-server-3.5.6/
make -j 8
make install TARGET_DIR=/server/software/rabbitmq SBIN_DIR=/server/software/rabbitmq/sbin MAN_DIR=/server/software/rabbitmq/man
配置
vim /server/software/rabbitmq/sbin/rabbitmq-defaults
SYS_PREFIX=/server/software/rabbitmq
ERL_DIR=
CLEAN_BOOT_FILE=start_clean
SASL_BOOT_FILE=start_sasl
BOOT_MODULE="rabbit"
CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq
LOG_BASE=${SYS_PREFIX}/logs
MNESIA_BASE=${SYS_PREFIX}/mnesia
ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/enabled_plugins
PLUGINS_DIR=${SYS_PREFIX}/plugins
CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq-env.conf
IO_THREAD_POOL_SIZE=64
添加目录
mkdir -p /server/software/rabbitmq/{etc,logs,mnesia}
增加用户并赋权
useradd -r -m -d /server/software/rabbitmq/home rabbitmq
chown -R rabbitmq.rabbitmq /server/software/rabbitmq
环境变量设置
cat >>/etc/bashrc <<EOF
export PATH=$PATH:/server/software/rabbitmq/sbin
EOF
source /etc/bashrc
集群先决条件
hosts文件设置
172.16.1.40 iscache01-host-sh
172.16.1.41 iscache02-host-sh
启动
su - rabbitmq
rabbitmq-server –detached &
复制rabbitmq1的~/.erlang.cookie
让rabbitmq2的~/.erlang.cookie一致,权限400
rabbitmq1创建集群
su - rabbitmq
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl cluster
rabbitmqctl start_app
查看集群状态
rabbitmqctl cluster_status
rabbitmq2加入集群
su - rabbitmq
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@iscache01-host-sh
rabbitmqctl start_app
检查集群状态
rabbitmqctl cluster_status
Cluster status of node 'rabbit@iscache02-host-sh' ...
[{nodes,[{disc,['rabbit@iscache01-host-sh','rabbit@iscache02-host-sh']}]},
{running_nodes,['rabbit@iscache01-host-sh','rabbit@iscache02-host-sh']},
{cluster_name,<<"rabbit@iscache01-host-sh">>},
{partitions,[]}]
RabbitMQ管理
Web管理
启动management
su - rabbitmq
rabbitmq-plugins enable rabbitmq_management
设置管理账户
rabbitmqctl add_user root xxxx
加入administrator角色
rabbitmqctl set_user_tags root administrator
最新内容
- Linux系统下systemctl常用命令以及service文件配置
- CI PHP7 session 不能读取的问题
- centos 7.4 基本配置
- mysqldump导入导出数据库总结
- Linux下的tar压缩解压缩常用命令
- 查看 SELinux状态、临时关闭SELinux、永久关闭SELinux
- centos6.8 yum安装mysql 5.6
- CentOS之7与6的区别2
- CentOS之7与6的区别1
- Mysql 忘记root密码的完美解决方法
- 输入密码登录,Linux scp (rsync)设置nohup后台运行
- ubantu zabbix部署——安装配置zabbix agent详解
- Zabbix客户端(agent端口)安装配置
- CentOS 7添加开机启动服务/脚本
- 阿里云机器配置 centos 6.8