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

環境:

          N F S: 172.16.0.3 (OS CentOS 7)

          node1:172.16.0.5 (OS CentOS 6.7)

          node2:172.16.0.6 (OS CentOS 6.7)

        浮動IP:172.16.0.168

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

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

# 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 不同時間了:

# 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 22 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,這里太簡單 不上圖了

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

2、填上用戶:在數據庫創建的:wordpress

3、填上密碼:redhat

4、其它根據自己定義填寫即可。

Hearbeat-Gui資源配置:
# hb_gui &

1、Resources新建組資源,并命名,注意Parameters里面的值

blob.png

blob.png

blob.png

blob.png

2、訪問測試

blob.png

3、節點切換并訪問測

blob.png

原創文章,作者:N24-SunshineBoy,如若轉載,請注明出處:http://www.www58058.com/54997

(0)
N24-SunshineBoyN24-SunshineBoy
上一篇 2016-10-27 17:28
下一篇 2016-10-27 20:06

相關推薦

  • 第二周作業

    1、Linux上的文件管理類命令都有哪些,其常用的使用方法及其相關示例演示。 目錄管理類的命令: mkdir, rmdir mkdir:make directories mkdir [OPTION]… DIRECTORY… -p: 自動按需創建父目錄; -v: verbose,顯示詳細過程; -m MODE:直接給定權限; 注意:路徑…

    Linux干貨 2018-01-17
  • bash特性、bash編程

    bash基礎特性: 命令行展開:~,{} 命令別名:alias,unalias 命令歷史:history 命令和路徑補全:$PATH glob通配符:*,?,[],[^], 快捷鍵:Ctrl+{a,e,l,c,u,k} 命令hash:   bash通配符及特殊符號: 通配符: ?:任意一個字符; *:匹配任意個任意字符; []:匹配括號內的任意一個…

    Linux干貨 2018-03-21
  • 重構與模式:改善代碼三部曲中的第三部

    一、改善代碼的三部曲    《設計模式》-> 《重構》-> 《重構與模式》。也就是設計->重構->重構出新設計。    《設計模式》主要詳細說明20幾種模式,為我們帶來了常見設計問題的經典解決方案,從而改變了整個面向對象開發的面貌。為設計而著。    《重構》改善既有代碼的設…

    Linux干貨 2015-04-07
  • ssh登陸與端口轉發

    ssh: secure shell, protocol, 22/tcp,  安全的遠程登錄     具體的軟件實現:OpenSSH  : ssh 協議的開源實現,CentOS 默認安裝dropbear :另一個開源實現SSH      協議版本   …

    Linux干貨 2017-04-13
  • 初學Linux之shell腳本編程

    shell程序的特點;shell腳本的結構和格式要求;變量;算術運算和邏輯運算;條件測試;防止擴展和shell登錄的相關配置文件

    2018-01-01
  • 第六周作業

    第六周作業 1、復制/etc/rc.d/rc.sysinit文件至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#; cp /etc/rc.d/rc.sysinit /tmp vim /tmp/rc.sysinit :進入末行模式 % s/^[[:space:]]/#&…

    Linux干貨 2016-10-09

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-11-02 16:41

    如果能加入一些架構展示,效果會更好點,加油!

欧美性久久久久