整理一下,这几天的项目
还是很乱,有时间得好好整理一下。
安装
yum -y install wget PyXML cluster-glue cluster-glue-libs resource-agents ipv
wget -O /etc/yum.repos.d/network_ha-clustering_Stable.repo http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/RedHat_RHEL-6/network:ha-clustering:Stable.repo
yum -y install heartbeat* ldirectord
cp /usr/share/doc/heartbeat-3.0.4/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.4/haresources /etc/ha.d/
cp /usr/share/doc/ldirectord-3.9.6/ldirectord.cf /etc/ha.d/
也可以下载好RPM包安装
配置文件
[root@dr1 ha.d]# cat ha.cf |grep -v ^#
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast eth1 # Linux
auto_failback on
node dr1
node dr2
ping 10.10.0.1
respawn hacluster /usr/lib64/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
[root@dr1 ha.d]# cat ldirectord.cf |grep -v ^#
checktimeout=3
checkinterval=1
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no
virtual=10.10.0.40:80
real=10.10.0.33:80 gate
real=10.10.0.34:80 gate
real=10.10.0.35:80 gate
fallback=127.0.0.1:80 gate
service=http
scheduler=rr
#persistent=600
netmask=255.255.255.255
protocol=tcp
checktype=negotiate
checkport=80
request="ok.html"
receive="ok"
virtualhost=www.x.y.z
[root@dr1 ha.d]# cat haresources |grep -v ^#
dr1 IPaddr::10.10.0.40/32/eth0 ldirectord::ldirectord.cf
[root@dr1 ha.d]# cat authkeys |grep -v ^#
auth 1
1 crc
chmod 600 authkeys
把这两个文件COPY到另一台DR上面
rsync -avzlR /etc/ha.d/ 10.10.0.31:/
chkconfig heartbeat on
开启两台DR 的服务
service heartbeat start
查看日志文件
tailf /var/log/ha-log
tailf /var/log/ldirectord.log
一切正常就可以安装WEB服务器
安装WEB服务器
一:安装依赖包
yum install make apr* autoconf automake bzip2 bzip2-devel curl curl-devel gcc gcc-c++ gcc-g77 e2fsprogs e2fsprogs-devel zlib* zlib-devel openssl openssl-devel pcre-devel gd gd-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* libvpx libjpeg libpng zlib libXpm libXpm-devel t1lib libt1-devel freetype freetype-devel libpng* libpng10 libpng10-devel libpng-devel php-common php-gd ncurses* ncurses-devel libtool* libtool-libs libxml2-devel patch glibc glibc-devel glib2 glib2-devel krb5 krb5-devel libevent libevent-devel libidn libidn-devel nss_ldap openldap openldap-clients openldap-devel openldap-servers openssl openssl-devel pspell-devel net-snmp* net-snmp-devel -y
内核参数优化
# vi sysctl.conf
增加以下配置
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1800
net.ipv4.ip_conntrack_max = 16777216 # 如果使用默认参数,容易出现网络丢包
net.ipv4.netfilter.ip_conntrack_max = 16777216# 如果使用默认参数,容易出现网络丢包
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries =
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.ip_local_port_range = 1024 65535
二:下载LNMP所需软件
wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.19.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget http://iweb.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://iweb.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gz
wget http://tw1.php.net/distributions/php-5.5.24.tar.gz
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://pecl.php.net/get/memcache-2.2.7.tgz
wget http://www.imagemagick.org/download/legacy/ImageMagick-6.8.3-10.tar.gz
wget http://pecl.php.net/get/imagick-3.3.0RC1.tgz
wget http://pecl.php.net/get/pecl_http-1.7.5.tgz
wget http://downloads.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36.tar.gz
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz
wget http://pecl.php.net/get/igbinary-1.1.1.tgz
wget https://github.com/nicolasff/phpredis/archive/master.zip
wget https://github.com/libgd/libgd/archive/GD_2_0_29.tar.gz
wget https://github.com/libgd/libgd/archive/gd-2.1.1.tar.gz
三、安装mysql
tar zxf mysql-5.5.19.tar.gz
cd mysql-5.5.19
groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DSYSCONFDIR=/etc/mysql -DMYSQL_UNIX_ADDR=/opt/mysql/tmp/mysql.sock -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install
chown -R mysql.mysql /opt/mysql
cd ..
因为有专门的mysql服务器,所以mysql安装到此结束。如果想要在本地运行mysql的话还要做其他配置。比如my.cnf配置文件,mysql启动脚本等等。
四:安装PHP
安装PHP(FastCGI)
### 安装PHP支持库 ###
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install
cd ..
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
cd ../../
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
create database bbs default charset uft8;
grant all on bbs.* to bbs@'10.10.0.%' identified by '123456';
cd ../
tar zxf re2c-0.13.5.tar.gz
cd re2c-0.13.5
./configure
make && make install
cd ..
将下面的内容加入到local.conf中
[root@web1 ~]# cat /etc/ld.so.conf.d/local.conf
/usr/local/lib64/
/usr/local/lib/
/usr/lib64/
/usr/local/php/lib/
/usr/local/libmcrytp/lib/
现在安装PHP
tar jxf php-5.3.18.tar.bz2
cd php-5.3.18
groupadd nginx
useradd -M -s /sbin/nologin -g nginx nginx
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pic --with-bz2 --with-gettext --with-gmp --with-iconv --with-openssl --with-zlib --with-layout=GNU --with-kerberos --with-mhash --with-pcre-regex --enable-exif --enable-sockets --enable-shmop --enable-calendar --enable-mbstring --enable-xml --enable-fpm --enable-gd-native-ttf --enable-exif --enable-soap --with-gd --with-curl --with-mcrypt --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-pdo-mysql --with-unixODBC --enable-wddx --with-libexpat-dir --with-xmlrpc --with-xsl --with-ldap --enable-bcmath --enable-dom --without-gdbm --disable-debug --disable-fileinfo --without-pspell --disable-posix --disable-sysvmsg --disable-sysvshm --disable-sysvsem
make && make install
ake ZEND_EXTRA_LIBS='-liconv'
make install
拷贝配置文件及启动脚本
cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cd ../
安装PHP扩展模块,别忘记在配置文件里开启模块,不然就白装了哈
### 安装扩展模块 ###
tar zxf memcache-2.2.7.tgz
cd memcache-2.2.7/
/usr/local/php/bin/phpize
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar jxf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
mkdir /tmp/cache/eaccelerator
chmod 0777 /tmp/cache/eaccelerator
cd ../
tar zxf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/opt/mysql
make
make install
cd ../
tar zxf igbinary-1.1.1.tgz
cd igbinary-1.1.1
/usr/local/php/bin/phpize
./configure --enable-igbinary --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ..
unzip master
cd phpredis-master
/usr/local/php/bin/phpize
./configure --enable-redis --enable-redis-igbinary --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ..
tar zxvf ImageMagick-6.8.3-10.tar.gz
cd ImageMagick-6.8.3-10/
./configure
make
make install
cd ../
tar zxvf imagick-3.3.0RC1.tgz
cd imagick-3.3.0RC1.tgz
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
#ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick
#export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make
make install
cd ../
安装NGINX
tar zxf nginx-1.4.4.tar.gz
cd nginx-1.4.4
/configure --user=nginx --group=nginx --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --with-pcre --http-client-body-temp-path=/usr/local/nginx/tmp/client_body --http-proxy-temp-path=/usr/local/nginx/tmp/proxy --http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi --http-scgi-temp-path=/usr/local/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-file-aio --with-google_perftools_module
make && make install
mkdir -pv /usr/local/nginx/tmp/client_body
vim /etc/nginx/nginx.conf
user nginx nginx;
[root@web1 test.peter.com]# cat /etc/nginx/nginx.conf | grep -v ^#
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
server {
listen 10.10.0.33:80;
server_name test.peter.com;
access_log /data/logs/nginx/test.peter.com.access.log;
index index.php index.html index.html;
root /data/site/test.peter.com/;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
}
/usr/local/nginx/bin/nginx
/usr/local/nginx/bin/nginx -s stop
/usr/local/nginx/bin/nginx -s reload
保存以下内容为 info.php 到 /data/www/,检查 phpinfo 中的各项信息是否正确。
phpinfo();
?>
到最后NGINX启动的时候可能会报错,具体看报错信息。
每台WEB服务器上要启用VIP
realserver vip
sh
#!/bin/bash
# chkconfig: - 60 50
# description: start realserver
# processname: lvsrs
VIP=10.10.0.40
case
"$1"
in
start)
echo
"start LVS of REALServer"
/sbin
/ifconfig lo
:0
$VIP broadcast
$VIP netmask 255.255.255.255 up
echo
"1" >
/proc
/sys
/net
/ipv4
/conf
/lo
/arp_ignore
echo
"2" >
/proc
/sys
/net
/ipv4
/conf
/lo
/arp_announce
echo
"1" >
/proc
/sys
/net
/ipv4
/conf
/all
/arp_ignore
echo
"2" >
/proc
/sys
/net
/ipv4
/conf
/all
/arp_announce
;;
stop)
/sbin
/ifconfig lo
:0 down
echo
"close LVS REALserver"
echo
"0" >
/proc
/sys
/net
/ipv4
/conf
/lo
/arp_ignore
echo
"0" >
/proc
/sys
/net
/ipv4
/conf
/lo
/arp_announce
echo
"0" >
/proc
/sys
/net
/ipv4
/conf
/all
/arp_ignore
echo
"0" >
/proc
/sys
/net
/ipv4
/conf
/all
/arp_announce
;;
*)
echo
"Usage: $0 {start|stop}"
exit 1
esac
下面配置MYSQL服务器
cat mysql_install.sh
echo "-----------------------start install mysql----------------------"
yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel libtool*
mkdir -p /data/mysql_data_3306
if [ `grep "mysql" /etc/passwd | wc -l` -eq 0 ];then
echo "adding user mysql"
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
else
echo "mysql user is exist"
fi
echo "tar xvzf cmake-2.8.8.tar.gz"
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure && make && make install
cd ..
echo "tar xzvf mysql-5.5.41.tar.gz"
tar zxvf mysql-5.5.41.tar.gz
cd mysql-5.5.41
echo "configuring mysql,please wait-----------------"
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_ZLIB=system -DSYSCONFDIR=/etc/mysql -DMYSQL_UNIX_ADDR=/opt/mysql/tmp/mysql.sock -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DMYSQL_DATADIR=/data/mysql_data_3306 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
if [ $? -ne 0 ];then
echo "configure filed ,please check it out!"
exit 1
fi
echo "make mysql, please wait for 20 minutes"
make
if [ $? -ne 0 ];then
echo "make filed ,please check it out!"
exit 1
fi
make install
chown -R mysql:mysql /opt/mysql
chown -R mysql.mysql /data/mysql_data_3306
cd /opt/mysql
/opt/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql_data_3306
cp /opt/mysql/support-files/my-huge.cnf /etc/my.cnf
cp /opt/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
echo "mysql starting"
/etc/rc.d/init.d/mysqld start
if [ $? -ne 0 ];then
echo "mysql start filed ,please check it out!"
else
echo "mysql start successful,congratulations!"
fi
此时安装 Discuz_X3.2_SC_UTF8.zip
修改配置文件
#server1
binlog-do-db=bbs #需要记录二进制日志的数据库,多个用逗号隔开
binlog-ignore-db=mysql,information_schema #不需要记录二进制日志的数据库,多个用逗号隔开
auto_increment_increment=2 #字段一次递增多少
auto_increment_offset=1 #自增字段的起始值
replicate-do-db=bbs #同步的数据库,多个用逗号隔开
replicate-ignore-db = information_schema #不同步的数据库,多个用逗号隔开
server_id = 1 #每台设置不同
log_bin = mysql-bin
log_slave_updates #当一个主故障,另一个立即接管
sync-binlog=1 #每条自动更新,安全性高,默认是0
#vim /root/.bash_profile
PATH=$PATH:/opt/mysql/bin
#. /root/.bash_profile
#service mysqld restart
#mysql_secure_installation
#mysql -uroot -p123456
create database bbs default charset uft8;
grant all on bbs.* to bbs@'10.10.0.%' identified by '123456';
mysql> grant replication slave on *.* to 'slave'@'10.10.0.61' identified by '123456';
flush privileges;
service mysqld restart
备份mysql数据库
/opt/mysql/bin/mysqldump -uroot -p123456 --opt --skip-lock-tables --flush-logs --all-database >/root/allbak.sql
scp allbak.sql
[email protected]:/root
mysql> show master status;
+----------------+----------+--------------+--------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------+----------+--------------+--------------------------+
| bin-log.000004 | 107 | bbs | mysql,information_schema |
+----------------+----------+--------------+--------------------------+
1 row in set (0.00 sec)
mysql> change master to master_host='10.10.0.60',
-> master_user='slave',
-> master_password='123456',
-> master_log_file='bin-log.000004',
-> master_log_pos=107;
Query OK, 0 rows affected (0.30 sec)
mysql> start slave
#server2
mysql -uroot -p123456
mysql>grant replication slave on *.* to 'slave'@'10.10.0.60' identified by '123456';
mysql> flush privileges;
mysql> change master to
-> master_host='10.10.0.60',
-> master_user='slave',
-> master_password='123456',
-> master_log_file='bin-log.000004',
-> master_log_pos=187;
查看状态
show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
找到这样子的信息就算OK了
主主复制OK
主从复制这里就不说了
下面安装MYSQL-MMM
yum -y install libart_lgpl perl-Date-Manip perl-XML-DOM perl-XML-DOM-XPath perl-XML-Parser perl-XML-RegExp rrdtool perl-Class-Singleton perl perl-DBD-MySQL perl-Params-Validate perl-MailTools perl-Time-HiRes mysql-connector-odbc
下面的软件需下载安装
yum -y install perl-Algorithm-Diff-1.1902-1.el6.rfx.noarch.rpm perl-Net-ARP-1.0.6-2.1.el6.x86_64.rpm perl-IPC-Shareable-0.60-2.el6.rf.noarch.rpm perl-Proc-Daemon-0.19-1.el6.noarch.rpm perl-Log-Dispatch-2.26-1.el6.rf.noarch.rpm perl-Proc-ProcessTable-0.48-1.el6.x86_64.rpm perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm rrdtool-perl-1.3.8-6.el6.x86_64.rpm
每个DBserver都要安装
每个DB MYSQL都执行如下命令
GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'10.10.0.%' IDENTIFIED BY '123456';
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'10.10.0.%' IDENTIFIED BY '123456';
安装MYSQL-MMM-2.2.1
tar xvzf mysql-mmm-2.2.1.tar.gz
cd mysql-mmm-2.2.1
make install
在主服务器上设置
[root@localhost mysql-mmm]# cat /etc/mysql-mmm/mmm_common.conf
active_master_role writer
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user slave
replication_password 123456
agent_user mmm_agent
agent_password 123456
ip 10.10.0.60
mode master
peer db2
ip 10.10.0.61
mode master
peer db1
ip 10.10.0.62
mode slave
ip 10.10.0.63
mode slave
hosts db1, db2
ips 10.10.0.100
mode exclusive
hosts db1, db2, db3 ,db4
ips 10.10.0.101,10.10.0.102,10.10.0.103,10.10.0.104
mode balanced
[root@localhost mysql-mmm]# cat /etc/mysql-mmm/mmm_mon.conf
include mmm_common.conf
ip 10.10.0.99
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 10.10.0.60, 10.10.0.61, 10.10.0.62, 10.10.0.63
monitor_user mmm_monitor
monitor_password 123456
debug 0
[root@localhost mysql-mmm]# cat /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this db1
(此处注意。第个DB服务器都不一样。要修改)
然后同步配置文件
拷贝mmm_common.conf mmm_agent.conf db1,db2,db3,db4上的
在每个DB 服务器上
echo "/etc/init.d/mysql-mmm-agent" >>/etc/rc.local
[root@slave mysql-mmm-2.2.1]# /etc/init.d/mysql-mmm-agent start
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Ok
在管理机上面
[root@localhost mysql-mmm]# /etc/init.d/mysql-mmm-monitor start
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Ok
[root@localhost mysql-mmm]# mmm_control show
db1(10.10.0.60) master/AWAITING_RECOVERY. Roles:
db2(10.10.0.61) master/AWAITING_RECOVERY. Roles:
db3(10.10.0.62) slave/AWAITING_RECOVERY. Roles:
db4(10.10.0.63) slave/AWAITING_RECOVERY. Roles:
[root@localhost mysql-mmm]# mmm_control set_online db1
OK: State of 'db1' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db2
OK: State of 'db2' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db3
OK: State of 'db3' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db4
OK: State of 'db4' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control show
db1(10.10.0.60) master/ONLINE. Roles: reader(10.10.0.101), writer(10.10.0.100)
db2(10.10.0.61) master/ONLINE. Roles: reader(10.10.0.104)
db3(10.10.0.62) slave/ONLINE. Roles: reader(10.10.0.102)
db4(10.10.0.63) slave/ONLINE. Roles: reader(10.10.0.103)
配置文件到此就结束了
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29901741/viewspace-1608914/,如需转载,请注明出处,否则将追究法律责任。