如果您用的是Oushu Lava公有云,或者私有云2.0+,您可以通過(guò)Lava UI自動(dòng)部署OushuDB,詳情請(qǐng)見(jiàn): http://oushu.io/docs/ch/lava-oushu.html。
如果您不使用Oushu Lava瓣喊,只想單獨(dú)部署OushuDB,請(qǐng)按照本節(jié)步驟安裝黔酥。
首先在oushum1藻三,修改/usr/local/hawq/etc/slaves,將所有OushuDB的segment節(jié)點(diǎn)的hostname寫入slaves中跪者,在本次安裝中棵帽,應(yīng)該寫入slaves的有oushus1和oushus2,slaves內(nèi)容為:
oushus1oushus2
在其他節(jié)點(diǎn)上安裝hawq:
hawq ssh -h oushum2 -e "yum install -y hawq"hawq ssh -f slaves -e "yum install -y hawq"
在oushum1節(jié)點(diǎn)上渣玲,在配置文件/etc/sysctl.conf添加內(nèi)容:
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中的配置文件到所有節(jié)點(diǎn):
hawq scp -r -f hostfile /etc/sysctl.conf =:/etc/
在oushum1逗概,使用“hawq ssh”執(zhí)行下面的命令,使所有節(jié)點(diǎn)的/etc/sysctl.conf中的系統(tǒng)配置生效>:
hawq ssh -f hostfile -e "sysctl -p"
在oushum1忘衍,創(chuàng)建文件/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中的配置文件到所有節(jié)點(diǎn):
hawq scp -r -f hostfile /etc/security/limits.d/gpadmin.conf =:/etc/security/limits.d
在oushum1逾苫,在Hadoop上創(chuàng)建/hawq/default_filespace卿城,并賦予gpadmin權(quán)限:
sudo -u hdfs hdfs dfs -mkdir -p /hawq/default_filespacesudo -u hdfs hdfs dfs -chown -R gpadmin /hawq
在oushum1,創(chuàng)建mhostfile铅搓,記錄所有hawq的master和standby master的hostname瑟押,類似hostfile:
touch mhostfile
mhostfile記錄內(nèi)容:
oushum1oushum2
在oushum1,創(chuàng)建shostfile星掰,記錄所有hawq的segment的hostname多望,類似hostfile:
touch shostfile
shostfile記錄內(nèi)容:
oushus1oushus2
在oushum1,使用“hawq ssh”在master和standby節(jié)點(diǎn)創(chuàng)建master元數(shù)據(jù)目錄和臨時(shí)文件目錄氢烘,并授 予gpadmin權(quán)限:
創(chuàng)建master元數(shù)據(jù)目錄hawq ssh -f mhostfile -e 'mkdir -p /data1/hawq/masterdd'#創(chuàng)建臨時(shí)文件目錄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創(chuàng)建segment元數(shù)據(jù)目錄和臨時(shí)文件目錄,并授予gpadmin權(quán)限:
創(chuàng)建segment元數(shù)據(jù)目錄hawq ssh -f shostfile -e 'mkdir -p /data1/hawq/segmentdd'#創(chuàng)建臨時(shí)文件目錄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相關(guān)的配置文件都需要使用該用戶權(quán)限:
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的單獨(dú)配置和啟停功能脓斩,使用magam服務(wù)時(shí), 在oushum1,使用“hawq ssh”在所有slave節(jié)點(diǎn)創(chuàng)建node數(shù)據(jù)目錄畴栖,并授予gpadmin權(quán)限
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中的配置文件到所有節(jié)點(diǎn):
source /usr/local/hawq/greenplum_path.shhawq scp -r -f hostfile /usr/local/hawq/etc =:/usr/local/hawq
在oushum1,切換到gpadmin用戶吗讶,創(chuàng)建hhostfile:
su - gpadminsource /usr/local/hawq/greenplum_path.sh #設(shè)置hawq環(huán)境變量touch hhostfile
hhostfile文件記錄所有OushuDB節(jié)點(diǎn)主機(jī)名稱燎猛,內(nèi)容如下:
oushum1oushum2oushus1oushus2
使用root用戶登錄到每臺(tái)機(jī)器,修改gpadmin用戶密碼:
sudo echo 'password' | sudo passwd --stdin gpadmin
針對(duì)gpadmin用戶交換key照皆,并且按照提示輸入相應(yīng)節(jié)點(diǎn)的gpadmin用戶密碼:
su - gpadminsource /usr/local/hawq/greenplum_path.sh #設(shè)置hawq環(huán)境變量hawq ssh-exkeys -f hhostfile
在oushum1重绷,使用gpadmin用戶權(quán)限,初始化OushuDB集群膜毁, 當(dāng)提示“Continue with HAWQ init”時(shí)昭卓,輸 入 Y:
hawq init cluster //OushuDB4.0 默認(rèn)不啟動(dòng)magma服務(wù)
hawq init cluster --with_magma //OushuDB4.0新增,3.X版本不支持該用法
// OushuDB4.0版本新增--with_magma選項(xiàng)瘟滨,但只有hawq init|start|stop cluster命令可以帶--with_magma選項(xiàng)候醒。
注意:
在做OushuDB集群初始化的時(shí)候,需要保證在創(chuàng)建的/data/hawq/目錄下杂瘸,masterdd和segmentdd>都是空目錄倒淫,在hadoop上創(chuàng)建的/hawq/default_filespace確保是空目錄#另外,如果hawq init cluster失敗胧沫,可以先執(zhí)行下面的命令停止hawq集群昌简,清空目錄占业,找出>問(wèn)題原因后重新初始化。hawq stop cluster#在OushuDB master節(jié)點(diǎn)纯赎,根據(jù)本次安裝的配置谦疾,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節(jié)點(diǎn)犬金,使用下面的命令念恍,清空/hawq/default_filespace,如果/hawq/default_filespace中有用戶數(shù)據(jù)晚顷,注意備份數(shù)據(jù)峰伙,避免造成損失:hdfs dfs -rm -f -r /hawq/default_filespace/*
你也需要檢查HDFS的參數(shù)配置是否正確,最好以gpadmin用戶來(lái)檢查该默。如果參數(shù)配置不正確的話瞳氓,>雖然有時(shí)HDFS可以正常啟動(dòng),但在高負(fù)載情況下HDFS會(huì)出現(xiàn)錯(cuò)誤栓袖。
su - gpadminsource /usr/local/hawq/greenplum_path.shhawq check -f hostfile --hadoop /usr/hdp/current/hadoop-client/ --hdfs-ha
檢查OushuDB是否運(yùn)行正常:
su - gpadmin
source /usr/local/hawq/greenplum_path.sh
psql -d postgres
select * from gp_segment_configuration; #確定所有節(jié)點(diǎn)是up狀態(tài)
create table t(i int);
insert into t select generate_series(1,1000);
select count(*) from t;