Linux系统连接

<p class="shortdesc">本文主要介绍如何在Linux操作系统的ECS上安装PostgreSQL客户端,并通过PostgreSQL客户端访问RASESQL实例。</p> <section class="section prereq" id="Linux_RASESQL__prereq_mbc_kxm_hsb"><div class="tasklabel"><h2 class="doc-tairway">前提条件</h2></div> <ol class="ol" id="Linux_RASESQL__ol_onr_kxm_hsb"> <li class="li">您已成功创建RASESQL实例,可参考<a class="xref" href="/ssr/help/database/RASESQL/User_Guide_for_RDS_PostgreSQL.Instance_Management.Create_Instance.Create_Common_Instance_MySQL" target="_blank" rel="external noopener">创建RASESQL实例</a>。</li> <li class="li">您已成功创建ECS,可参考<a class="xref" href="/ssr/help/database/RASESQL/Getting_Started.createECSRASESQL" target="_blank" rel="external noopener">创建ECS</a>,且实例处于运行中。</li> <li class="li">您已成功开通白名单,可参考<a class="xref" href="/ssr/help/database/RASESQL/User_Guide_for_RDS_PostgreSQL.Security_Management_RASESQL.Create_Whitelist_RDS_RASESQL" target="_blank" rel="external noopener">开通白名单</a>。</li> </ol> </section> <section class="section context"><div class="tasklabel"><h2 class="doc-tairway">背景信息</h2></div> <p class="p">ECS的操作系统请选择CentOS 7.x、RedHat Linux 7.x、Oracle Linux 7.x及以上的版本。</p> </section> <section><div class="tasklabel"><h2 class="doc-tairway">操作步骤</h2></div><ol class="ol steps"><li class="li step stepexpand"> <span class="ph cmd"><a class="xref" href="/ssr/help/compute/ecs/manual.Instance.Login_Linux_Instance.Console_Remote_Login" target="_blank" rel="external noopener">登录Linux云主机</a>。</span> </li><li class="li step stepexpand"> <span class="ph cmd">执行以下命令打开xxx.repo文件。</span> <div class="itemgroup info"> <div class="note important note_important"><span class="note__title">重要:</span> <p class="p">xxx:文件名称,您可以根据实际情况自定义。</p> </div> <pre class="pre codeblock"><code>cd /etc/yum.repos.d vim xxx.repo </code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">在xxx.repo文件中增加以下内容。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>[PostgreSQL] //您可以根据实际情况自定义名称 name=postgresql11-rhel-7-x86_64 baseurl=http://mirrors.yun.paic.com.cn:4048/postgresql/repos/yum/12/redhat/rhel-8-x86_64/ enabled=1 gpgcheck=0 </code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">执行以下命令,更新yum源。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>yum clean all && yum makecache</code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">执行以下命令,屏蔽默认的PostgreSQL软件。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>yum -qy module disable postgresql</code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">执行以下命令,安装PostgreSQL客户端。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>yum install postgresql11</code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">执行以下命令,并输入密码,连接RASESQL实例。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>psql -h <em class="ph i">Domain-name</em> -p <em class="ph i">Port</em> -U <em class="ph i">Postgresql_Account</em> -d <em class="ph i">postgres</em> -W</code></pre> <div class="note important note_important"><span class="note__title">重要:</span> <p class="p">各参数说明如下,若需了解更多实例相关信息可参考<a class="xref" href="/ssr/help/database/RASESQL/User_Guide_for_RDS_PostgreSQL.Instance_Management.View_Instance_RASESQL.View_Common_Instance_RASESQL" target="_blank" rel="external noopener">查看实例基本信息</a>。</p> <ul class="ul" id="Linux_RASESQL__ul_pvx_5xm_hsb"> <li class="li">-h <em class="ph i">Domain-Name</em>:RASESQL实例的<span class="ph uicontrol">访问域名</span>。</li> <li class="li">-p<em class="ph i"> Port</em>:RASESQL实例的<span class="ph uicontrol">连接端口</span>。</li> <li class="li">-U <em class="ph i">Postgresql _Account</em>:创建的管理员名称。</li> <li class="li">-d postgres:需要连接的数据库名称,默认为postgres数据库。</li> <li class="li">-W:强制输入密码,执行上述命令后,根据提示信息输入创建账号时设置的密码。</li> </ul> </div> </div> </li></ol></section> <section class="section result"><div class="tasklabel"><h2 class="doc-tairway">执行结果</h2></div> <p class="p">成功连接RASESQL实例。</p> <div class="p"> <img class="image" id="Linux_RASESQL__image_n1z_vxm_hsb" src="https://obs-cn-shanghai.fincloud.pinganyun.com/pacloud/20231101095159-18074eb59194.png"> </div> </section>
以上内容是否解决了您的问题?
请补全提交信息!
联系我们

电话咨询

400-151-8800

邮件咨询

fincloud@ocft.com

在线客服

工单支持

解决云产品相关技术问题