Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to install and run tbase on one host? #60

Open
l1t1 opened this issue Jul 16, 2020 · 8 comments
Open

how to install and run tbase on one host? #60

l1t1 opened this issue Jul 16, 2020 · 8 comments

Comments

@l1t1
Copy link

l1t1 commented Jul 16, 2020

i followed the build steps at https://github.com/Tencent/TBase, and got bin files now.
I want to run it on one host, what are the additional steps?

cd ${SOURCECODE_PATH}
rm -rf ${INSTALL_PATH}/tbase_bin_v2.0
chmod +x configure*
./configure --prefix=${INSTALL_PATH}/tbase_bin_v2.0 --enable-user-switch --with-openssl --with-ossp-uuid CFLAGS=-g
make clean
make -sj
make install
chmod +x contrib/pgxc_ctl/make_signature
cd contrib
make -sj
make install

i move the install directory which includes compiled files to /data/tbase/install
then i create a user tbase and set it the owner of /data/tbase
then run
ssh-copy-id -i ~/.ssh/id_rsa.pub tbase@my_hostname

ssh-keygen -t rsa

then edit the /home/tbase/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
# add PG env
export PGHOME=/data/tbase/install/tbase_bin_v2.0
export PGDATA=/data/tbase
export PATH=$PGHOME/bin:$PATH
export MANPATH=$PGHOME/share/man:$MANPATH
export LANG=en_US.utf8
export DATE=`date +"%Y-%m-%d %H:%M:%S"`
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
alias rm='rm  -i'
alias ll='ls -lh'
#alias pg_start='pg_ctl start -D $PGDATA'
#alias pg_stop='pg_ctl stop -D $PGDATA -m fast'

export PGHOST=localhost
export PGPORT=5432
export PGUSER=tbase

then create the file /home/tbase/pgxc_ctl/pgxc_ctl.conf as following

gtmName=gtm
gtmMasterServer=a.a.a.a
gtmMasterPort=50001
gtmMasterDir=/data/tbase/g/data/gtm_master

coordNames=(cn001)
coordPorts=(30004)
poolerPorts=(30014)
coordPgHbaEntries=(0.0.0.0/0)
coordMasterServers=(a.a.a.a)
coordMasterDirs=(/data/tbase/c/data/cn_master/cn001)
coordMaxWALsernder=0
coordMaxWALSenders=($coordMaxWALsernder)
coordSlave=n
coordSpecificExtraConfig=(none none none)
coordSpecificExtraPgHba=(none none none)

primaryDatanode=dn001
datanodeNames=(dn001)
datanodePorts=(20008)
datanodePoolerPorts=(20018)
datanodePgHbaEntries=(0.0.0.0/0)
datanodeMasterServers=(a.a.a.a)
datanodeMasterDirs=(/data/tbase/d/data/dn_master/dn001)
dnWALSndr=0
datanodeMaxWALSenders=($dnWALSndr)

but execute the pgxc_ctl, it reports many errors.

[tbase@VM_0_13_centos pgxc_ctl]$ pgxc_ctl
/bin/bash
Installing pgxc_ctl_bash script as /home/tbase/pgxc_ctl/pgxc_ctl_bash.
Installing pgxc_ctl_bash script as /home/tbase/pgxc_ctl/pgxc_ctl_bash.
Reading configuration using /home/tbase/pgxc_ctl/pgxc_ctl_bash --home /home/tbase/pgxc_ctl --configuration /home/tbase/pgxc_ctl/pgxc_ctl.conf
Finished reading configuration.
   ******** PGXC_CTL START ***************

Current directory: /home/tbase/pgxc_ctl

PGXC deploy all
Deploying Postgres-XL components to all the target servers.
Prepare tarball to deploy ...
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `( tar czCf (null) (null)/707564.tgz bin include lib share ) < /dev/null > (null)/STDOUT_707564_0 2>&1'
ERROR: Cannot open "(null)/STDOUT_707564_0" for read, No such file or directory
Deploying to the server a.a.a.a.
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `ssh (null)@a.a.a.a "( rm -rf (null)/bin (null)/include (null)/lib (null)/share; mkdir -p (null) ) > (null)/VM_0_13_centos_STDOUT_707564_2 2>&1" < /dev/null > /dev/null 2>&1'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(ssh (null)@a.a.a.a touch (null)/VM_0_13_centos_STDOUT_707564_2) < /dev/null > /dev/null 2>&1'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(touch (null)/STDOUT_707564_1) < /dev/null > /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(scp (null)@a.a.a.a:(null)/VM_0_13_centos_STDOUT_707564_2 (null)/STDOUT_707564_1; ssh (null)@a.a.a.a rm -rf (null)/VM_0_13_centos_STDOUT_707564_2) < /dev/null > /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `( scp (null)/707564.tgz (null)@a.a.a.a:(null) ) > (null)/STDOUT_707564_3 2>&1 < /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(touch (null)/STDOUT_707564_3) < /dev/null > /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `ssh (null)@a.a.a.a "( tar xzCf (null) (null)/707564.tgz; rm (null)/707564.tgz ) > (null)/VM_0_13_centos_STDOUT_707564_5 2>&1" < /dev/null > /dev/null 2>&1'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(ssh (null)@a.a.a.a touch (null)/VM_0_13_centos_STDOUT_707564_5) < /dev/null > /dev/null 2>&1'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(touch (null)/STDOUT_707564_4) < /dev/null > /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `(scp (null)@a.a.a.a:(null)/VM_0_13_centos_STDOUT_707564_5 (null)/STDOUT_707564_4; ssh (null)@a.a.a.a rm -rf (null)/VM_0_13_centos_STDOUT_707564_5) < /dev/null > /dev/null'
ERROR: Cannot open "(null)/STDOUT_707564_1" for read, No such file or directory
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `(rm -f (null)/STDOUT_707564_1) < /dev/null > /dev/null'
ERROR: Cannot open "(null)/STDOUT_707564_3" for read, No such file or directory
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `(rm -f (null)/STDOUT_707564_3) < /dev/null > /dev/null'
ERROR: Cannot open "(null)/STDOUT_707564_4" for read, No such file or directory
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `(rm -f (null)/STDOUT_707564_4) < /dev/null > /dev/null'
sh: -c: line 0: syntax error near unexpected token `null'
sh: -c: line 0: `ssh (null)@a.a.a.a "rm -f (null)/VM_0_13_centos_STDOUT_707564_5 > /dev/null 2>&1"'
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `( rm -f (null)/707564.tgz ) < /dev/null > (null)/STDOUT_707564_6 2>&1'
ERROR: Cannot open "(null)/STDOUT_707564_6" for read, No such file or directory
Deployment done.
PGXC Q

@cyberspicecai
Copy link

you can use virtual machine in one host. It works.

@JennyJennyChen
Copy link
Collaborator

readme is relatively simple to write, if you do not understand, you can refer to it in detail:

https://github.com/Tencent/TBase/wiki/1%E3%80%81TBase_Quick_Start

Copy the content of the configuration file pgxc_ctl.conf here and change the IP directly

@l1t1
Copy link
Author

l1t1 commented Jul 17, 2020

install a simple cluster on a local machine with 1 Coordinator, 2 Datanodes and 1 GTM ( https://www.postgres-xl.org/documentation/install-short.html )

it works, but no network config.

https://www.pgxl-xl.org/downloads/pgxl-xl-10r1.1.tar.gz

./configure
gmake
su
gmake install
adduser pgxl
mkdir /usr/local/pgsql/data_coord1
mkdir /usr/local/pgsql/data_datanode_1
mkdir /usr/local/pgsql/data_datanode_2
mkdir /usr/local/pgsql/data_gtm
chown pgxl /usr/local/pgsql/data_coord1
chown pgxl /usr/local/pgsql/data_datanode_1
chown pgxl /usr/local/pgsql/data_datanode_2
chown pgxl /usr/local/pgsql/data_gtm
su - pgxl
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data_coord1 \
  --nodename coord1
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data_datanode_1 \
  --nodename datanode_1
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data_datanode_2 \
  --nodename datanode_2

/usr/local/pgsql/bin/initgtm -D /usr/local/pgsql/data_gtm -Z gtm
/usr/local/pgsql/bin/gtm -D /usr/local/pgsql/data_gtm >logfile 2>&1 &

/usr/local/pgsql/bin/postgres --datanode -p 15432 -c pooler_port=40101 \
  -D /usr/local/pgsql/data_datanode_1 >logfile 2>&1 &
/usr/local/pgsql/bin/postgres --datanode -p 15433 -c pooler_port=40102 \
  -D /usr/local/pgsql/data_datanode_2 >logfile 2>&1 &
/usr/local/pgsql/bin/postgres --coordinator -c pooler_port=40100 \
  -D /usr/local/pgsql/data_coord1 >logfile 2>&1 &

/usr/local/pgsql/bin/psql -c "ALTER NODE coord1 \
  WITH (TYPE = 'coordinator', PORT = 5432)" postgres
/usr/local/pgsql/bin/psql -c "CREATE NODE datanode_1 \
  WITH (TYPE = 'datanode', PORT = 15432)" postgres
/usr/local/pgsql/bin/psql -c "CREATE NODE datanode_2 \
  WITH (TYPE = 'datanode', PORT = 15433)" postgres

/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_1) \
  'ALTER NODE datanode_1 WITH (TYPE = ''datanode'', PORT = 15432)'" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_1) \
  'CREATE NODE datanode_2 WITH (TYPE = ''datanode'', PORT = 15433)'" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_1) \
  'CREATE NODE coord1 WITH (TYPE = ''coordinator'', PORT = 5432)'" postgres

/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_2) \
  'ALTER NODE datanode_2 WITH (TYPE = ''datanode'', PORT = 15433)'" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_2) \
  'CREATE NODE datanode_1 WITH (TYPE = ''datanode'', PORT = 15432)'" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_2) \
  'CREATE NODE coord1 WITH (TYPE = ''coordinator'', PORT = 5432)'" postgres

/usr/local/pgsql/bin/psql -c "SELECT pgxc_pool_reload()" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_1) \
  'SELECT pgxc_pool_reload()'" postgres
/usr/local/pgsql/bin/psql -c "EXECUTE DIRECT ON (datanode_2) \
  'SELECT pgxc_pool_reload()'" postgres
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

then connect and query by

[pgxl@VM_0_13_centos ~]$ /usr/local/pgsql/bin/createdb test
[pgxl@VM_0_13_centos ~]$ /usr/local/pgsql/bin/psql test
psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))
Type "help" for help.

test=# SELECT * FROM pgxc_node;
 node_name  | node_type | node_port | node_host | nodeis_primary | nodeis_preferred |   node_id
------------+-----------+-----------+-----------+----------------+------------------+-------------
 coord1     | C         |      5432 | localhost | f              | f                |  1885696643
 datanode_1 | D         |     15432 | localhost | f              | f                |  -675012441
 datanode_2 | D         |     15433 | localhost | f              | f                | -1047623914
(3 rows)

@l1t1
Copy link
Author

l1t1 commented Jul 18, 2020

the ip address must use that ifconfig command returns

@l1t1
Copy link
Author

l1t1 commented Jul 21, 2020

install commands of tbase ,copied from (https://github.com/Tencent/TBase/wiki/5%E3%80%81TBase%E7%BB%84%E4%BB%B6%E5%AE%89%E8%A3%85%E5%8F%8A%E7%AE%A1%E7%90%86)

adduser tbase21

mkdir /data/tbase21/data_cn1
mkdir /data/tbase21/data_dn1
mkdir /data/tbase21/data_dn2
mkdir /data/tbase21/data_gtm
chown tbase21 /data/tbase21/data_cn1
chown tbase21 /data/tbase21/data_dn1
chown tbase21 /data/tbase21/data_dn2
chown tbase21 /data/tbase21/data_gtm
su - tbase21
export PATH="$PATH:/data/tbase21/bin"
export LD_LIBRARY_PATH=/data/tbase21/lib:${LD_LIBRARY_PATH}

initgtm -D /data/tbase21/data_gtm -Z gtm
gtm -D /data/tbase21/data_gtm >logfile 2>&1 &

initdb -D /data/tbase21/data_cn1 --nodename cn1 --nodetype coordinator --master_gtm_nodename gtm --master_gtm_ip localhost --master_gtm_port 5552
initdb -D /data/tbase21/data_dn1 --nodename dn1 --nodetype datanode    --master_gtm_nodename gtm --master_gtm_ip localhost --master_gtm_port 5552
initdb -D /data/tbase21/data_dn2 --nodename dn2 --nodetype datanode    --master_gtm_nodename gtm --master_gtm_ip localhost --master_gtm_port 5552

postgres --datanode -p 15552 -c pooler_port=45552 -D /data/tbase21/data_dn1 >logfile 2>&1 &
postgres --datanode -p 15553 -c pooler_port=45553 -D /data/tbase21/data_dn2 >logfile 2>&1 &
postgres --coordinator -c pooler_port=45500 -D /data/tbase21/data_cn1 >logfile 2>&1 &

psql -c "ALTER NODE cn1 WITH (TYPE ='coordinator', PORT = 5552)" postgres
psql -c "CREATE NODE dn1 WITH (TYPE ='datanode', PORT = 15552)" postgres
psql -c "CREATE NODE dn2 WITH (TYPE ='datanode', PORT = 15553)" postgres

psql -c "EXECUTE DIRECT ON (dn1) 'ALTER NODE dn1 WITH (TYPE =''datanode'', PORT = 15552)'" postgres
psql -c "EXECUTE DIRECT ON (dn1) 'CREATE NODE dn2 WITH (TYPE =''datanode'', PORT = 15553)'" postgres
psql -c "EXECUTE DIRECT ON (dn1) 'CREATE NODE cn1 WITH (TYPE =''coordinator'', PORT = 5552)'" postgres

psql -c "EXECUTE DIRECT ON (dn2) 'ALTER NODE dn2 WITH (TYPE =''datanode'', PORT = 15553)'" postgres
psql -c "EXECUTE DIRECT ON (dn2) 'CREATE NODE dn1 WITH (TYPE =''datanode'', PORT = 15552)'" postgres
psql -c "EXECUTE DIRECT ON (dn2) 'CREATE NODE cn1 WITH (TYPE =''coordinator'', PORT = 5552)'" postgres

psql -c "SELECT pgxc_pool_reload()" postgres
psql -c "EXECUTE DIRECT ON (dn1) 'SELECT pgxc_pool_reload()'" postgres
psql -c "EXECUTE DIRECT ON (dn2) 'SELECT pgxc_pool_reload()'" postgres
createdb test
psql test

@l1t1
Copy link
Author

l1t1 commented Jul 21, 2020

in the installation of #60 (comment),
postgres --coordinator -c pooler_port=45500 -D /data/tbase21/data_cn1 >logfile 2>&1 &
the port of cn1 is 5432, not 5552,

[tbase21@aaa ~]$ psql test -h localhost -p 5552
psql: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
[tbase21@aaa ~]$ psql test -h localhost -p 5432
psql (PostgreSQL 10.0 TBase V2)
Type "help" for help.

@l1t1
Copy link
Author

l1t1 commented Jul 21, 2020

postgres --datanode -p 15552 -c pooler_port=45552 -D /data/tbase21/data_dn1 >logfile 2>&1 &
direct >logfile is dangerous, it will fill the /home directory
-rw-rw-r-- 1 tbase21 tbase21 6802851932 Jul 21 11:57 logfile

@JennyJennyChen
Copy link
Collaborator

in the installation of #60 (comment),
postgres --coordinator -c pooler_port=45500 -D /data/tbase21/data_cn1 >logfile 2>&1 &
the port of cn1 is 5432, not 5552,

[tbase21@aaa ~]$ psql test -h localhost -p 5552
psql: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
[tbase21@aaa ~]$ psql test -h localhost -p 5432
psql (PostgreSQL 10.0 TBase V2)
Type "help" for help.

The correct command should be "pg_ctl -Z coordinator -D xxx start" not "postgres --coordinator xxx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants