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.178linux.com/54997

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

相关推荐

  • kickstart文件及引导镜像的制作流程

    kickstart文件及引导镜像的制作流程 kickstart文件制作流程 安装制作kickstart文件的图形界面工具 [root@slave1 ~]# yum install system-config-kickstart 开启工具 [root@slave1 ~]# system-config-kickstart 在打开的图形界面中通过file菜单选项选…

    Linux干货 2017-09-04
  • Linux进程篇16.4top命令:进程管理工具

    top命令:进程管理工具

    2017-12-18
  • 8.3_Linux习题和作业

    课堂习题 1.当用户xiaoming对/testdir 目录无执行权限时,意味着无法做哪些操作? 答:不能cd进该目录 2.当用户xiaoqiang对/testdir 目录无读权限时,意味着无法做哪些操作? 答:不能查看目录内的文件列表,不能cd,也不能查看目录里面文件的元数据 3.当用户wangcai 对/testdir 目录无写权限时,该目录下的只读文件…

    Linux干货 2016-08-04
  • CentOS开发环境搭建

        一个月之前将系统换为Linux,昨天系统运行的时候突然死机,开机之后进不了系统,并且BIOS无法识别硬盘,无奈只有在普通硬盘上重装系统。搭建开发环境,为了避免再次遇到类似现象,或在下次遇到这类问题快速搭建开发环境,记录开发环境搭建的过程。 1、启用wifi echo "blacklist&n…

    Linux干货 2016-08-04
  • ldirectord 结合ipvsadm 配置nat,dr模型

    ldirectord 结合ipvsadm 配置nat,dr模型  一、nat模型 1、 drector # wget ftp://172.16.0.1/pub/Sources/7.x86_64/crmsh/ldirectord-3.9.6-0rc1.1.1.x86_64.rpm # yum -y install nginx (同时用于做为sorry…

    Linux干货 2014-01-03
  • grep、egrep正则表达式之初窥门径

    何谓正则表达式 正则表达式,又称正规表示法、常规表示法(Regular Expression,在代码中常简写为regex、regexp或RE),是一类字符所书写的模式,其中许多字符不表示其字面意义,而是表达控制或通配等功能。正则表达式使用单个字符串来描述、匹配一系列符合某个句法规则的字符串。在很多文本编辑器里,正则表达式通常被用来检索、替换那些符合某个模式的…

    2015-03-19

评论列表(1条)

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

    如果能加入一些架构展示,效果会更好点,加油!