遷移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.

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章