-
服务安装和配置运维中心 / operations 2dot5 写在2017年05月05日lvs 安装和配置方法:参考网站:http://kerry.blog.51cto.com/172631/401253同步服务器时间yum install -y ntpntpdate time.nist.govnginx -s reloadVIP=192.168.0.200MASTER=192.168.0.201BACKUP=192.168.0.202关闭SELINUXvi /etc/sysconfig/selinuxSELINUX=disabledsetenforce 0 selinux立即生效关闭防火墙iptables -F安装必要的软件yum install ipvsadmyum install openssl openssl-devel下载keepalived源码包wget http://www.keepalived.org/software/keepalived-1.1.17.tar.gztar xf keepalived-1.1.17.tar.gzcd keepalived-1.1.17./configure –with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-x86_64/Keepalived configuration————————Keepalived version : 1.1.17Compiler : gccCompiler flags : -g -O2Extra Lib : -lpopt -lssl -lcryptoUse IPVS Framework : YesIPVS sync daemon support : YesUse VRRP Framework : YesUse LinkWatch : NoUse Debug flags : No[root@master ~]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/[root@master ~]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/[root@master ~]# mkdir /etc/keepalived[root@master ~]# cp /usr/local/sbin/keepalived /usr/sbin/[root@master ~]# vi /etc/keepalived/keepalived.conf主机配置:! Configuration: command not foundglobal_defs {notification_email {king_819@163.com}notification_email_from king_819@163.comsmtp_server smtp.163.com# smtp_connect_timeout 30router_id LVS_DEVEL}# VIP1vrrp_instance VI_1 {state MASTERinterface eth0virtual_router_id 51priority 100advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.0.205}}virtual_server 192.168.0.205 80{delay_loop 6# lb_algo wlclb_algo wrrlb_kind DRprotocol TCPreal_server 192.168.0.202 80 {weight 3TCP_CHECK {connect_timeout 10nb_get_retry 3delay_before_retry 3connect_port 80}}real_server 192.168.0.201 80 {weight 3TCP_CHECK {connect_timeout 10nb_get_retry 3delay_before_retry 3connect_port 80}}}备机配置! Configuration: command not foundglobal_defs {notification_email {king_819@163.com}notification_email_from king_819@163.comsmtp_server smtp.163.com# smtp_connect_timeout 30router_id LVS_DEVEL}# VIP1vrrp_instance VI_1 {state BACKUPinterface eth0virtual_router_id 51priority 90advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.0.205}}virtual_server 192.168.0.205 80{delay_loop 6# lb_algo wlclb_algo wrrlb_kind DRprotocol TCPreal_server 192.168.0.202 80 {weight 3TCP_CHECK {connect_timeout 10nb_get_retry 3delay_before_retry 3connect_port 80}}real_server 192.168.0.201 80 {weight 3TCP_CHECK {connect_timeout 10nb_get_retry 3delay_before_retry 3connect_port 80}}}被负载机器的配置生成RealServer.sh#!/bin/bash# Written by NetSeek# description: Config realserver lo and apply noarpWEB_VIP=192.168.0.160. /etc/rc.d/init.d/functionscase “$1” instart)ifconfig lo:0 $WEB_VIP netmask 255.255.255.255 broadcast $WEB_VIP/sbin/route add -host $WEB_VIP dev lo:0echo “1” >/proc/sys/net/ipv4/conf/lo/arp_ignoreecho “2” >/proc/sys/net/ipv4/conf/lo/arp_announceecho “1” >/proc/sys/net/ipv4/conf/all/arp_ignoreecho “2” >/proc/sys/net/ipv4/conf/all/arp_announcesysctl -p >/dev/null 2>&1echo “RealServer Start OK”;;stop)ifconfig lo:0 downroute del $WEB_VIP >/dev/null 2>&1echo “0” >/proc/sys/net/ipv4/conf/lo/arp_ignoreecho “0” >/proc/sys/net/ipv4/conf/lo/arp_announceecho “0” >/proc/sys/net/ipv4/conf/all/arp_ignoreecho “0” >/proc/sys/net/ipv4/conf/all/arp_announceecho “RealServer Stoped”;;status)# Status of LVS-DR real server.islothere=`/sbin/ifconfig lo:0 | grep $WEB_VIP`isrothere=`netstat -rn | grep “lo:0” | grep $web_VIP`if [ ! “$islothere” -o ! “isrothere” ];then# Either the route or the lo:0 device# not found.echo “LVS-DR real server Stopped.”elseecho “LVS-DR Running.”fi;;*)# Invalid entry.echo “$0: Usage: $0 {start|status|stop}”exit 1;;esacexit 0./RealServer.sh start__________________________________________________________________________________________________________mysql 同步方法:1、环境描述。主机:192.168.0.201(A)主机:192.168.0.202(B)MYSQL 版本为5.1.212、授权用户。A:mysql> grant replication slave,file on *.* to ‘repl1’@’192.168.0.202’ identified by ‘123456’;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)B:mysql> grant replication slave,file on *.* to ‘repl2’@’192.168.0.201’ identified by ‘123456’;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)然后都停止MYSQL 服务器。3、配置文件。在两个机器上的my.cnf里面都开启二进制日志 。A:user = mysqllog-bin=mysql-binserver-id = 1binlog-do-db=testbinlog-ignore-db=mysqlreplicate-do-db=testreplicate-ignore-db=mysqllog-slave-updatesslave-skip-errors=allsync_binlog=1auto_increment_increment=2auto_increment_offset=1B:user = mysqllog-bin=mysql-binserver-id = 2binlog-do-db=testbinlog-ignore-db=mysqlreplicate-do-db=testreplicate-ignore-db=mysqllog-slave-updatesslave-skip-errors=allsync_binlog=1auto_increment_increment=2auto_increment_offset=24、重新启动MYSQL服务器。5、进入MYSQL的SHELL。A:mysql> flush tables with read lock\GQuery OK, 0 rows affected (0.00 sec)mysql> show master status\G*************************** 1. row ***************************File: mysql-bin.000002Position: 106Binlog_Do_DB: testBinlog_Ignore_DB: mysql1 row in set (0.00 sec)B:mysql> flush tables with read lock;Query OK, 0 rows affected (0.00 sec)mysql> show master status\G*************************** 1. row ***************************File: mysql-bin.000002Position: 106Binlog_Do_DB: testBinlog_Ignore_DB: mysql1 row in set (0.00 sec)6、在各自机器上执行CHANGE MASTER TO命令。A:mysql> change master to-> master_host=’192.168.0.202′,-> master_user=’repl2′,-> master_password=’123456′,-> master_log_file=’mysql-bin.000002′,-> master_log_pos=106;Query OK, 0 rows affected (0.01 sec)mysql> start slave;Query OK, 0 rows affected (0.00 sec)B:mysql> change master to-> master_host=’192.168.0.201′,-> master_user=’repl1′,-> master_password=’123456′,-> master_log_file=’mysql-bin.000002′,-> master_log_pos=106;Query OK, 0 rows affected (0.01 sec)mysql> start slave;Query OK, 0 rows affected (0.00 sec)7、查看各自机器上的IO进程和 SLAVE进程是否都开启。A:mysql> show processlist\G*************************** 1. row ***************************Id: 2User: replHost: 192.168.0.202:54475db: NULLCommand: Binlog DumpTime: 1590State: Has sent all binlog to slave; waiting for binlog to be updatedInfo: NULL*************************** 2. row ***************************Id: 3User: system userHost:db: NULLCommand: ConnectTime: 1350State: Waiting for master to send eventInfo: NULL*************************** 3. row ***************************Id: 4User: system userHost:db: NULLCommand: ConnectTime: 1149State: Has read all relay log; waiting for the slave I/O thread to update itInfo: NULL*************************** 4. row ***************************Id: 5User: rootHost: localhostdb: testCommand: QueryTime: 0State: NULLInfo: show processlist4 rows in set (0.00 sec)B:mysql> show processlist\G*************************** 1. row ***************************Id: 1User: system userHost:db: NULLCommand: ConnectTime: 2130State: Waiting for master to send eventInfo: NULL*************************** 2. row ***************************Id: 2User: system userHost:db: NULLCommand: ConnectTime: 1223State: Has read all relay log; waiting for the slave I/O thread to update itInfo: NULL*************************** 3. row ***************************Id: 4User: rootHost: localhostdb: testCommand: QueryTime: 0State: NULLInfo: show processlist*************************** 4. row ***************************Id: 5User: repl2Host: 192.168.0.201:50718db: NULLCommand: Binlog DumpTime: 1398State: Has sent all binlog to slave; waiting for binlog to be updatedInfo: NULL4 rows in set (0.00 sec)8、释放掉各自的锁,然后进行插数据测试。mysql> unlock tables;Query OK, 0 rows affected (0.00 sec)插入之前两个机器表的对比:A:mysql> show tables;+—————-+| Tables_in_test |+—————-+| t11_innodb || t22 |+—————-+B:mysql> show tables;+—————-+| Tables_in_test |+—————-+| t11_innodb || t22 |+—————-+从A机器上进行插入A:mysql> create table t11_replicas-> (id int not null auto_increment primary key,-> str varchar(255) not null) engine myisam;Query OK, 0 rows affected (0.01 sec)mysql> insert into t11_replicas(str) values-> (‘This is a master to master test table’);insert into t11_replicas(str) values (‘3’);Query OK, 1 row affected (0.01 sec)mysql> show tables;+—————-+| Tables_in_test |+—————-+| t11_innodb || t11_replicas || t22 |+—————-+3 rows in set (0.00 sec)mysql> select * from t11_replicas;+—-+—————————————+| id | str |+—-+—————————————+| 1 | This is a master to master test table |+—-+—————————————+1 row in set (0.00 sec)现在来看B机器:mysql> show tables;+—————-+| Tables_in_test |+—————-+| t11_innodb || t11_replicas || t22 |+—————-+3 rows in set (0.00 sec)mysql> select * from t11_replicas;select * from t11_replicas order by id;+—-+—————————————+| id | str |+—-+—————————————+| 1 | This is a master to master test table |+—-+—————————————+1 row in set (0.00 sec)现在反过来从B机器上插入数据:B:mysql> insert into t11_replicas(str) values(‘This is a test 2’);Query OK, 1 row affected (0.00 sec)mysql> select * from t11_replicas;+—-+—————————————+| id | str |+—-+—————————————+| 1 | This is a master to master test table || 2 | This is a test 2 |+—-+—————————————+2 rows in set (0.00 sec)我们来看AA:mysql> select * from t11_replicas;+—-+—————————————+| id | str |+—-+—————————————+| 1 | This is a master to master test table || 2 | This is a test 2 |+—-+—————————————+2 rows in set (0.00 sec)好了。现在两个表互相为MASTER。————————————————————————————————————————————————————————————————————————————————————————————————mysql的编译安装yum install gccyum install ncurses-develyum install gcc-c++./configure –prefix=/usr/local/mysql –localstatedir=/var/lib/mysql –with-comment=Source –with-server-suffix=-Community –with-mysqld-user=mysql –without-debug –with-big-tables –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=all –with-pthread –enable-static –enable-thread-safe-client –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –without-innodb –without-ndb-debugmakemake installcp support-files/my-medium.cnf /usr/local/mysql/my.cnf修改my.cnf[mysqld]user=root./mysql_install_db –user=root –basedir=/usr/local/mysql/ –datadir=/var/lib/mysql/./mysql_install_db –user=root –basedir=/usr/local/mysql5.1/ –datadir=/var/lib/mysql5.1/————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————nginx + phpnginx./configure –prefix=/usr/local/nginx –with-openssl=/usr/include –with-pcre=/usr/include/pcre/ –with-http_stub_status_module –with-openssl=/usr/local/opensslmakemake installphpyum -y install curl-devellibpng-devellibmcrypt./configure –piefix=/usr/local/libmcryptyum install libxml2yum install libxml2-devel -y./configure –prefix=/usr/local/php-fcgi –enable-fpm –with-config-file-path=/usr/local/php-fcgi/etc –enable-zend-multibyte –with-mysql=/usr/local/mysql –with-libxml-dir=/usr/local/libxml2 –with-gd –with-jpeg-dir –with-png-dir –with-bz2 –with-freetype-dir –with-iconv-dir –with-zlib-dir –with-curl –with-mhash –with-openssl –enable-bcmath –with-mcrypt=/usr/local/libmcrypt –enable-sysvsem –enable-inline-optimization –enable-soap –enable-gd-native-ttf –enable-ftp –enable-mbstring –enable-exif –disable-debug –disable-ipv6makemake installserver {listen 80;server_name bunny.claverstat.com;location / {root /date/tz;index index.html index.htm index.php;if (-f $request_filename/index.html){rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){rewrite (.*) $1/index.php;}if (!-f $request_filename){rewrite (.*) /index.php;}}location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_buffers 2 256k;fastcgi_buffer_size 128K;fastcgi_busy_buffers_size 256K;fastcgi_temp_file_write_size 256K;include fastcgi_params;fastcgi_param SCRIPT_FILENAME /date/tz$fastcgi_script_name;}}————————————————————————————————————————————————————————————————————————————————————————————————jdk直接执行 ./jdk-6u25-linux-x64.bin默认安装在执行目录——————————————————————————————————————————————————————————————————————————————————————————————————resin解压 resin-3.1.10配置 java_home 直接用
上一篇: nginx
-
Liunx 防火墙 iptables
iptables 的命令参数 -t<表>:指...
-
虚拟服务器安装日志
df -h 格式化硬盘 fdisk /dev/vdb 1 p w...
-
nginx 日志配置
nginx 日志相关指令主要有两条, log_fo...
-
mysql的编译安装
mysql的编译安装 下载目录: http://gd....
-
Mysql 5.7.20 glibc 安装
1、下载mysql glibc 包wget https://dow...
-
nginx
pcre zlib openssl 怎么捣鼓也没搞定,...
相关推荐
您好!请登录
已有0评论