一, rabbitmq安装:
安装服务器:10.0.16.101, 10.0.16.102
下载及安装方式:
step 1:
启用EPEL:EPEL是一个FedoraProject 推出的 EPEL(Extra Packagesfor Enterprise Linux),EPEL是RHEL的 Fedora 软件仓库,把它添上,你就可以获得 RHELAS 的高质量、高性能、高可靠性,又需要方便易用(关键是免费)的软件包更新功能。我当前使用的是cenos6.3_x86_64
# wgethttp://mirror.neu.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
安装 epel( -U表示更新)
# rpm -Uvh epel-release-6-8.noarch.rpm -U
step 2:
将erlang的repo文件添加到/ete/yum.repos.d/下
# wget -O /etc/yum.repos.d/epel-erlang.repohttp://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo
step 3:
安装erlang
# yum update
# yum install erlang
step 4:
确认erlang安装成功
# erl
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0][kernel-poll:false]
Eshell V5.8.5 (abort with ^G)
1>io:format("hello world ~n").
输出 hello world ok 安装erlang完毕
step 5:
安装rabbitmq-server (当前最新版本3.1.3-1)
导入rabbitmq 数字签名key 支持后安装
# rpm --importhttp://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.1.3/rabbitmq-server-3.1.3-1.noarch.rpm
# yum installrabbitmq-server-3.1.3-1.noarch.rpm
rabbitmq-server安装完成
第一次安装时没有更新EPEL安装到这里遇到的问题:
提示erlang 版本支持问题
Error: Package: rabbitmq-server-3.1.3-1.noarch (/rabbitmq-server-3.1.3-1.noarch)
Requires: erlang >= R12B-3
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
删除所有相关rpm包后重新按照官方文档安装
运行RabbitMQ Server
设置开机自动启动 rabbitmq-server#chkconfig --level 35 rabbitmq-server on 启动rabbitmq-server[start][stop][etc]# service rabbitmq-server start rabbitmqctl status
安装插件管理界面
# mkdir -m 777/etc/rabbitmq/ (如果目录已经存在直接执行 # chmod 777 /etc/rabbitmq/)# rabbitmq-plugins enable rabbitmq_management 重启rabbitmq-server#rabbitmqctl stop# rabbitmq-server start 查看管理端口有没有启动:# netstat -tnlp|grep 55672浏览器打开http://IP:55672/mgmt/ 账号密码都是guest,如果局域网无法访问设置防火墙过滤规则或关闭防火墙
二,安装Haproxy+keepalived
haproxy-1.4.24.tar.gzkeepalived-1.2.7
安装服务器:10.0.16.101, 10.0.16.102
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz
tar -zxvf haproxy-1.4.24.tar.gz
cd haproxy-1.4.24
make TARGET=linux26 PREFIX=/usr/local
make install PREFIX=/usr/local
cp haproxy-1.4.24/examples/haproxy.cfg /etc/haproxy.cfg
vim /etc/haproxy.cfg 修改配置文件:
[plain]
global
log 127.0.0.1 alertdebug
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
uid 99
gid 99
daemon
#debug
#quiet
defaults
log global
mode http
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen rabbitmq 0.0.0.0:56720
mode tcp
balance roundrobin
option tcpka
server rabbit1192.168.1.93:5672 check inter 5000 downinter 500
server rabbit2 192.168.1.94:5672check inter 5000
用当前机器56720端口,代理93、94两台rabbit机器的5672端口。
守护模式运行:
haproxy -f /etc/haproxy.cfg -D
cd/usr/local/src
wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
tar zxfkeepalived-1.2.7.tar.gz
cdkeepalived-1.2.7
./configure--prefix=/usr/local/keepalived
make
make install
所设keepalived安装到/usr/local/keepalived,则所有配置文件均位于此目录之下。我一直没搞明白一个问题,Linux默认总是将程序安装到/usr/local目录下,所有程序共享了/usr/local/sbin目录。这对一些人的操作习惯是有影响的。为何不考虑使用每个软件一个独立的目录呢?
1. 建立服务启动脚本,以便使用service命令控制之
cp /usr/local/keepalived/sbin/keepalived /usr/sbin
cp /usr/local/keepalived/etc/sysconfig/keepalived/etc/sysconfig
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived/etc/init.d
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf/etc/keepalived
servicekeepalived start
下载和安装:http://www.cnblogs.com/dkblog/archive/2011/07/06/2098949.html
keepalived配置:上面的文档里有。
haproxy配置: http://www.2cto.com/kf/201207/144600.html
三, 安装mysql
安装服务器:10.0.16.104, 10.0.16.105
先安装需要用到的库:
# yum -yinstall gcc gcc-c++
# yum -yinstall ncurses-devel
下载所需软件包:
将下载的文件都放到/usr/local/src目录下
# cd /usr/local/src
# wgethttp://wwwNaNake.org/files/v2.8/cmake-2.8.7.tar.gz
#wgethttp://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
#wgethttp://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gz
#wget http://www.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz/from/http://cdn.mysql.com
安装cmake编译器
# tarzxvf cmake-2.8.7.tar.gz
# cdcmake-2.8.7
#./bootstrap
#make&& make install
安装m4
#cdm4-1.4.16
./configure
make
makeinstall
安装bison
# tarzxvf bison-2.5.tar.gz
# cdbison-2.5
#./configure
#make&& make install
Mysql数据库的安装
我们这里下载使用的版本为MySQL社区服务器版本,注意md5值及大小。
MD5:9dcee911fb4bc7e977a6b63f4d3ffa63 Size: 33.5M
Mysql安装包,前面已经下载完成。执行如下操作命令即可:
#/usr/sbin/groupadd mysql
#/usr/sbin/useradd -g mysql mysql
# tarxvf mysql-5.6.10.tar.gz
# cdmysql-5.6.10
# mkdir/data0/mysql -p
cmake . -DCMAKE_INSTALL_PREFIX=/data0/mysql-DMYSQL_UNIX_ADDR=/data0/mysql/mysql.sock -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSET=all-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data0/mysql/data
# mkdir/data0/mysql-3307/data –p
给mysql组及mysql用户授权
[root@localhost mysql-5.5.22]# cd /data0/mysql
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
设置选项文件,将配置文件拷贝到/etc下
[root@localhost mysql]#cp support-files/my-default.cnf /etc/my.cnf
设置开机自启动
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chmod +x /etc/init.d/mysql
[root@localhost mysql]# chkconfig mysql on
通过服务来启动和关闭Mysql
[root@localhost ~]# service mysql start
为root账户设置密码
[root@localhost ~]# cd /usr/local/mysql/bin
[root@localhost mysql]# ./bin/mysqladmin -u root password 123456
Enter Password:123456
设置profile PATH环境变量,任意目录下连接mysql
#echo “exportPATH=/data0/mysql/bin:\$PATH”>>/etc/profile
#source/etc/profile