辅助连接服务器的安装
1. 使用场景
A和B两台服务器,A存在数据库,需要在B上进行连接
2. 步骤
- A上信息收集
- B上需要先安装数据库应用,因为dbaccess指令都在数据库应用内部
- B上配置环境变量
- B上配置sqlhost文件
- 配置互信
- 测试连接
3. 信息收集
服务器 | 实例名称 | 安装路径 | 存在数据库 | 环境变量文件 | 通信文件 |
192.168.6.6 | t1 | /home/gbasedbt/gbase | test | /home/gbasedbt/profile.t1 | /home/gbasedbt/gbase/etc/sqlhosts.t1 |
192.168.6.7 | 无 | /home/gbasedbt/gbase | 无 | /home/gbasedbt/profile.test | /home/gbasedbt/gbase/etc/sqlhosts.test |
4. B上默认已安装数据库应用,配置环境变量
su - gbasedbt
echo 'source /home/gbasedbt/profile.test' >> /home/gbasedbt/.bash_profile
echo 'export GBASEDBTDIR=/home/gbasedbt/gbase' >> /home/gbasedbt/profile.test
echo 'export GBASEDBTSQLHOSTS=/home/gbasedbt/gbase/etc/sqlhosts.test' >> /home/gbasedbt/profile.test
echo 'export PATH=/home/gbasedbt/gbase/bin:$PATH' >> /home/gbasedbt/profile.test
echo 'export DB_LOCALE=zh_CN.utf8' >> /home/gbasedbt/profile.test
echo 'export CLIENT_LOCALE=zh_CN.utf8' >> /home/gbasedbt/profile.test
echo 'export GL_USEGLU=1' >> /home/gbasedbt/profile.test
5. 配置sqlhosts文件
su - gbasedbt
cp gbase/etc/sqlhosts.std gbase/etc/sqlhosts.test
echo 't1 onsoctcp 192.168.6.6 9088 '>>gbase/etc/sqlhosts.test
6. 配置互信
--服务器192.168.6.7上,数据库服务器为192.168.6.6
--使用root用户执行以下命令
echo '+ +' >>/etc/hosts.equiv
echo '192.168.6.6' >>/etc/hosts.equiv
echo '192.168.6.6 root' >>/root/.rhosts
echo '192.168.6.7 root' >>/root/.rhosts
echo '192.168.6.6 gbasedbt' >>/root/.rhosts
echo '192.168.6.7 gbasedbt' >>/root/.rhosts
--gbasedbt用户
echo '192.168.6.6 gbasedbt' >>/home/gbasedbt/.rhosts
echo '192.168.6.7 gbasedbt' >>/home/gbasedbt/.rhosts
--服务器192.168.6.6上,有数据库的服务器IP为192.168.6.6,辅助服务器为192.168.6.7
--使用root用户执行以下命令
echo '+ +' >>/etc/hosts.equiv
echo '192.168.6.6' >>/etc/hosts.equiv
echo '192.168.6.6 root' >>/root/.rhosts
echo '192.168.6.7 root' >>/root/.rhosts
echo '192.168.6.6 gbasedbt' >>/root/.rhosts
echo '192.168.6.7 gbasedbt' >>/root/.rhosts
--gbasedbt用户
echo '192.168.6.6 gbasedbt' >>/home/gbasedbt/.rhosts
echo '192.168.6.7 gbasedbt' >>/home/gbasedbt/.rhosts
7. 测试连接
--生效环境变量
source /home/gbasedbt/profile.test
--连接
--test为服务器上的数据库,t1为实例名称
[gbasedbt@node02 ~]$ dbaccess test@t1 -
Your evaluation license will expire on 2025-05-09 00:00:00
Database selected.