在CentOS7.2上部署基于PostgreSQL10的citus分布式数据库
轉自citusdata官網在線文檔《Multi-node setup on Fedora, CentOS, or Red Hat》
在其基礎上進行了些微的改動。
This section describes the steps needed to set up a multi-node Citus cluster on your own Linux machines from RPM packages.
Steps to be executed on all nodes
1. Add repository
# Add Citus repository for package manager curl https://install.citusdata.com/community/rpm.sh | sudo bash2. Install PostgreSQL + Citus and initialize a database
# install PostgreSQL with Citus extension sudo yum install -y citus72_10 # initialize system database (using RHEL 6 vs 7 method as necessary) sudo service postgresql-10 initdb || sudo /usr/pgsql-10/bin/postgresql-10-setup initdb # preload citus extension echo "shared_preload_libraries = 'citus'" | sudo tee -a /var/lib/pgsql/10/data/postgresql.confPostgreSQL adds version-specific binaries in /usr/pgsql-10/bin, but you’ll usually just need psql, whose latest version is added to your path, and managing the server itself can be done with the service command.
3. Configure connection and authentication
Before starting the database let’s change its access permissions. By default the database server listens only to clients on localhost. As a part of this step, we instruct it to listen on all IP interfaces, and then configure the client authentication file to allow all incoming connections from the local network.
sudo vi /var/lib/pgsql/10/data/postgresql.conf # Uncomment listen_addresses for the changes to take effect listen_addresses = '*' sudo vi /var/lib/pgsql/10/data/pg_hba.conf # Allow unrestricted access to nodes in the local network. The following ranges # correspond to 24, 20, and 16-bit blocks in Private IPv4 address spaces. local all all peer local replication all peer host all all 192.168.7.0/24 trust host all all 0.0.0.0/0 md5# Also allow the host unrestricted access to connect to itself host all all 127.0.0.1/32 trust host all all ::1/128 trust【Note】
Your DNS settings may differ. Also these settings are too permissive for some environments, see our notes about Worker Security. The PostgreSQL manual explains how to make them more restrictive.
4. 配置防火墻
#查看 firewall-cmd --zone=public --query-port=5432/tcp#添加5432端口(--permanent永久生效,沒有此參數重啟后失效) firewall-cmd --zone=public --add-port=5432/tcp --permanent#重新載入 firewall-cmd --reload5. Start database servers, create Citus extension
# start the db server sudo service postgresql-10 restart # and make it start automatically when computer does sudo chkconfig postgresql-10 onYou must add the Citus extension to every database you would like to use in a cluster. The following example adds the extension to the default database which is named postgres.
sudo -i -u postgres psql -c "CREATE EXTENSION citus;"Steps to be executed on the coordinator node
The steps listed below must be executed only on the coordinator node after the previously mentioned steps have been executed.
1. Add worker node information
We need to inform the coordinator about its workers. To add this information, we call a UDF which adds the node information to the pg_dist_node catalog table, which the coordinator uses to get the list of worker nodes. For our example, we assume that there are two workers (named worker-101, worker-102). Add the workers’ DNS names (or IP addresses) and server ports to the table.
sudo -i -u postgres psql -c "SELECT * from master_add_node('192.168.7.130', 5432);" sudo -i -u postgres psql -c "SELECT * from master_add_node('192.168.7.131', 5432);"2. Verify that installation has succeeded
To verify that the installation has succeeded, we check that the coordinator node has picked up the desired worker configuration. This command when run in the psql shell should output the worker nodes we added to the pg_dist_node table above.
sudo -i -u postgres psql -c "SELECT * FROM master_get_active_worker_nodes();"Ready to use Citus
At this step, you have completed the installation process and are ready to use your Citus cluster. The new Citus database is accessible in psql through the postgres user:
sudo -i -u postgres psql【Note】
Please note that Citus reports anonymous information about your cluster to the Citus Data company servers. To learn more about what information is collected and how to opt out of it, see Checks For Updates and Cluster Statistics.
總結
以上是生活随笔為你收集整理的在CentOS7.2上部署基于PostgreSQL10的citus分布式数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 洛阳市有害生物防控员怎么报考
- 下一篇: Citus初步测试