CentOS下关于配置zookeeper集群时,克隆后的虚拟机无法启动Hadoop的解决方案

CentOS下关于配置zookeeper集群时,克隆后的虚拟机无法启动Hadoop的解决方案,第1张

准备材料:

被克隆主机:Hadoop01(名称我随便起的,方便记忆)

克隆后的主机:Hadoop01(克隆后的主机名与被克隆的主机名一样后期会修改为Hadoop02)

错误原因:克隆的虚拟机主机名和被克隆的虚拟机名相同,而在启动Hadoop集群的时候,配置文件中读取的主机名不匹配,所以无法启动Hadoop集群。我们只需要修改配置信息和主机名就可以了,多台机器,只需要在需要启动Hadoop集群的机器上修改配置文件

解决方案:

第一步:首先要修改克隆后的主机ip

vim /etc/sysconfig/network-scripts/ifcfg-eth0

  1>修改HWADDR:00:0c:29:xx:xx:xx(前六个数基本相同,后面六个数根据虚拟机设置查看)

  2>修改IPADDR:192.168.xxx.xxx(具体IP地址根据被克隆主机的ip修改)

  3>重启网卡:service network restart

第二步:查看被克隆的主机的主机名并修改

  1>vim /etc/sysconfig/network

    例:原主机名Hadoop01  修改后------>Hadoop02

  2>source /etc/sysconfig/network

第三步:建立主机名与ip地址一一对应的关系

  vim /etc/hosts

  例:192.168.247.151 Hadoop02

第四步:接下来修改Hadoop的配置文件

在这个路径下行:/home/software/hadoop-2.7.1/etc/hadoop

不同人可能路径可能存在差异

    1>修改core-site.xml

    凡是被克隆主机名均修改为现在的主机名,也就是将Hadoop01修改为Hadoop02

    2>修改yarn-site.xml

    凡是被克隆主机名均修改为现在的主机名,也就是将Hadoop01修改为Hadoop02

    3>修改slaves

    凡是被克隆主机名均修改为现在的主机名,也就是将Hadoop01修改为Hadoop02

    4>删除tmp文件

    在这个路径下/home/software/hadoop-2.7.1删除tmp文件

不同人路径可能不同

    5>格式化namenode(请谨慎格式化)

    hadoop namenode -format

第五步:执行start-all.sh和jps查看所有进程是否启动成功

本文只是记录自己学习过程中的疑难问题和解决方案,如果逻辑不通或者知识点有错,请不要吝啬批评和更正,共同学习进步,不喜勿喷,喷子止步,谢谢合作

事先准备,已经成功安装好pgsql9.6

1.citus安装

首先citus是pgsql的一个扩展,首先更新yum源,执行命令:yum update,然后安装citus,执行命令:

2.登录pgsql并创建citus扩展。执行命令:su postgres 然后执行:psql 登录pgsql里面,并执行sql命令 :

如下图所示:

然后会报如下图所示错误。

然后找到文件pg_hba.conf,在文件末尾处添加配置:

然后重启pgsql,一定要记得重启pgsql,修改的配置文件才生效。

然后在登录pgsql后,执行sql命令,创建citus扩展,如图所示:

最后,克隆其他2台机器,ip地址分别为192.168.1.235和192.168.1.236 。执行命令如下图,成功后也如图所示,代表集群创建成功。

一、环境准备

主机IP 主机名 *** 作系统版本 PXC

192.168.244.146 node1 CentOS7.1 Percona-XtraDB-Cluster-56-5.6.30

192.168.244.147 node2 CentOS7.1 Percona-XtraDB-Cluster-56-5.6.30

192.168.244.148 node3 CentOS7.1 Percona-XtraDB-Cluster-56-5.6.30

关闭防火墙或者允许3306, 4444, 4567和4568四个端口的连接

关闭SElinux

二、下载PXC

安装PXC yum源

# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

这样会在/etc/yum.repos.d下生成percona-release.repo文件

安装PXC

# yum install Percona-XtraDB-Cluster-56

最终下载下来的版本是Percona-XtraDB-Cluster-56-5.6.30

注意:三个节点上均要安装。

三、配置节点

配置节点一

修改node1的/etc/my.cnf

复制代码

[mysqld]

datadir=/var/lib/mysql

user=mysql

# Path to Galera library

wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

# Cluster connection URL contains the IPs of node#1, node#2 and node#3

wsrep_cluster_address=gcomm://192.168.244.146,192.168.244.147,192.168.244.148

# In order for Galera to work correctly binlog format should be ROW

binlog_format=ROW

# MyISAM storage engine has only experimental support

default_storage_engine=InnoDB

# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera

innodb_autoinc_lock_mode=2

# Node #1 address

wsrep_node_address=192.168.244.146

# SST method

wsrep_sst_method=xtrabackup-v2

# Cluster name

wsrep_cluster_name=my_centos_cluster

# Authentication for SST method

wsrep_sst_auth="sstuser:s3cret"

复制代码

启动node1

# systemctl start mysql@bootstrap.service

注意:这个是CentOS 7下的启动方式,如果是CentOS 6,则启动方式为 # /etc/init.d/mysql bootstrap-pxc

之所以采用bootstrap启动,其实是告诉数据库,这是第一个节点,不用进行数据的同步。

利用这种方式启动,相当于wsrep_cluster_address方式设置为gcomm://。

此时,可登录客户端查看数据库的状态

mysql>show status like 'wsrep%'

主要关注以下参数的状态

复制代码

+------------------------------+--------------------------------------+

| Variable_name| Value|

+------------------------------+--------------------------------------+

| wsrep_local_state_uuid | 1fbb69e3-32a3-11e6-a571-aeaa962bae0c |

...

| wsrep_local_state| 4

| wsrep_local_state_comment| Synced |

...

| wsrep_cluster_size | 1

...

| wsrep_cluster_status | Primary |

| wsrep_connected | ON |

...

| wsrep_ready | ON |

复制代码

在上面的配置文件中,有个wsrep_sst_auth参数。该参数是用于其它节点加入到该集群中,利用XtraBackup执行State Snapshot Transfer(类似于全量同步)的。

所以,接下来是授权

mysql>CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 's3cret'

mysql>GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost'

mysql>FLUSH PRIVILEGES

配置节点二

修改node2的/etc/my.cnf

复制代码

[mysqld]

datadir=/var/lib/mysql

user=mysql

# Path to Galera library

wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

# Cluster connection URL contains the IPs of node#1, node#2 and node#3

wsrep_cluster_address=gcomm://192.168.244.146,192.168.244.147,192.168.244.148

# In order for Galera to work correctly binlog format should be ROW

binlog_format=ROW

# MyISAM storage engine has only experimental support

default_storage_engine=InnoDB

# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera

innodb_autoinc_lock_mode=2

# Node #2 address

wsrep_node_address=192.168.244.147

# SST method

wsrep_sst_method=xtrabackup-v2

# Cluster name

wsrep_cluster_name=my_centos_cluster

# Authentication for SST method

wsrep_sst_auth="sstuser:s3cret"

复制代码

启动node2

# systemctl start mysql

如果是CentOS 6,则启动方式为 # /etc/init.d/mysql start

如果在启动的过程中出现问题,可查看mysql的错误日志,如果是RPM安装,默认是/var/lib/mysql/主机名.err

启动完毕后,也可通过mysql>show status like 'wsrep%'命令查看集群的信息。

配置节点三

修改node3的/etc/my.cnf

复制代码

[mysqld]

datadir=/var/lib/mysql

user=mysql

# Path to Galera library

wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

# Cluster connection URL contains the IPs of node#1, node#2 and node#3

wsrep_cluster_address=gcomm://192.168.244.146,192.168.244.147,192.168.244.148

# In order for Galera to work correctly binlog format should be ROW

binlog_format=ROW

# MyISAM storage engine has only experimental support

default_storage_engine=InnoDB

# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera

innodb_autoinc_lock_mode=2

# Node #3 address

wsrep_node_address=192.168.244.148

# SST method

wsrep_sst_method=xtrabackup-v2

# Cluster name

wsrep_cluster_name=my_centos_cluster

# Authentication for SST method

wsrep_sst_auth="sstuser:s3cret"

复制代码

启动node3

# systemctl start mysql

登录数据库,查看集群的状态

复制代码

+------------------------------+--------------------------------------+

| Variable_name| Value|

+------------------------------+--------------------------------------+

| wsrep_local_state_uuid | 1fbb69e3-32a3-11e6-a571-aeaa962bae0c |

...

| wsrep_local_state| 4

| wsrep_local_state_comment| Synced |

...

| wsrep_cluster_size | 3

...

| wsrep_cluster_status | Primary |

| wsrep_connected | ON |

...

| wsrep_ready | ON

复制代码

通过wsrep_cluster_size可以看出集群有3个节点。

四、 测试

下面来测试一把,在node3中创建一张表,并插入记录,看node1和node2中能否查询得到。

node3中创建测试表并插入记录

root@node3 >create table test.test(id int,description varchar(10))

Query OK, 0 rows affected (0.18 sec)

root@node3 >insert into test.test values(1,'hello,pxc')

Query OK, 1 row affected (0.01 sec)

node1和node2中查询

复制代码

root@node1 >select * from test.test

+------+-------------+

| id | description |

+------+-------------+

|1 | hello,pxc |

+------+-------------+

1 row in set (0.00 sec)

复制代码

复制代码

root@node2 >select * from test.test

+------+-------------+

| id | description |

+------+-------------+

|1 | hello,pxc |

+------+-------------+

1 row in set (0.05 sec)

复制代码

至此,Percona XtraDB Cluster搭建完毕~

总结:

1. 刚开始启动node2的时候,启动失败,错误日志中报如下信息:

复制代码

2016-06-15 20:06:09 4937 [ERROR] WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 (Connection timed out)

at gcomm/src/pc.cpp:connect():162

2016-06-15 20:06:09 4937 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208: Failed to open backend connection: -110 (Connection timed out)

2016-06-15 20:06:09 4937 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1387: Failed to open channel 'my_centos_cluster' at 'gcomm://192.168.244.146,192.168.244.147,192.168.244.148': -110 (Connection timed out)

2016-06-15 20:06:09 4937 [ERROR] WSREP: gcs connect failed: Connection timed out

2016-06-15 20:06:09 4937 [ERROR] WSREP: wsrep::connect(gcomm://192.168.244.146,192.168.244.147,192.168.244.148) failed: 7

2016-06-15 20:06:09 4937 [ERROR] Aborting

复制代码

复制代码

2016-06-15 20:27:03 5870 [ERROR] WSREP: Failed to read 'ready <addr>' from: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.244.147' --datadir '/var/lib/mysql/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '5870' ''

Read: '(null)'

2016-06-15 20:27:03 5870 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.244.147' --datadir '/var/lib/mysql/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '5870' '' : 2 (No such file or directory)

2016-06-15 20:27:03 5870 [ERROR] WSREP: Failed to prepare for 'xtrabackup-v2' SST. Unrecoverable.

2016-06-15 20:27:03 5870 [ERROR] Aborting


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11251505.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存