Heartbeat-Gui V2 實現HA LAMP 搭建wordpress博客


環境:
php

          N F S: 172.16.0.3 (OS CentOS 7)
html

          node1:172.16.0.5 (OS CentOS 6.7)
node

          node2:172.16.0.6 (OS CentOS 6.7)
mysql

        浮動IP:172.16.0.168
linux


php php-mysql 安裝:
# yum install php php-mysql 倆個節點都安裝
Heartbeat 安裝:
  • 互信操做:倆邊都操做:sql

# ssh-keygen -t rsa
 # ssh-copy-id -i .ssh/id_rsa.pub root@x.x.x.x
  • 修改主機名:shell

# cat /etc/sysconfig/network	//node2   NETWORKING=yes   HOSTNAME=node2.sunshine.com
   
 # cat /etc/sysconfig/network  //node1   NETWORKING=yes   HOSTNAME=node1.sunshine.com
  • 本地/etc/hosts解析:數據庫

#  cat /etc/hosts | tail -2
    172.16.0.5 node2.sunshine.com node2	172.16.0.6 node1.sunshine.com node1 #  cat /etc/hosts | tail -2
	172.16.0.5 node2.sunshine.com node2	172.16.0.6 node1.sunshine.com node1
  • 同步時間:兩邊都操做,這裏測試就不作crontab 不一樣時間了:vim

# service ntpdate  start
 
 # [root@HA2 ~]# date ;ssh node2 'date'
	Wed Oct 26 15:28:32 CST 2016
	Wed Oct 26 15:28:32 CST 2016
  • 重啓:服務器

# shutdown -r now
  • 安裝epel源:

# rpm -Uivh  ftp://ftp.pbone.net/mirror/dl.iuscommunity.org/pub/ius/archive/Redhat/6/i386/epel-release-6-5.noarch.rpm
  • 安裝依賴:

# yum install net-snmp-libs libnet PyXML pygtk2-libglade -y
# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm \  
> heartbeat-stonith-2.1.4-12.el6.x86_64.rpm   \
> heartbeat-pils-2.1.4-12.el6.x86_64.rpm \
> heartbeat-gui-2.1.4-12.el6.x86_64.rpm
  • 如報如下錯誤:安裝libtool-ltdl 既能夠:

error: Failed dependencies:
	libltdl.so.7()(64bit) is needed by heartbeat-2.1.4-12.el6.x86_64
	libltdl.so.7()(64bit) is needed by heartbeat-stonith-2.1.4-12.el6.x86_64
	libltdl.so.7()(64bit) is needed by heartbeat-pils-2.1.4-12.el6.x86_64# yum install libtool-ltdl -y     //安裝libtool-ltdl

-安裝支持xshell Xmanger包,不然網絡上很方法也是不可用的:

# yum install xorg-x11-xauth   //若是不安裝使用hb_gui是沒法調用x11
  • ha.cf配置:

# grep -v "#" ha.cf 
	logfile	/var/log/heartbeat-log
	mcast eth0 225.10.210.1 694 1 0
	auto_failback on
	node	node1.sunshine.com
	node	node2.sunshine.com
	crm	on
	ping 172.16.0.1
 # grep -v "#" authkeys 
	auth 2
	2 sha1 Dn880wJZxfsUpioJWy7FgQ 
 # passwd hacluster			//在哪裏啓動,就在哪裏設置hacluster密碼
 
 # hb_gui &
 compression	bz2
compression_threshold 2
  • authkeys配置

[root@node2 ha.d]# cat authkeys | tail -4 | grep -v "#"
auth 2
2 sha1 Dn880wJZxfsUpioJWy7FgQ
  • 在node{1|2}清除iptables並關閉selinux

# iptables -F# setenforce 0# cat /etc/selinux/config | tail -3 | head -1
	SELINUXTYPE=targeted
  • httpd 安裝:

#  yum install httpd -y								//node{1|2}
 
 # echo "<h1>node1</h1>" > /var/www/html/index.html		//node1執行
 
 # echo "<h1>node2</h1>" > /var/www/html/index.html		//node2執行
 
 # curl node{1,2}			//訪問測試
	<h1>node1</h1>
	<h1>node2</h1>
 # service httpd stop ;ssh node2 'service httpd stop'
	Stopping httpd: [  OK  ]
	Stopping httpd: [  OK  ]

 # chkconfig httpd off ;ssh node2 'chkconfig httpd off'  //關閉httpd自動啓動
 
 # chkconfig httpd --list ;ssh node2 'chkconfig httpd --list'//查看是否關閉
	httpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
	httpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
  • NFS Server搭建:這是在NFS服務器上執行

# groupadd -g 306 mysql
 # useradd -g 306 -u 306 -M -r mysql
 # mkdir /data/mydata
 # chown -R mysql.mysql /data/mydata
 # cat /etc/exports		//編輯須要導出的文件
	/data/mydata 172.16.0.0/24(rw,no_root_squash)	//no_root_squash表示遠端主機root用戶不轉換nobody用戶

 # systemctl start nfs.service	//啓動nfs服務
 
 # cat /etc/rc.local | tail -1	//加入開機啓動
	/usr/bin/systemctl start nfs.service
PerconaMySQL 安裝:
# mount -t nfs 172.16.0.3:/data/mydata /mydata	//掛載nfs文件至本地
    # yum install openssl-devel -yes                //安裝openssl-devel包,至此Preconamysql的ssl
 # cd /usr/lib64                                 //進入lib64# ln -s libssl.so.1.0.1e libssl.so.6            //軟鏈接,由於Preconamysql要依賴該庫,可是咱們系統上的是libssl.so.1.0.1e
 # ln -sv libcrypto.so libcrypto.so.6            //軟鏈接,由於Preconamysql要依賴該庫,可是咱們系統上的是libcrypto.so
 # tar xf /usr/local/src/Percona-Server-5.6.27-rel76.0-Linux.x86_64.ssl098e.tar.gz -C /usr/local   //解壓縮至/usr/local,我的習慣
 # cd /usr/local                                 //進入local
 # ln -sv Percona-Server-5.6.27-rel76.0-Linux.x86_64.ssl098e.tar.gz mysql    //不要問爲何,你們都這麼作
 # groupadd -g 306 mysql                         //新建組,指定GID306
 # useradd -g 306 -u 306 -r -M mysql             //新建用戶,指定GID,UID爲306
 # mkdir /mydata                                 //建立NFS掛載點
 # cd /usr/local/mysql                           //進入程序包
 # chown -R mysql.mysql ./*                      //-R遞歸
 # scripts/mysql_install_db --datadir=/mydata/ --user=mysql      //初始化
 # cp -p  support-files/mysql.server /etc/init.d/mysqld          //拷貝啓動腳本
 # vim /etc/my.cnf                             //mysql的配置文件,裏面的參數我調的很小,是由於僅作博客測試使用
 # The MySQL server[mysqld]
 port                    = 3306
 user                    = mysql
 datadir                 = /mydata
 tmpdir                  = /dev/shm
 slave-load-tmpdir       = /tmp
 socket                  = /mydata/mysql.sock
 key_buffer_size         = 32M
 max_allowed_packet      = 8M # table_cache             = 30s
 join_buffer_size        = 16M
 sort_buffer_size        = 16M read_buffer_size        = 16M read_rnd_buffer_size    = 16M
 myisam_sort_buffer_size = 32M
 query_cache_size        = 16M
 query_cache_type        = 1
 max_tmp_tables          = 64
 tmp_table_size          = 64M
 max_heap_table_size     = 64M
 thread_cache_size       = 32
 thread_concurrency      = 16
 max_connections         = 1986
 max_user_connections    = 0
 max_connect_errors      = 99999999
 wait_timeout            = 28800
 interactive_timeout     = 7200
 slow_query_log          = 1
 long_query_time         = 3
 log_slow_slave_statements=1
 #slow_query_log_timestamp_always =1
 slow_query_log_file     = /mydata/slow.log
 back_log                = 200
 myisam_repair_threads   = 1
 myisam-recover          = DEFAULT
 expire_logs_days        = 20
 pid-file                = /mydata/mysql.pid
 binlog_format           = mixed


 init-connect='SET NAMES utf8'
 character-set-server=utf8
 skip-character-set-client-handshake bind-address=0.0.0.0

 skip-external-locking #skip-symlink
 log-slave-updates
 skip-name-resolve # read_only
 skip-slave-start

 server-id               = 3306 
 log-bin                 = 3306-bin
 relay-log               = 3306-relay-bin log-error=error.log #-------------    innodb  --------------
 innodb_file_format             = Barracuda
 default-storage-engine          = InnoDB
 innodb_buffer_pool_size         = 64M 
 innodb_additional_mem_pool_size = 32M
 innodb_data_file_path           = ibdata1:100M:autoextend # innodb_autoextend_increment     = 100M
 innodb_flush_log_at_trx_commit  = 0
 innodb_log_buffer_size          = 8M
 innodb_log_file_size            = 32M
 innodb_log_files_in_group       = 3
 innodb_max_dirty_pages_pct      = 90
 innodb_lock_wait_timeout        = 20
 innodb_file_per_table           = 1
 innodb_flush_method = O_DIRECT
 innodb_support_xa = 0
 innodb_io_capacity = 500
 # innodb_buffer_pool_instances    = 4

 [client]
 user                    = mysql
 port                    = 3306
 socket                  = /mydata/mysql.sock

 [myisamchk]
 key_buffer = 32
 sort_buffer_size = 32
 read_buffer = 32M
 write_buffer = 32M
# service mysqld start		//測試是否可以啓動
		# service mysqld stop		//而後中止服務
 # chkconfig mysqld off		//關閉自動啓動  ps:node{1|2}都是同樣的操做
安裝博客
  • 下載程序包

# cd /usr/local/src 
 
 # wget https://cn.wordpress.org/wordpress-4.5.3-zh_CN.tar.gz
  • 解壓並設置 777 權限,這邊爲了方便

# tar xf wordpress-4.5.3-zh_CN.tar.gz -C /var/www/html/
 
 # cd /var/www/html/
 
 # chown -R 777  wordpress
  • 手動啓動mysql

# service mysqd start
  • 進入mysql建立wordpress庫,提供給wordpress初始化呢使用

# mysql -uroot -p		//回車輸入本身的密碼,沒設定密碼直接回車
 
 # CREATE DATABASE wordpess;
  • 受權wordpress庫權限,生產機建議不要使用通配符

# GRANT ALL ON wordpress.* TO wordpress@‘172.16.%.%' INDENTIFIED BY 'redhat';
 
 # FLUSH PRIVILEGES;
博客初始化:先手動啓動mysql,初始化完畢後再手動關閉mysql,這裏太簡單 不上圖了

一、填上mysql地址:也就是咱們的浮動IP:172.16.0.168

二、填上用戶:在數據庫建立的:wordpress

三、填上密碼:redhat

四、其它根據本身定義填寫便可。

Hearbeat-Gui資源配置:
# hb_gui &

一、Resources新建組資源,並命名,注意Parameters裏面的值

blob.png

blob.png

blob.png

blob.png

二、訪問測試

blob.png

三、節點切換並訪問測

blob.png

相關文章
相關標籤/搜索