温馨提示×

如何配置Ubuntu上的SQL Server网络

小樊
51
2025-06-06 19:25:35
栏目: 云计算

在Ubuntu上配置SQL Server网络涉及多个步骤,包括安装SQL Server、配置网络设置、打开必要的端口等。以下是一个详细的指南:

安装SQL Server

  1. 导入公共存储库GPG密钥:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc 
  1. 注册SQL Server Ubuntu存储库:

对于Ubuntu 20.04:

sudo add-apt-repository "deb [archamd64] https://packages.microsoft.com/ubuntu/20.04/mssql-server-2022 main" 

对于Ubuntu 18.04:

sudo add-apt-repository "deb [archamd64] https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 main" 
  1. 更新软件源并安装SQL Server:
sudo apt-get update sudo apt-get install -y mssql-server 

配置SQL Server

  1. 运行 mssql-conf setup 进行配置:
sudo /opt/mssql/bin/mssql-conf setup 

按照提示设置SA密码并选择版本。

  1. 启动SQL Server服务:
sudo systemctl start mssql-server 
  1. 设置SQL Server开机自启动:
sudo systemctl enable mssql-server 

配置网络

  1. 修改网络接口配置文件(例如,编辑 /etc/network/interfaces):
sudo vim /etc/network/interfaces 

添加以下内容(根据实际情况修改IP地址、子网掩码、网关等):

auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 
  1. 重启网络服务:
sudo systemctl restart networking 

或者

sudo /etc/init.d/networking restart 
  1. 打开SQL Server TCP端口:
sudo ufw allow 1433/tcp 

这将允许通过TCP端口1433访问SQL Server。

验证网络配置

  1. 检查SQL Server服务状态:
sudo systemctl status mssql-server --no-pager 

如果显示服务正在运行,则表示配置成功。

  1. 远程连接测试:

从另一台机器上尝试使用SQL Server客户端(如SQL Server Management Studio)连接到Ubuntu机器的IP地址和配置的端口,确保网络配置正确。

请注意,以上步骤假设你已经在Ubuntu上安装了SQL Server并且有一个基本的网络配置。如果遇到任何问题,请检查SQL Server的日志文件以获取更多信息。此外,确保你的Ubuntu系统和SQL Server版本兼容,并且所有必要的依赖包都已正确安装。

0