迁移Cloudera Manager Server

参考 Moving the Cloudera Manager Server to a New Host

Database Backing up and Restore

根据官方的参考文档,如果在另外一个节点上新建一个供Cloudera Manager使用的数据库,需要把原来的数据库的内容进行back up,然后在新的数据库中进行restore。然而,怎样restore,确实语焉不详。

Cloudera Manager可以使用多种数据库,如PostgreSQL、MySQL、Oracle等。同时,它也可以使用external database或者embedded database。这里,我们以embedded PostgreSQL database为例。


Backing up

本步骤在原来的数据库节点上进行操作。

  1. 登录到该节点上

  2. 获取Cloudera Manager Database的name/user/password 
    这些信息在文件 /etc/cloudera-scm-server/db.properties中。

    # Auto-generated by initialize_embedded_db.sh 

    # 20141212-164925 

    # These are database settings for CM Manager 

    com.cloudera.cmf.db.type=postgresql 
    com.cloudera.cmf.db.host=localhost:7432 
    com.cloudera.cmf.db.name=scm 
    com.cloudera.cmf.db.user=scm 
    com.cloudera.cmf.db.password=jFTDfcNqmL

  3. 导出数据 
    以root用户执行以下命令:

       
       
    1. pg_dump -h localhost -p 7432 -U scm > /tmp/scm_server_db_backup.$(date +%Y%m%d)

    该命令会要求输入密码,密码就在上面步骤2的文件中。


 新机器安装DB-(会自动安装CM)

You can move the Cloudera Manager Server if either the Cloudera Manager database server or a currentback up of the Cloudera Manager database is available.

To move the Cloudera Manager Server:
  1. Identify a new host on which to install Cloudera Manager.
  2. Install Cloudera Manager on a new host, using the method described under Install the Cloudera Manager Server Packages.Important:
    • The Cloudera Manager version on the destination host must match the version on the source host.
    • Do not install the other components, such as CDH and databases.

 

           安装Cloudera Manager的embedded PostgreSQL,可以通过如下命令进行:

yum -y install cloudera-manager-server-db-2


如果CM没有被自动安装,则可以按下面步骤安装:

【Install the Cloudera Manager Server Packages】

Install the Cloudera Manager Server packages either on the host where the database is installed, or on a host that has access to the database. This host need not be a host in the cluster that you want to manage with Cloudera Manager. On the Cloudera Manager Server host, type the following commands to install the Cloudera Manager packages.

 sudo yum -y install cloudera-manager-daemons cloudera-manager-serve

If you choose an Oracle database for use with Cloudera Manager, edit the /etc/default/cloudera-scm-server file on the Cloudera Manager server host. Locate the line that begins with export CM_JAVA_OPTS and change the -Xmx2G option to -Xmx4G.

 

  1. Copy the entire content of /var/lib/cloudera-scm-server/ on the old host to that same path on the new host. Ensure you preserve permissions and all file content.
  2. If the database server is not available:
    1. Install the database packages on the host that will host the restored database. This could be the same host on which you have just installed Cloudera Manager or it could be a different host. If you used the embedded PostgreSQL database, install the PostgreSQL package as described inEmbedded PostgreSQL Database. If you used an external MySQL, PostgreSQL, or Oracle database, reinstall following the instructions in Cloudera Manager and Managed Service Datastores.
    2. Restore the backed up databases to the new database installation.


数据库停止命令:   rm -rf /var/lib/cloudera-scm-server-db/data/postmaster.pid

 错误描述:
修复已存在目录 /var/lib/cloudera-scm-server-db/data 的权限 ... initdb: 无法改变目录 "/var/lib/cloudera-scm-server-db/data" 的权限: 权限不够
Could not initialize database server.
  This usually means that your PostgreSQL installation failed or isn't working properly.
  PostgreSQL is installed using the set of repositories found on this machine. Please
  ensure that PostgreSQL can be installed. Please also uninstall any other instances of
  PostgreSQL and then try again., giving up
 
解决方法:  
chown -R cloudera-scm:cloudera-scm /var/lib/cloudera*

并执行如下命令:

 su -s /bin/bash cloudera-scm -c "touch /var/log/cloudera-scm-server/db.log; /usr/share/cmf/bin/initialize_embedded_db.sh /var/lib/cloudera-scm-server-db/data /var/log/cloudera-scm-server/db.log"
 su -s /bin/bash cloudera-scm -c "pg_ctl start -w -D /var/lib/cloudera-scm-server-db/data -l /var/log/cloudera-scm-server/db.log"

安装好后,不同的用户会有各自的密码。 用户cloudera-scm的密码 在文件 /var/lib/cloudera-scm-server-db/data/generated_password.txt 中,其内容为: wKojqDE2uw The password above was generated by /usr/share/cmf/bin/initialize_embedded_db.sh (part of the cloudera-manager-server-db package)  and is the password for the user 'cloudera-scm' for the database in the current directory.  Generated at 20141212-164925. 用户scm的密码 在文件 /etc/cloudera-scm-server/db.properties 中,其内容为:  # Auto-generated by initialize_embedded_db.sh  #  # 20141212-164925  #  # These are database settings for CM Manager  #  com.cloudera.cmf.db.type=postgresql  com.cloudera.cmf.db.host=localhost:7432  com.cloudera.cmf.db.name=scm  com.cloudera.cmf.db.user=scm  com.cloudera.cmf.db.password=jFTDfcNqmL Start the PostgreSQL database: $ sudo service cloudera-scm-server-db start

Restoring


现在,我们已经将原来的数据库内容导出到一个文件中了。下面,将把这些导出的数据恢复到一个新建的PostgreSQL数据库中。
实际上我们之前是把所有的数据库的内容全部导出了,因此我们不用这个命令,而是用另一个命令:
  psql -h localhost -p 7432 -U scm < /tmp/ scm_server_db_backup.... #dumpfile


这样就会恢复所有的数据库内容。
执行上面的命令时,会要求输入密码,这里的密码保存在新安装的PostgreSQL所在节点的/etc/cloudera-scm-server/db.properties文件中。


service cloudera-scm-server restart


more /var/lib/cloudera-scm-server-db/data/pg_log/postgresql-Sat.log 
more /var/log/cloudera-scm-server/db.log 

日志内容:

       postgres cannot access the server configuration file "/var/lib/cloudera-scm-server-db/data/postgresql.conf": Permission denied

       postgres cannot access the server configuration file "/var/lib/cloudera-scm-server-db/data/postgresql.conf": Permission denied

原因:可能是SELinux 没有禁用、防火墙没有禁用。
查看SELinux状态:/usr/sbin/sestatus -v      SELinux status: enabled
解决方法:  关闭SELinux:
        1、临时关闭(不用重启机器):  setenforce 0 
        2、修改配置文件需要重启机器:
                修改/etc/selinux/config 文件     将SELINUX=enforcing改为SELINUX=disabled
                重启机器即可


错误描述:
Starting cloudera-scm-server:                              [失败]
查看embedded PostgreSQL中的内容
使用命令
         psql -h localhost-p7432-U scm
         <输入密码>
         \l


可以看出,  在数据库中有如下的几个database

所有节点Agent配置修改、重启服务

 yum -y install cloudera-manager-agent

  1. In /etc/cloudera-scm-agent/config.ini on each host, update the server_host property to the new hostname and restart the Agents.

  2. Start the Cloudera Manager Server. Cloudera Manager should resume functioning as it did before the failure. Because you restored the database from the backup, the server should accept the running state of the Agents, meaning it will not terminate any running processes.

    The process is similar with secure clusters, though files in /etc/cloudera-scm-server must be restored in addition to the database. See Cloudera Security.

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值