Linux

Nginx反向代理、镜像缓存加速及负载均衡的配置

none

Nginx已经具备Squid所拥有的Web缓存加速功能、清除指定URL缓存的功能。而在性能上,Nginx对多核CPU的利用,胜过Squid不少。另外,在反向代理、负载均衡、健康检查、后端服务器故障转移、Rewrite重写、易用性上,Nginx也比Squid强大得多。

...

rabbitmq 消息队列安装和配置

none

erlang #

首先安装erlang语言环境

yum install erlang -y

rabbitMQ #

rabbitMQ下载地址:直达安装方法:

rpm -ivh --force --nodeps rabbitmq-server-3.6.0-1.noarch.rpm
或者
yum localinstall  rabbitmq-server-3.6.0-1.noarch.rpm -y

启动服务 #

/etc/init.d/rabbitmq-server start
rabbitmq-plugins enable rabbitmq_management

配置主备 #

同步cookie #

chmod 777 /var/lib/rabbitmq/.erlang.cookie
scp /var/lib/rabbitmq/.erlang.cookie Go02:/var/lib/rabbitmq/.erlang.cookie
chmod 400 /var/lib/rabbitmq/.erlang.cookie

添加节点 #

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster [--ram] rabbit@Go01 //此处的Go01为主节点的hostname,需要在/etc/hosts中指定
rabbitmqctl start_app

删除节点 #

rabbitmqctl stop_app
rabbitmqctl forget_cluster_node rabbit@rabbit1

修改类型 #

rabbitmqctl stop_app
rabbitmqctl change_cluster_node_type ram
rabbitmqctl start_app

添加用户 #

rabbitmqctl add_user admin admin
添加权限:
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
删除测试用户:
rabbitmqctl delete_user guest
赋予其administrator角色:
rabbitmqctl set_user_tags admin administrator

修改配置 #

//防止服务端异常中断恢复后镜像队列不能恢复的问题

vim /etc/rabbitmq/rabbitmq.conf
[
  {rabbit,[{tcp_listeners,[5672]},
  {cluster_partition_handling, autoheal}]}
].
#不要忘记最后面的那个点号哦!

环境变量 #

touch /etc/rabbitmq/rabbitmq-env.conf#输入
    RABBITMQ_NODENAME=FZTEC-240088 节点名称    RABBITMQ_NODE_IP_ADDRESS=127.0.0.1 监听IP
    RABBITMQ_NODE_PORT=5672 监听端口    RABBITMQ_LOG_BASE=/data/rabbitmq/log 日志目录
    RABBITMQ_PLUGINS_DIR=/data/rabbitmq/plugins 插件目录
    RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia 后端存储目录

RabbitMQ的用户角色分类 #

none、management、policymaker、monitoring、administrator

...

RabbitMQ性能优化

none

rabbitmq.config #

rabbitmq.config文件时rabbitmq的配置文件,他遵守Erlang配置文件定义。

rabbitmq.config文件位置:

...

rabbitmq之机器机器全部断电恢复记录

今天遇到一个rabbitmq集群同时断电,当机器全部启动的时候发现rabbitmq无法正常启动,然后发现如下日志。

=INFO REPORT==== 25-Apr-2018::11:11:07 ===
Starting RabbitMQ 3.5.3 on Erlang R16B03-1
Copyright (C) 2007-2014 GoPivotal, Inc.
Licensed under the MPL.  See http://www.rabbitmq.com/

=INFO REPORT==== 25-Apr-2018::11:11:07 ===
node           : rabbit@WIN-ACC2J7AGNM9
home dir       : C:\Users\Administrator
config file(s) : e:/RabbitMQ Data/rabbitmq.config (not found)
cookie hash    : kR4NuIdBr2n8/4Qt9uIgqQ==
log            : E:/RabbitMQ Data/log/rabbit@WIN-ACC2J7AGNM9.log
sasl log       : E:/RabbitMQ Data/log/rabbit@WIN-ACC2J7AGNM9-sasl.log
database dir   : e:/RabbitMQ Data/db/rabbit@WIN-ACC2J7AGNM9-mnesia

=WARNING REPORT==== 25-Apr-2018::11:11:07 ===
Kernel poll (epoll, kqueue, etc) is disabled. Throughput and CPU utilization may worsen.

=INFO REPORT==== 25-Apr-2018::11:11:08 ===
Memory limit set to 13095MB of 32738MB total.

=INFO REPORT==== 25-Apr-2018::11:11:08 ===
Disk free limit set to 50MB

=INFO REPORT==== 25-Apr-2018::11:11:08 ===
Limiting to approx 8092 file handles (7280 sockets)

=INFO REPORT==== 25-Apr-2018::11:11:38 ===
Timeout contacting cluster nodes: ['rabbit@WIN-2W6NDAIZBIA'].

BACKGROUND
==========

This cluster node was shut down while other nodes were still running.
To avoid losing data, you should start the other nodes first, then
start this one. To force this node to start, first invoke
"rabbitmqctl force_boot". If you do so, any changes made on other
cluster nodes after this one was shut down may be lost.

DIAGNOSTICS
===========

attempted to contact: ['rabbit@WIN-2W6NDAIZBIA']

rabbit@WIN-2W6NDAIZBIA:
  * connected to epmd (port 4369) on WIN-2W6NDAIZBIA
  * epmd reports: node 'rabbit' not running at all
                  no other nodes on WIN-2W6NDAIZBIA
  * suggestion: start the node

current node details:
- node name: 'rabbit@WIN-ACC2J7AGNM9'
- home dir: C:\Users\Administrator
- cookie hash: kR4NuIdBr2n8/4Qt9uIgqQ==

关键的地方在于中间的这段说明:

...

rabbitmq之修改数据和log目录位置位置

vim /etc/rabbitmq/rabbitmq-env.conf

I am a complete /etc/rabbitmq/rabbitmq-e… #

 vim /etc/rabbitmq/rabbitmq-env.conf

# I am a complete /etc/rabbitmq/rabbitmq-env.conf file.
# Comment lines start with a hash character.
# This is a /bin/sh script file - use ordinary envt var syntax
MNESIA_BASE=/data/rabbitmq/mnesia
LOG_BASE=/data/logs/rabbitmq

Ubuntu 阿里云镜像源

准备工作 #

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份

修改配置 #

14.04 #

sudo vim /etc/apt/sources.list #修改
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

16.04 #

sudo vim /etc/apt/sources.list #修改
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

更新缓存 #

sudo apt-get update #更新列表

ubuntu编译安装vim及配制方法

一个非常好用的vim配置文件

vim简介 #

Vim是一个类似于Vi的著名的功能强大、高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性。VIM是自由软件。

...

vim 快速入门手册

vim常见操作

图示 #

![vi-vim-cheat-sheet-sch.png](/static/uploads/BJ8I8E9U0M/img/vi-vim-cheat-
sheet-sch_SyLsV8yY4.png)

一、移动光标 #

1、左移h、右移l、下移j、上移k

2、向下翻页ctrl + f,向上翻页ctrl + b

3、向下翻半页ctrl + d,向上翻半页ctrl + u

...