
# GaussDB分布式为源的多任务配置方法
GaussDB分布式为源的多任务配置方法有两种，修改配置文件、通过gs_guc修改。
#### 修改配置文件操作步骤
1. 登录GaussDB分布式数据库所有CN节点。
2. 查询配置文件位置： 
   ```
   find / -name "pg_hba.conf"
   或者
   find / -name "gs_hba.conf"
   ```
   
   
3. 打开pg_hba.conf或者**gs_hba.conf** ，增加配置如下：
   
   ```
   host all <user> 0.0.0.0/0 sha256
   ```
   
   
4. 登录GaussDB分布式数据库所有DN节点。
5. 执行命令查询配置文件位置。 
   ```
   find / -name "pg_hba.conf"
   或者
   find / -name "gs_hba.conf"
   ```
   
   
6. 打开pg_hba.conf 或者**gs_hba.conf** ，增加配置如下：
   
   ```
   host all <user> 0.0.0.0/0 sha256
   host replication <user> 0.0.0.0/0 sha256
   ```
   
   
7. 在源数据库使用系统管理员用户执行以下语句，或重启数据库实例，使修改生效。 
   ```
   select pg_reload_conf();
   ```
   
   
 
#### 通过gs_guc修改操作步骤
1. **云上数据库，进入沙箱需执行以下命令；** 自建数据库，source gauss_env_file环境变量文件即可。
   
   **登录数据库实例任一节点，切换至Ruby用户，su - Ruby**
   1. 2.0(V500R002C00)以前版本
      ```
      /usr/sbin/chroot /var/chroot /bin/bash
      source /etc/profile && source ~/.bashrc
      ```
      
   
   2. 2.0(V500R002C00)及以后版本
      ```
      chroot /var/chroot
      source /etc/profile; source /home/Ruby/.bashrc ;source /home/Ruby/gauss_env_file
      ```
      
   
   
   ![](https://support.huaweicloud.com/drs_faq/public_sys-resources/note_3.0-zh-cn.png)
   华为云上GaussDB实例，需要数据库oncall同事实施变更
   
   
2. 1）普通连接 
   如果放开所有用户、ip普通连接到cn、dn节点：
   gs_guc reload -Z datanode -Z coordinator -N all -I all -h "host all all 0.0.0.0/0 sha256"
   如果放开指定\<user\>、\<ip\>普通连接到cn、dn节点：
   gs_guc reload -Z datanode -Z coordinator -N all -I all -h "host all \<user\> \<ip\>/32 sha256"
   2）逻辑复制连接
   如果放开所有用户、ip复制连接到dn节点：
   gs_guc reload -Z datanode -N all -I all -h "host replication all 0.0.0.0/0 sha256"
   如果放开指定\<user\>、\<ip\>复制连接到dn节点：
   gs_guc reload -Z datanode -N all -I all -h "host replication \<user\> \<ip\>/32 sha256
   
   
 
