成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

通過(guò)rhel7的kvm虛擬機(jī)實(shí)現(xiàn)3節(jié)點(diǎn)Postgres-XL(包括gtm standby)

huhud / 3800人閱讀

摘要:這里只演示修改下運(yùn)行停掉的服務(wù)下運(yùn)行,編輯配置文件,修改連接地址以下為修改后的顯示結(jié)果,是的服務(wù),從可以看到下運(yùn)行

????關(guān)于postgres-xl的實(shí)驗(yàn)是在我自己筆記本rhel7.2_x64的環(huán)境下,用kvm實(shí)現(xiàn)的,總共有6臺(tái)虛擬機(jī):

????一臺(tái)openfiler2.99發(fā)布共享存儲(chǔ),一臺(tái)gtm master,一臺(tái)gtm slave,三臺(tái)gtm_proxy/coordinator/datanode,除了openfiler之外其余5臺(tái)虛擬機(jī)皆以最小化安裝rhel7.2_x64初始化,且具備兩張網(wǎng)卡,一張用于192.168.122.* 提供服務(wù),一張用于10.10.10.* 讀取openfiler發(fā)布的共享存儲(chǔ),具體的postgres-xl服務(wù)規(guī)劃如下。

服務(wù)名稱 服務(wù)作用 ip 服務(wù)端口 服務(wù)目錄 pooler port
gtm_mast gtm master 192.168.122.179 20001 /pgdata/gtm/data
gtm_slav gtm slave 192.168.122.189 20001 /pgdata/gtm/data
gtm_pxy01 gtm proxy 192.168.122.171 20001 /pgdata/gtm_pxy01/data
gtm_pxy02 gtm proxy 192.168.122.172 20001 /pgdata/gtm_pxy02/data
gtm_pxy03 gtm proxy 192.168.122.173 20001 /pgdata/gtm_pxy03/data
coord01 coordinator 192.168.122.171 15432 /pgdata/coord01/data 40101
coord02 coordinator 192.168.122.172 15432 /pgdata/coord02/data 40102
coord03 coordinator 192.168.122.173 15432 /pgdata/coord03/data 40103
datan01 datanode 192.168.122.181 25431 /pgdata/datan01/data 40401
datan02 datanode 192.168.122.182 25432 /pgdata/datan02/data 40402
datan03 datanode 192.168.122.183 25433 /pgdata/datan03/data 40403
一. 虛擬機(jī)操作系統(tǒng)配置 1. 主機(jī)名配置

對(duì)每個(gè)虛擬機(jī)修改主機(jī)名

hostnamectl set-hostname rhel7pg171

將 /etc/hosts 文件修改成格式化文件(帶域名就三列,不帶域名則兩列就行)

從 /etc/hosts 文件可以看出每臺(tái)虛擬機(jī)的主機(jī)名為 rhel7pgxxx

# cat /etc/hosts
127.0.0.1              localhost
192.168.122.1          station90
192.168.122.170        rhel7pg170
192.168.122.171        rhel7pg171
192.168.122.172        rhel7pg172
192.168.122.173        rhel7pg173
192.168.122.179        rhel7pg179
192.168.122.189        rhel7pg189
192.168.122.100        openfiler100
192.168.122.181        datan01
192.168.122.182        datan02
192.168.122.183        datan03
2. 安全設(shè)置

對(duì)每個(gè)虛擬機(jī)關(guān)閉selinux,關(guān)閉防火墻

setenforce 0
sed -i.bak "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
systemctl disable firewalld.service
systemctl stop firewalld.service
iptables --flush
3. 本地yum服務(wù)配置

掛載本地cdrom中的操作系統(tǒng)ISO到本地目錄

mkdir -p /mnt/iso
mount /dev/cdrom /mnt/iso
# 寫入fstab,下次重起操作系統(tǒng)的時(shí)候自動(dòng)掛載
echo "/dev/cdrom    /mnt/iso    iso9660    defaults    0 0" >> /etc/fstab

創(chuàng)建本地yum源

vi /etc/yum.repos.d/base.repo
cat /etc/yum.repos.d/base.repo
[rhel7]
name=rhel7
baseurl=file:///mnt/iso
gpgcheck=0

[rhel7-HA]
name=rhel7-HA
baseurl=file:///mnt/iso/addons/HighAvailability
gpgcheck=0

[rhel7-RS]
name=rhel7-RS
baseurl=file:///mnt/iso/addons/ResilientStorage

更新yum服務(wù)信息

yum clean all
yum list
yum group list
4. 時(shí)間同步服務(wù)配置

安裝chrony包

yum install chrony.x86_64 -y

編輯配置文件,注釋掉默認(rèn)的server,添加已知可用的或者自建的時(shí)間服務(wù)器,本實(shí)驗(yàn)在openfiler的虛擬機(jī)192.168.122.100通過(guò)ntp發(fā)布了一個(gè)時(shí)間同步源

vi /etc/chrony.conf
# server 0.rhel.pool.ntp.org iburst
# server 1.rhel.pool.ntp.org iburst
# server 2.rhel.pool.ntp.org iburst
# server 3.rhel.pool.ntp.org iburst
server 192.168.122.100 iburst

重啟時(shí)間同步服務(wù):

systemctl restart chronyd.service

查看時(shí)間同步狀態(tài):

systemctl status chronyd.service

設(shè)置開(kāi)機(jī)啟動(dòng)服務(wù):

systemctl enable chronyd.service

查看時(shí)間同步源:

chronyc sources -v

查看時(shí)間同步源狀態(tài):

chronyc sourcestats -v
5. 重啟

重啟所有虛擬機(jī),生效主機(jī)名和selinux的配置

init 6
二. postgres-xl軟件安裝 1. 依賴包的安裝

各種依賴包:

yum install -y make mpfr libmpc cpp kernel-headers glibc-headers glibc-devel libgomp libstdc++-devel libquadmath libgfortran libgnat libgnat-devel libobjc gcc gcc-c++ libquadmath-devel gcc-gfortran gcc-gnat gcc-objc gcc-objc++ ncurses-devel readline readline-devel zlib-devel m4 flex bison mailcap

perl的支持:

yum install -y perl 
perl-Carp 
perl-constant 
perl-Encode 
perl-Exporter 
perl-File-Path 
perl-File-Temp 
perl-Filter 
perl-Getopt-Long 
perl-HTTP-Tiny 
perl-libs 
perl-macros 
perl-parent 
perl-PathTools 
perl-Pod-Escapes 
perl-podlators 
perl-Pod-Perldoc 
perl-Pod-Simple 
perl-Pod-Usage 
perl-Scalar-List-Utils 
perl-Socket 
perl-Storable 
perl-Text-ParseWords 
perl-threads 
perl-threads-shared 
perl-Time-HiRes 
perl-Time-Local
2. postgres-xl主體的安裝
gunzip postgres-xl-9.5r1.4.tar.gz
tar -xvf postgres-xl-9.5r1.4.tar
cd postgres-xl-9.5r1.4
./configure
gmake
gmake install
3. pgxc_ctl插件的安裝

pgxc_ctl插件中,假如我們有需要配置備份配置文件的選項(xiàng)的話,需要修改下源代碼。postgres-xl-9.5r1.4/contrib/pgxc_ctl源代碼中do_command.c的static void init_all(void) 下面第二行,即第524行的init_gtm_master(true);前面,必須插入一行doConfigBackup();再保存編譯make&make install , 要不然用pgxc_ctl init all的時(shí)候,configBackup=y的功能沒(méi)辦法正常使用

cd postgres-xl-9.5r1.4/contrib/pgxc_ctl
vi do_command.c
make
make install
4. 用戶環(huán)境配置

此處環(huán)境變量要寫入 .bashrc 中,因?yàn)閜gxc_ctl會(huì)通過(guò)ssh信任協(xié)議直接遠(yuǎn)程到服務(wù)器上運(yùn)行命令,這樣的話不會(huì)去讀取.bash_profile,只會(huì)讀取.bashrc,如果不把PATH等環(huán)境變量配置到.bashrc的化,之后初始化集群init all 的時(shí)候就會(huì)報(bào)“命令不存在”的錯(cuò)誤。

/usr/sbin/groupadd -g 2001 postgres 
/usr/sbin/useradd -u 2001 -g postgres postgres 
echo "postgres_passwd" | passwd --stdin postgres
echo "export PGHOME=/usr/local/pgsql" >> /home/postgres/.bashrc
echo "export LD_LIBRARY_PATH==$PGHOME/lib" >> /home/postgres/.bashrc
echo "export PG_CONFIG=$PGHOME/bin/pg_config" >> /home/postgres/.bashrc
echo "export pg_config=$PGHOME/bin/pg_config" >> /home/postgres/.bashrc
echo "export PATH=$PATH:$PGHOME/bin" >> /home/postgres/.bashrc
5. 鏈接庫(kù)文件
source /home/postgres/.bash_profile
echo "$PGHOME/lib" >> /etc/ld.so.conf
/sbin/ldconfig
cat /etc/ld.so.conf
三. postgres-xl初始化 1. ssh互信配置

配置每個(gè)節(jié)點(diǎn)的postgres用戶互信
ssh互信配置方法非常多,可以參考 《配置SSH互信》
http://blog.163.com/cao_jfeng...
我使用的是oracle的腳本

./sshUserSetup.sh -hosts "rhel7pg171 rhel7pg172 rhel7pg173 rhel7pg179 rhel7pg189" -user postgres -advanced -noPromptPassphrase -exverify

測(cè)試ssh互通

2. 創(chuàng)建PGDATA目錄

3臺(tái)datanode

mkdir -p /pgdata/datan01
mkdir -p /pgdata/datan02
mkdir -p /pgdata/datan03
mkdir -p /pgdata/coord01
mkdir -p /pgdata/coord02
mkdir -p /pgdata/coord03
mkdir -p /pgdata/gtm_pxy01
mkdir -p /pgdata/gtm_pxy02
mkdir -p /pgdata/gtm_pxy03

gtm master和gtm slave

mkdir -p /pgdata/gtm

所有節(jié)點(diǎn)

chown -R postgres:postgres /pgdata
3. datanode的特殊準(zhǔn)備

用openfiler配置3個(gè)3GB的共享磁盤給datan01 datan02 datan03
在datan01 datan02 datan03上執(zhí)行

systemctl enable iscsi
iscsiadm -m discovery -t sendtargets -p 10.10.10.100
iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.bf1f466b7eef -p 10.10.10.100 -l

在其中某個(gè)datanode上對(duì)共享磁盤進(jìn)行分區(qū),分成一個(gè)分區(qū)即可,并對(duì)其進(jìn)行格式化

fdisk /dev/sda
fdisk /dev/sdb
fdisk /dev/sdc
partprobe /dev/sda
partprobe /dev/sdb
partprobe /dev/sdc
mkfs.xfs /dev/sda1
mkfs.xfs /dev/sdb1
mkfs.xfs /dev/sdc1
tune2fs -c 0 -i 0 /dev/sda1
tune2fs -c 0 -i 0 /dev/sdb1
tune2fs -c 0 -i 0 /dev/sdc1

重啟所有datanode進(jìn)行重新識(shí)別

掛載測(cè)試

mount /dev/sda1 /pgdata/datan01/
mount /dev/sdb1 /pgdata/datan02/
mount /dev/sdc1 /pgdata/datan03/
umount  /dev/sda1
umount  /dev/sdb1
umount  /dev/sdc1

添加每個(gè)datanode的臨時(shí)ip和掛載文件系統(tǒng)

cd /etc/sysconfig/network-scripts/
cp -rp ifcfg-eth0 ifcfg-eth0:1
vi ifcfg-eth0:1
systemctl restart network
mount /dev/sdc1 /pgdata/datan03/

所有節(jié)點(diǎn)

chown -R postgres:postgres /pgdata
4. pgxc_ctl配置文件編寫

進(jìn)入gtm_mast

su - postgres
pgxc_ctl
PGXC prepare
PGXC q
cd pgxc_ctl
vi pgxc_ctl.conf

編輯好的配置文件如下:

    #!/usr/bin/env bash
    #
    # Postgres-XC Configuration file for pgxc_ctl utility. 
    #
    # Configuration file can be specified as -c option from pgxc_ctl command.   Default is
    # $PGXC_CTL_HOME/pgxc_ctl.org.
    #
    # This is bash script so you can make any addition for your convenience to configure
    # your Postgres-XC cluster.
    #
    # Please understand that pgxc_ctl provides only a subset of configuration which pgxc_ctl
    # provide.  Here"s several several assumptions/restrictions pgxc_ctl depends on.
    #
    # 1) All the resources of pgxc nodes has to be owned by the same user.   Same user means
    #    user with the same user name.  User ID may be different from server to server.
    #    This must be specified as a variable $pgxcOwner.
    #
    # 2) All the servers must be reacheable via ssh without password.   It is highly recommended
    #    to setup key-based authentication among all the servers.
    #
    # 3) All the databases in coordinator/datanode has at least one same superuser.  Pgxc_ctl
    #    uses this user to connect to coordinators and datanodes.   Again, no password should
    #    be used to connect.  You have many options to do this, pg_hba.conf, pg_ident.conf and
    #    others.  Pgxc_ctl provides a way to configure pg_hba.conf but not pg_ident.conf.   This
    #    will be implemented in the later releases.
    #
    # 4) Gtm master and slave can have different port to listen, while coordinator and datanode
    #    slave should be assigned the same port number as master.
    #
    # 5) Port nuber of a coordinator slave must be the same as its master.
    #
    # 6) Master and slave are connected using synchronous replication.  Asynchronous replication
    #    have slight (almost none) chance to bring total cluster into inconsistent state.
    #    This chance is very low and may be negligible.  Support of asynchronous replication
    #    may be supported in the later release.
    #
    # 7) Each coordinator and datanode can have only one slave each.  Cascaded replication and
    #    multiple slave are not supported in the current pgxc_ctl.
    #
    # 8) Killing nodes may end up with IPC resource leak, such as semafor and shared memory.
    #    Only listening port (socket) will be cleaned with clean command.
    #
    # 9) Backup and restore are not supported in pgxc_ctl at present.   This is a big task and
    #    may need considerable resource.
    #
    #========================================================================================
    #
    #
    # pgxcInstallDir variable is needed if you invoke "deploy" command from pgxc_ctl utility.
    # If don"t you don"t need this variable.
    pgxcInstallDir=/usr/local/pgsql
    #---- OVERALL -----------------------------------------------------------------------------
    #
    pgxcOwner=postgres            # owner of the Postgres-XC databaseo cluster.  Here, we use this
                            # both as linus user and database user.  This must be
                            # the super user of each coordinator and datanode.
    pgxcUser=$pgxcOwner        # OS user of Postgres-XC owner
    
    tmpDir=/tmp                    # temporary dir used in XC servers
    localTmpDir=$tmpDir            # temporary dir used here locally
    
    configBackup=y                    # If you want config file backup, specify y to this value.
    configBackupHost=192.168.122.189    # host to backup config file
    configBackupDir=/home/postgres/pgxc_ctl        # Backup directory
    configBackupFile=pgxc_ctl.conf    # Backup file name --> Need to synchronize when original changed.
    
    #---- GTM ------------------------------------------------------------------------------------
    
    # GTM is mandatory.  You must have at least (and only) one GTM master in your Postgres-XC cluster.
    # If GTM crashes and you need to reconfigure it, you can do it by pgxc_update_gtm command to update
    # GTM master with others.   Of course, we provide pgxc_remove_gtm command to remove it.  This command
    # will not stop the current GTM.  It is up to the operator.
    
    
    #---- GTM Master -----------------------------------------------
    
    #---- Overall ----
    gtmName=gtm_mast
    gtmMasterServer=192.168.122.179
    gtmMasterPort=20001
    gtmMasterDir=/pgdata/gtm/data
    
    #---- Configuration ---
    gtmExtraConfig=none            # Will be added gtm.conf for both Master and Slave (done at initilization only)
    gtmMasterSpecificExtraConfig=none    # Will be added to Master"s gtm.conf (done at initialization only)
    
    #---- GTM Slave -----------------------------------------------
    
    # Because GTM is a key component to maintain database consistency, you may want to configure GTM slave
    # for backup.
    
    #---- Overall ------
    gtmSlave=y                    # Specify y if you configure GTM Slave.   Otherwise, GTM slave will not be configured and
                                # all the following variables will be reset.
    gtmSlaveName=gtm_slav
    gtmSlaveServer=192.168.122.189        # value none means GTM slave is not available.  Give none if you don"t configure GTM Slave.
    gtmSlavePort=20001            # Not used if you don"t configure GTM slave.
    gtmSlaveDir=/pgdata/gtm/data    # Not used if you don"t configure GTM slave.
    # Please note that when you have GTM failover, then there will be no slave available until you configure the slave
    # again. (pgxc_add_gtm_slave function will handle it)
    
    #---- Configuration ----
    gtmSlaveSpecificExtraConfig=none # Will be added to Slave"s gtm.conf (done at initialization only)
    
    #---- GTM Proxy -------------------------------------------------------------------------------------------------------
    # GTM proxy will be selected based upon which server each component runs on.
    # When fails over to the slave, the slave inherits its master"s gtm proxy.  It should be
    # reconfigured based upon the new location.
    #
    # To do so, slave should be restarted.   So pg_ctl promote -> (edit postgresql.conf and recovery.conf) -> pg_ctl restart
    #
    # You don"t have to configure GTM Proxy if you dont" configure GTM slave or you are happy if every component connects
    # to GTM Master directly.  If you configure GTL slave, you must configure GTM proxy too.
    
    #---- Shortcuts ------
    gtmProxyDir=/pgdata/gtm_pxy
    
    #---- Overall -------
    gtmProxy=y                # Specify y if you conifugre at least one GTM proxy.   You may not configure gtm proxies
                            # only when you dont" configure GTM slaves.
                            # If you specify this value not to y, the following parameters will be set to default empty values.
                            # If we find there"re no valid Proxy server names (means, every servers are specified
                            # as none), then gtmProxy value will be set to "n" and all the entries will be set to
                            # empty values.
    gtmProxyNames=(gtm_pxy01 gtm_pxy02 gtm_pxy03)    # No used if it is not configured
    gtmProxyServers=(192.168.122.171 192.168.122.172 192.168.122.173)        # Specify none if you dont" configure it.
    gtmProxyPorts=(20001 20001 20001)                # Not used if it is not configured.
    gtmProxyDirs=($gtmProxyDir"01/data" $gtmProxyDir"02/data" $gtmProxyDir"03/data")# Not used if it is not configured.
    
    #---- Configuration ----
    gtmPxyExtraConfig=none        # Extra configuration parameter for gtm_proxy.  Coordinator section has an example.
    gtmPxySpecificExtraConfig=(none none none)
    
    #---- Coordinators ----------------------------------------------------------------------------------------------------
    
    #---- shortcuts ----------
    coordMasterDir=/pgdata/coord
    ##coordSlaveDir=$HOME/pgxc/nodes/coord_slave
    ##coordArchLogDir=$HOME/pgxc/nodes/coord_archlog
    
    #---- Overall ------------
    coordNames=(coord01 coord02 coord03)        # Master and slave use the same name
    coordPorts=(15432 15432 15432)            # Master ports
    poolerPorts=(40101 40102 40103)            # Master pooler ports
    coordPgHbaEntries=(0.0.0.0/0)                # Assumes that all the coordinator (master/slave) accepts
                                            # the same connection
                                            # This entry allows only $pgxcOwner to connect.
                                            # If you"d like to setup another connection, you should
                                            # supply these entries through files specified below.
    # Note: The above parameter is extracted as "host all all 0.0.0.0/0 trust".   If you don"t want
    # such setups, specify the value () to this variable and suplly what you want using coordExtraPgHba
    # and/or coordSpecificExtraPgHba variables.
    #coordPgHbaEntries=(::1/128)    # Same as above but for IPv6 addresses
    
    #---- Master -------------
    coordMasterServers=(192.168.122.171 192.168.122.172 192.168.122.173)        # none means this master is not available
    coordMasterDirs=($coordMasterDir"01/data" $coordMasterDir"02/data" $coordMasterDir"03/data")
    coordMaxWALsernder=0    # max_wal_senders: needed to configure slave. If zero value is specified,
                            # it is expected to supply this parameter explicitly by external files
                            # specified in the following.    If you don"t configure slaves, leave this value to zero.
    coordMaxWALSenders=(0 0 0)
                            # max_wal_senders configuration for each coordinator.
    
    #---- Slave -------------
    coordSlave=n            # Specify y if you configure at least one coordiantor slave.  Otherwise, the following
                            # configuration parameters will be set to empty values.
                            # If no effective server names are found (that is, every servers are specified as none),
                            # then coordSlave value will be set to n and all the following values will be set to
                            # empty values.
    ##coordSlaveSync=y        # Specify to connect with synchronized mode.
    ##coordSlaveServers=(node07 node08 node09 node06)            # none means this slave is not available
    ##coordSlavePorts=(20004 20005 20004 20005)            # Master ports
    ##coordSlavePoolerPorts=(20010 20011 20010 20011)            # Master pooler ports
    ##coordSlaveDirs=($coordSlaveDir $coordSlaveDir $coordSlaveDir $coordSlaveDir)
    ##coordArchLogDirs=($coordArchLogDir $coordArchLogDir $coordArchLogDir $coordArchLogDir)
    
    #---- Configuration files---
    # Need these when you"d like setup specific non-default configuration 
    # These files will go to corresponding files for the master.
    # You may supply your bash script to setup extra config lines and extra pg_hba.conf entries 
    # Or you may supply these files manually.
    coordExtraConfig=coordExtraConfig    # Extra configuration file for coordinators.  
                            # This file will be added to all the coordinators"
                            # postgresql.conf
    # Pleae note that the following sets up minimum parameters which you may want to change.
    # You can put your postgresql.conf lines here.
    cat > $coordExtraConfig <> ========================================================
    # You can setup more than one backup set for various purposes, such as disaster recovery.
    ##walArchiveSet=(war1 war2)
    ##war1_source=(master)    # you can specify master, slave or ano other additional slaves as a source of WAL archive.
                        # Default is the master
    ##wal1_source=(slave)
    ##wal1_source=(additiona_coordinator_slave_set additional_datanode_slave_set)
    ##war1_host=node10    # All the nodes are backed up at the same host for a given archive set
    ##war1_backupdir=$HOME/pgxc/backup_war1
    ##wal2_source=(master)
    ##war2_host=node11
    ##war2_backupdir=$HOME/pgxc/backup_war2
    #=============<< End of future extension demonistration >> ========================================================
5. 通過(guò)pgxc_ctl進(jìn)行初始化

進(jìn)入gtm_mast
在postgres用戶下使用 pgxc_ctl init all 命令進(jìn)行初始化以下是輸出結(jié)果:

    # su - postgres
    # pgxc_ctl init all
    /bin/bash
    Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.
    Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.
    Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf
    Finished reading configuration.
       ******** PGXC_CTL START ***************
    
    Current directory: /home/postgres/pgxc_ctl
    pgxc_ctl.conf                                                                                                                         100%   17KB  17.3KB/s   00:00    
    Initialize GTM master
    The files belonging to this GTM system will be owned by user "postgres".
    This user must also own the server process.
    
    
    fixing permissions on existing directory /pgdata/gtm/data ... ok
    creating configuration files ... ok
    creating control file ... ok
    
    Success.
    waiting for server to shut down.... done
    server stopped
    Done.
    Start GTM master
    server starting
    Initialize GTM slave
    The files belonging to this GTM system will be owned by user "postgres".
    This user must also own the server process.
    
    
    fixing permissions on existing directory /pgdata/gtm/data ... ok
    creating configuration files ... ok
    creating control file ... ok
    
    Success.
    Done.
    Start GTM slaveserver starting
    Done.
    Initialize all the gtm proxies.
    Initializing gtm proxy gtm_pxy01.
    Initializing gtm proxy gtm_pxy02.
    Initializing gtm proxy gtm_pxy03.
    The files belonging to this GTM system will be owned by user "postgres".
    This user must also own the server process.
    
    
    fixing permissions on existing directory /pgdata/gtm_pxy01/data ... ok
    creating configuration files ... ok
    
    Success.
    The files belonging to this GTM system will be owned by user "postgres".
    This user must also own the server process.
    
    
    fixing permissions on existing directory /pgdata/gtm_pxy02/data ... ok
    creating configuration files ... ok
    
    Success.
    The files belonging to this GTM system will be owned by user "postgres".
    This user must also own the server process.
    
    
    fixing permissions on existing directory /pgdata/gtm_pxy03/data ... ok
    creating configuration files ... ok
    
    Success.
    Done.
    Starting all the gtm proxies.
    Starting gtm proxy gtm_pxy01.
    Starting gtm proxy gtm_pxy02.
    Starting gtm proxy gtm_pxy03.
    server starting
    server starting
    server starting
    Done.
    Initialize all the coordinator masters.
    Initialize coordinator master coord01.
    Initialize coordinator master coord02.
    Initialize coordinator master coord03.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/coord01/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/coord01/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/coord02/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/coord02/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/coord03/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/coord03/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    Done.
    Starting coordinator master.
    Starting coordinator master coord01
    Starting coordinator master coord02
    Starting coordinator master coord03
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    Done.
    Initialize all the datanode masters.
    Initialize the datanode master datan01.
    Initialize the datanode master datan02.
    Initialize the datanode master datan03.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/datan01/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/datan01/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/datan02/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/datan02/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "zh_CN.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /pgdata/datan03/data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /pgdata/datan03/data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    creating cluster information ... ok
    loading system objects" descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    syncing data to disk ... ok
    freezing database template0 ... ok
    freezing database template1 ... ok
    freezing database postgres ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success.
    Done.
    Starting all the datanode masters.
    Starting datanode master datan01.
    Starting datanode master datan02.
    Starting datanode master datan03.
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    LOG:  redirecting log output to logging collector process
    HINT:  Future log output will appear in directory "pg_log".
    Done.
    ALTER NODE coord01 WITH (HOST="192.168.122.171", PORT=15432);
    ALTER NODE
    CREATE NODE coord02 WITH (TYPE="coordinator", HOST="192.168.122.172", PORT=15432);
    CREATE NODE
    CREATE NODE coord03 WITH (TYPE="coordinator", HOST="192.168.122.173", PORT=15432);
    CREATE NODE
    CREATE NODE datan01 WITH (TYPE="datanode", HOST="192.168.122.181", PORT=25431);
    CREATE NODE
    CREATE NODE datan02 WITH (TYPE="datanode", HOST="192.168.122.182", PORT=25432);
    CREATE NODE
    CREATE NODE datan03 WITH (TYPE="datanode", HOST="192.168.122.183", PORT=25433);
    CREATE NODE
    SELECT pgxc_pool_reload();
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    CREATE NODE coord01 WITH (TYPE="coordinator", HOST="192.168.122.171", PORT=15432);
    CREATE NODE
    ALTER NODE coord02 WITH (HOST="192.168.122.172", PORT=15432);
    ALTER NODE
    CREATE NODE coord03 WITH (TYPE="coordinator", HOST="192.168.122.173", PORT=15432);
    CREATE NODE
    CREATE NODE datan01 WITH (TYPE="datanode", HOST="192.168.122.181", PORT=25431);
    CREATE NODE
    CREATE NODE datan02 WITH (TYPE="datanode", HOST="192.168.122.182", PORT=25432);
    CREATE NODE
    CREATE NODE datan03 WITH (TYPE="datanode", HOST="192.168.122.183", PORT=25433);
    CREATE NODE
    SELECT pgxc_pool_reload();
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    CREATE NODE coord01 WITH (TYPE="coordinator", HOST="192.168.122.171", PORT=15432);
    CREATE NODE
    CREATE NODE coord02 WITH (TYPE="coordinator", HOST="192.168.122.172", PORT=15432);
    CREATE NODE
    ALTER NODE coord03 WITH (HOST="192.168.122.173", PORT=15432);
    ALTER NODE
    CREATE NODE datan01 WITH (TYPE="datanode", HOST="192.168.122.181", PORT=25431);
    CREATE NODE
    CREATE NODE datan02 WITH (TYPE="datanode", HOST="192.168.122.182", PORT=25432);
    CREATE NODE
    CREATE NODE datan03 WITH (TYPE="datanode", HOST="192.168.122.183", PORT=25433);
    CREATE NODE
    SELECT pgxc_pool_reload();
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    Done.
    EXECUTE DIRECT ON (datan01) "CREATE NODE coord01 WITH (TYPE=""coordinator"", HOST=""192.168.122.171"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "CREATE NODE coord02 WITH (TYPE=""coordinator"", HOST=""192.168.122.172"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "CREATE NODE coord03 WITH (TYPE=""coordinator"", HOST=""192.168.122.173"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "ALTER NODE datan01 WITH (TYPE=""datanode"", HOST=""192.168.122.181"", PORT=25431)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "CREATE NODE datan02 WITH (TYPE=""datanode"", HOST=""192.168.122.182"", PORT=25432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "CREATE NODE datan03 WITH (TYPE=""datanode"", HOST=""192.168.122.183"", PORT=25433)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan01) "SELECT pgxc_pool_reload()";
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    EXECUTE DIRECT ON (datan02) "CREATE NODE coord01 WITH (TYPE=""coordinator"", HOST=""192.168.122.171"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "CREATE NODE coord02 WITH (TYPE=""coordinator"", HOST=""192.168.122.172"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "CREATE NODE coord03 WITH (TYPE=""coordinator"", HOST=""192.168.122.173"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "CREATE NODE datan01 WITH (TYPE=""datanode"", HOST=""192.168.122.181"", PORT=25431)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "ALTER NODE datan02 WITH (TYPE=""datanode"", HOST=""192.168.122.182"", PORT=25432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "CREATE NODE datan03 WITH (TYPE=""datanode"", HOST=""192.168.122.183"", PORT=25433)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan02) "SELECT pgxc_pool_reload()";
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    EXECUTE DIRECT ON (datan03) "CREATE NODE coord01 WITH (TYPE=""coordinator"", HOST=""192.168.122.171"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "CREATE NODE coord02 WITH (TYPE=""coordinator"", HOST=""192.168.122.172"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "CREATE NODE coord03 WITH (TYPE=""coordinator"", HOST=""192.168.122.173"", PORT=15432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "CREATE NODE datan01 WITH (TYPE=""datanode"", HOST=""192.168.122.181"", PORT=25431)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "CREATE NODE datan02 WITH (TYPE=""datanode"", HOST=""192.168.122.182"", PORT=25432)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "ALTER NODE datan03 WITH (TYPE=""datanode"", HOST=""192.168.122.183"", PORT=25433)";
    EXECUTE DIRECT
    EXECUTE DIRECT ON (datan03) "SELECT pgxc_pool_reload()";
     pgxc_pool_reload 
    ------------------
     t
    (1 row)
    
    Done.

初始化完成,可以用 pgxc_ctl monitor all 對(duì)所有服務(wù)的狀態(tài)進(jìn)行觀察:

    # pgxc_ctl monitor all
    /bin/bash
    Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.
    Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.
    Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf
    Finished reading configuration.
       ******** PGXC_CTL START ***************
    
    Current directory: /home/postgres/pgxc_ctl
    Running: gtm master
    Running: gtm slave
    Running: gtm proxy gtm_pxy01
    Running: gtm proxy gtm_pxy02
    Running: gtm proxy gtm_pxy03
    Running: coordinator master coord01
    Running: coordinator master coord02
    Running: coordinator master coord03
    Running: datanode master datan01
    Running: datanode master datan02
    Running: datanode master datan03
6. 修改datanode的gtm地址

為了后面datanode節(jié)點(diǎn)切換服務(wù)器的時(shí)候能夠注冊(cè)上gtm proxy,現(xiàn)在將每個(gè)datanode節(jié)點(diǎn)的配置文件里面的gtm地址配置為datanode自己的服務(wù)ip。這里只演示修改datan01:

    # gtm_mast下運(yùn)行,停掉datanode datan01的服務(wù)
    pgxc_ctl stop datanode datan01
    
    # datan01下運(yùn)行,編輯配置文件,修改gtm proxy連接地址
    su - postgres
    cd /pgdata/datan01/data/
    vi postgresql.conf 
    tail -n 3 postgresql.conf
    # 以下為修改后的顯示結(jié)果,192.168.122.181是datan01的服務(wù)ip,從/etc/hosts可以看到
    gtm_host = "192.168.122.181"
    gtm_port = 20001
    # End of Addition
    
    # gtm_mast下運(yùn)行
    pgxc_ctl start datanode datan01

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/38965.html

相關(guān)文章

  • 初識(shí)Postgres-XL

    摘要:所有節(jié)點(diǎn)中分為三種角色全局事務(wù)管理器協(xié)調(diào)器和數(shù)據(jù)節(jié)點(diǎn)。一旦故障,整個(gè)集群立刻無(wú)法訪問(wèn),此時(shí)可以切換到節(jié)點(diǎn)上。 第一節(jié) 簡(jiǎn)介Postgres-XL是一款開(kāi)源的PG集群軟件,XL代表eXtensible Lattice,即可擴(kuò)展的PG格子之意,以下簡(jiǎn)稱PGXL。官方稱其既適合寫操作壓力較大的OLTP應(yīng)用,又適合讀操作為主的大數(shù)據(jù)應(yīng)用。它的前身是Postgres-XC(簡(jiǎn)稱PGXC),...

    JasinYip 評(píng)論0 收藏0
  • Postgres-XL安裝與配置

    摘要:接上篇初識(shí)寫一下簡(jiǎn)稱的部署與測(cè)試。如果執(zhí)行報(bào)錯(cuò)則根據(jù)提示安裝相應(yīng)的庫(kù)即可,如等。默認(rèn)的安裝目錄是,和原生相同,很順手。 接上篇《初識(shí)Postgres-XL》https://segmentfault.com/a/11...寫一下Postgres-XL(簡(jiǎn)稱PGXL)的部署與測(cè)試。 第一節(jié) 安裝安裝很簡(jiǎn)單,源碼安裝,和PG的安裝基本相同,可能比PG多一個(gè)依賴庫(kù)。在所有節(jié)點(diǎn)上執(zhí)行相同操作。 ...

    ysl_unh 評(píng)論0 收藏0
  • PG兩種集群技術(shù):Pgpool-II與Postgres-XL

    摘要:最近研究了的兩種集群方案,分別是和,在這里總結(jié)一下二者的機(jī)制結(jié)構(gòu)優(yōu)劣測(cè)試結(jié)果等。其中的前身的,的前身是。為了避免單點(diǎn)故障,可以為所有節(jié)點(diǎn)配置對(duì)應(yīng)的節(jié)點(diǎn)。測(cè)試測(cè)試結(jié)果測(cè)試結(jié)果顯示,兩種集群與單機(jī)的性能指標(biāo)幾乎一致,無(wú)法分辨高下。 最近研究了PG的兩種集群方案,分別是Pgpool-II和Postgres-XL,在這里總結(jié)一下二者的機(jī)制、結(jié)構(gòu)、優(yōu)劣、測(cè)試結(jié)果等。 1、 Pgpool-I...

    gitmilk 評(píng)論0 收藏0
  • 構(gòu)建可擴(kuò)展PostgreSQL解決方案

    摘要:這可以通過(guò)負(fù)載平衡來(lái)實(shí)現(xiàn)數(shù)據(jù)分片當(dāng)問(wèn)題不是并發(fā)查詢的數(shù)量,而是數(shù)據(jù)庫(kù)的大小和單個(gè)查詢的速度時(shí),可以實(shí)現(xiàn)不同的方法。 showImg(https://segmentfault.com/img/remote/1460000018875091); 來(lái)源 | 愿碼(ChainDesk.CN)內(nèi)容編輯 愿碼Slogan | 連接每個(gè)程序員的故事 網(wǎng)站 | http://chaindesk.cn...

    jonh_felix 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<