天天看點

OushuDB 如何安裝與更新

OushuDB 如何安裝與更新

如果您用的是Oushu Lava公有雲,或者私有雲2.0+,您可以通過Lava UI自動部署OushuDB,詳情請見: 

http://oushu.io/docs/ch/lava-oushu.html

如果您不使用Oushu Lava,隻想單獨部署OushuDB,請按照本節步驟安裝。

首先在oushum1,修改/usr/local/hawq/etc/slaves,将所有OushuDB的segment節點的hostname寫入slaves中,在本次安裝中,應該寫入slaves的有oushus1和oushus2,slaves内容為:

oushus1oushus2           

在其他節點上安裝hawq:

hawq ssh -h oushum2 -e "yum install -y hawq"hawq ssh -f slaves -e "yum install -y hawq"           

在oushum1節點上,在配置檔案/etc/sysctl.conf添加内容:

kernel.shmmax = 1000000000kernel.shmmni = 4096kernel.shmall = 4000000000kernel.sem = 250 512000 100 2048kernel.sysrq = 1kernel.core_uses_pid = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.msgmni = 2048net.ipv4.tcp_syncookies = 0net.ipv4.conf.default.accept_source_route = 0net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_max_syn_backlog = 200000net.ipv4.conf.all.arp_filter = 1net.ipv4.ip_local_port_range = 10000 65535net.core.netdev_max_backlog = 200000net.netfilter.nf_conntrack_max = 524288fs.nr_open = 3000000kernel.threads-max = 798720kernel.pid_max = 798720# increase networknet.core.rmem_max=2097152net.core.wmem_max=2097152net.core.somaxconn=4096           

拷貝oushum1上/etc/sysctl.conf中的配置檔案到所有節點:

hawq scp -r -f hostfile /etc/sysctl.conf =:/etc/           

在oushum1,使用“hawq ssh”執行下面的指令,使所有節點的/etc/sysctl.conf中的系統配置生效>:

hawq ssh -f hostfile -e "sysctl -p"           

在oushum1,建立檔案/etc/security/limits.d/gpadmin.conf:

* soft nofile 1048576* hard nofile 1048576* soft nproc 131072* hard nproc 131072           

拷貝oushum1上/etc/security/limits.d/gpadmin.conf中的配置檔案到所有節點:

hawq scp -r -f hostfile /etc/security/limits.d/gpadmin.conf =:/etc/security/limits.d           

在oushum1,在Hadoop上建立/hawq/default_filespace,并賦予gpadmin權限:

sudo -u hdfs hdfs dfs -mkdir -p /hawq/default_filespacesudo -u hdfs hdfs dfs -chown -R gpadmin /hawq           

在oushum1,建立mhostfile,記錄所有hawq的master和standby master的hostname,類似hostfile:

touch mhostfile           

mhostfile記錄内容:

oushum1oushum2           

在oushum1,建立shostfile,記錄所有hawq的segment的hostname,類似hostfile:

touch shostfile           

shostfile記錄内容:

oushus1oushus2           

在oushum1,使用“hawq ssh”在master和standby節點建立master中繼資料目錄和臨時檔案目錄,并授 予gpadmin權限:

#建立master中繼資料目錄hawq ssh -f mhostfile -e 'mkdir -p /data1/hawq/masterdd'#建立臨時檔案目錄hawq ssh -f mhostfile -e 'mkdir -p /data1/hawq/tmp'hawq ssh -f mhostfile -e 'mkdir -p /data2/hawq/tmp'hawq ssh -f mhostfile -e 'chown -R gpadmin:gpadmin /data1/hawq'hawq ssh -f mhostfile -e 'chown -R gpadmin:gpadmin /data2/hawq'           

在oushum1,使用“hawq ssh”在所有segment建立segment中繼資料目錄和臨時檔案目錄,并授予gpadmin權限:

#建立segment中繼資料目錄hawq ssh -f shostfile -e 'mkdir -p /data1/hawq/segmentdd'#建立臨時檔案目錄hawq ssh -f shostfile -e 'mkdir -p /data1/hawq/tmp'hawq ssh -f shostfile -e 'mkdir -p /data2/hawq/tmp'hawq ssh -f shostfile -e 'chown -R gpadmin:gpadmin /data1/hawq'hawq ssh -f shostfile -e 'chown -R gpadmin:gpadmin /data2/hawq'           

在oushum1,切換hawq使用者,hawq相關的配置檔案都需要使用該使用者權限:

su - gpadmin           

修改/usr/local/hawq/etc/hdfs-client.xml:(與hdfs類似,先去掉HA的注釋):

<configuration><property><name>dfs.nameservices</name><value>oushu</value></property><property><name>dfs.ha.namenodes.oushu</name><value>nn1,nn2</value></property><property><name>dfs.namenode.rpc-address.oushu.nn1</name><value>oushum2:9000</value></property><property><name>dfs.namenode.rpc-address.oushu.nn2</name><value>oushum1:9000</value></property><property><name>dfs.namenode.http-address.oushu.nn1</name><value>oushum2:50070</value></property><property><name>dfs.namenode.http-address.oushu.nn2</name><value>oushum1:50070</value></property>...<property><name>dfs.domain.socket.path</name><value>/var/lib/hadoop-hdfs/dn_socket</value><description>Optional.  This is a path to a UNIX domain socket that will be used for communication between the DataNode and local HDFS clients.If the string "_PORT" is present in this path, it will be replaced by the TCP port of the DataNode.</description></property>...</configuration>           

在oushum1,修改/usr/local/hawq/etc/hawq-site.xml 注意:hawq_dfs_url中的oushu是dfs.nameservices的值,在hdfs-site.xml中配置;magma_nodes_url中的值最好取/usr/local/hawq/etc/slaves檔案中的前兩行:

<configuration><property><name>hawq_master_address_host</name><value>oushum1</value></property>...<property><name>hawq_standby_address_host</name><value>oushum2</value><description>The host name of hawq standby master.</description></property>...<property><name>hawq_dfs_url</name><value>oushu/hawq/default_filespace</value><description>URL for accessing HDFS.</description></property><property><name>magma_nodes_url</name><value>oushus1:6666,oushus2:6666</value><description>urls for accessing magma.</description></property><property><name>hawq_master_directory</name><value>/data1/hawq/masterdd</value><description>The directory of hawq master.</description></property><property><name>hawq_segment_directory</name><value>/data1/hawq/segmentdd</value><description>The directory of hawq segment.</description></property><property><name>hawq_master_temp_directory</name><value>/data1/hawq/tmp,/data2/hawq/tmp</value><description>The temporary directory reserved for hawq master. NOTE: please DONOT add " " between directories. </description></property><property><name>hawq_segment_temp_directory</name><value>/data1/hawq/tmp,/data2/hawq/tmp</value><description>The temporary directory reserved for hawq segment. NOTE: please DONOT add " " between directories. </description></property><property><name>default_storage</name><value>hdfs</value><description>Sets the default storage when creating table</description></property><property><name>hawq_init_with_hdfs</name><value>true</value><description>Choose whether init cluster with hdfs</description></property>...<property><name>hawq_rm_yarn_address</name><value>oushum1:8032</value><description>The address of YARN resource manager server.</description></property><property><name>hawq_rm_yarn_scheduler_address</name><value>oushum1:8030</value><description>The address of YARN scheduler server.</description></property>...<property><name>hawq_rm_yarn_app_name</name><value>hawq</value><description>The application name to register hawq resource manager in YARN.</description></property>...<property><name>hawq_re_cgroup_hierarchy_name</name><value>hawq</value><description>The name of the hierarchy to accomodate CGroup directories/files for resource enforcement.For example, /sys/fs/cgroup/cpu/hawq for CPU sub-system.</description></property>...</configuration>           

OushuDB4.0版本新增Magma的單獨配置和啟停功能,使用magam服務時, 在oushum1,使用“hawq ssh”在所有slave節點建立node資料目錄,并授予gpadmin權限:

hawq ssh -f shostfile -e 'mkdir -p /data1/hawq/magma_segmentdd'hawq ssh -f shostfile -e 'mkdir -p /data2/hawq/magma_segmentdd'hawq ssh -f shostfile -e 'chown -R gpadmin:gpadmin /data1/hawq'hawq ssh -f shostfile -e 'chown -R gpadmin:gpadmin /data2/hawq'           

然後編輯配置/usr/local/hawq/etc/magma-site.xml:

<property><name>nodes_file</name><value>slaves</value><description>The magma nodes file name at GPHOME/etc</description></property><property><name>node_data_directory</name><value>file:///data1/hawq/magma_segmentdd,file:///data2/hawq/magma_segmentdd</value><description>The data directory for magma node</description></property><property><name>node_log_directory</name><value>~/hawq-data-directory/segmentdd/pg_log</value><description>The log directory for magma node</description></property><property><name>node_address_port</name><value>6666</value><description>The port magma node listening</description></property><property><name>magma_range_number</name><value>2</value></property><property><name>magma_replica_number</name><value>3</value></property><property><name>magma_datadir_capacity</name><value>3</value></property>           

在oushum1,切換成root使用者:

su - root           

拷貝oushum1上/usr/local/hawq/etc中的配置檔案到所有節點:

source /usr/local/hawq/greenplum_path.shhawq scp -r -f hostfile /usr/local/hawq/etc =:/usr/local/hawq           

在oushum1,切換到gpadmin使用者,建立hhostfile:

su - gpadminsource /usr/local/hawq/greenplum_path.sh  #設定hawq環境變量touch hhostfile           

hhostfile檔案記錄所有OushuDB節點主機名稱,内容如下:

oushum1oushum2oushus1oushus2           

使用root使用者登入到每台機器,修改gpadmin使用者密碼:

sudo echo 'password' | sudo passwd  --stdin gpadmin           

針對gpadmin使用者交換key,并且按照提示輸入相應節點的gpadmin使用者密碼:

su - gpadminsource /usr/local/hawq/greenplum_path.sh  #設定hawq環境變量hawq ssh-exkeys -f hhostfile           

在oushum1,使用gpadmin使用者權限,初始化OushuDB叢集, 當提示“Continue with HAWQ init”時,輸 入 Y:

hawq init cluster   //OushuDB4.0 預設不啟動magma服務           
hawq init cluster --with_magma   //OushuDB4.0新增,3.X版本不支援該用法           
// OushuDB4.0版本新增--with_magma選項,但隻有hawq init|start|stop cluster指令可以帶--with_magma選項。           

注意:

在做OushuDB叢集初始化的時候,需要保證在建立的/data*/hawq/目錄下,masterdd和segmentdd>都是空目錄,在hadoop上建立的/hawq/default_filespace確定是空目錄#另外,如果hawq init cluster失敗,可以先執行下面的指令停止hawq叢集,清空目錄,找出>問題原因後重新初始化。hawq stop cluster#在OushuDB master節點,根據本次安裝的配置,s使用下面的指令清空所有hawq目錄,然後重建hawq子目錄:

hawq ssh -f hhostfile -e 'rm -fr /data1/hawq/masterdd/*'hawq ssh -f hhostfile -e 'rm -fr /data1/hawq/segmentdd/*'hawq ssh -f hhostfile -e 'rm -fr /data1/hawq/magma_masterdd/*'hawq ssh -f hhostfile -e 'rm -fr /data1/hawq/magma_segmentdd/*'hawq ssh -f hhostfile -e 'rm -fr /data2/hawq/magma_segmentdd/*'#在HDFS namenode節點,使用下面的指令,清空/hawq/default_filespace,如果/hawq/default_filespace中有使用者資料,注意備份資料,避免造成損失:hdfs dfs -rm -f -r /hawq/default_filespace/*           

你也需要檢查HDFS的參數配置是否正确,最好以gpadmin使用者來檢查。如果參數配置不正确的話,>雖然有時HDFS可以正常啟動,但在高負載情況下HDFS會出現錯誤。

su - gpadminsource /usr/local/hawq/greenplum_path.shhawq check -f hostfile --hadoop /usr/hdp/current/hadoop-client/ --hdfs-ha           

檢查OushuDB是否運作正常:

su - gpadmin
source /usr/local/hawq/greenplum_path.sh
psql -d postgres
select * from gp_segment_configuration;  #确定所有節點是up狀态

create table t(i int);
insert into t select generate_series(1,1000);
select count(*) from t;           

繼續閱讀