
# GaussDB分布式为源的单任务配置方法
方式一：修改配置文件
#### 操作步骤
1. 登录GaussDB分布式数据库所有节点。
2. 查询配置文件位置： 
   ```
   find / -name "pg_hba.conf"
   或者
   find / -name "gs_hba.conf"
   ```
   
   
3. 打开pg_hba.conf，建议原有的sha256不动，在sha256的配置前一行配置指定单任务同步用户的trust。 
   - CN节点配置：
     host replication \<user\> 0.0.0.0/0 sha256
     图1CN节点配置图   
     ![](https://support.huaweicloud.com/drs_faq/figure/zh-cn_image_0000001866140889.png "点击放大") 
   
   - DN节点配置： host replication \<*user*\> 0.0.0.0/0 trust
     图2DN节点配置图   
     ![](https://support.huaweicloud.com/drs_faq/figure/zh-cn_image_0000001866261065.png "点击放大")
     ![](https://support.huaweicloud.com/drs_faq/public_sys-resources/note_3.0-zh-cn.png)
     DN节点配置中，建议不要将\<*user*\>指定为all，否则会影响分布式为源多任务模式下直连DN解码。
     
   
   
   
   
4. 在源数据库使用系统管理员用户执行以下语句，或重启数据库实例，使修改生效。 
   ```
   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. 如果用户只使用单任务模式，以单任务迁移模式用户drs1为例： 
   gs_guc reload -Z coordinator -N all -I all -h "host all drs1 0.0.0.0/0 sha256"
   gs_guc reload -Z coordinator -N all -I all -h "host replication drs1 0.0.0.0/0 sha256"
   配置cn连接dn的复制连接，以cn节点网段192.168.0.0/16为例
   gs_guc reload -Z datanode -N all -I all -h 'host replication drs1 192.168.0.0/16 trust'
   
   如果用户只使用多任务模式，以多任务迁移模式用户drs2为例：
   gs_guc reload -Z datanode -Z coordinator -N all -I all -h "host all drs2 0.0.0.0/0 sha256"
   gs_guc reload -Z datanode -N all -I all -h 'host replication drs2 0.0.0.0/0 sha256'
   ![](https://support.huaweicloud.com/drs_faq/public_sys-resources/note_3.0-zh-cn.png)
   如果同一个源数据库实例，用户同时使用多任务模式和单任务模式，建议规划好迁移用户，按照用户进行配置。
   
   
 
