温馨提示×

如何在Debian中配置SQL Server网络

小樊
44
2025-08-01 14:27:12
栏目: 云计算

在Debian中配置SQL Server网络涉及多个步骤,包括安装必要的软件包、配置存储库、设置SQL Server服务以及开放必要的端口。以下是详细的步骤:

  1. 更新系统并安装依赖项

    sudo apt update && sudo apt upgrade
    sudo apt install -y curl gnupg apt-transport-https
    
  2. 添加Microsoft SQL Server存储库

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/debian/12/prod/ stable main" | sudo tee /etc/apt/sources.list.d/mssql-server.list
    
  3. 安装SQL Server

    sudo apt update
    sudo apt install -y mssql-server
    
  4. 配置SQL Server

    sudo /opt/mssql/bin/mssql-conf setup
    

    在配置过程中,设置系统管理员(SA)用户的密码。请记住这个密码,因为将在连接到SQL Server时使用它。

  5. 安装SQL Server命令行工具

    sudo apt install -y mssql-tools
    
  6. 配置防火墙

    sudo apt install ufw
    sudo ufw allow 1433/tcp
    sudo ufw reload
    
  7. 连接与管理SQL Server: 使用 sqlcmd 工具连接到SQL Server:

    sqlcmd -S localhost -U SA -P YourPassword
    

    请将 YourPassword 替换为在配置时为SA用户设置的密码。

  8. 配置网络(可选): 根据你的具体需求,你可能需要配置网络接口。Debian 10及更高版本可以使用 netplan 进行网络配置。 编辑或创建网络配置文件:

    sudo nano /etc/netplan/01-netcfg.yaml
    

    例如,配置有线连接:

    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: no
          addresses: [192.168.1.100/24]
          gateway4: 192.168.1.1
          nameservers:
            addresses: [8.8.8.8, 8.8.4.4]
    

    应用网络配置:

    sudo netplan apply
    

以上步骤提供了在Debian系统上配置SQL Server网络的基本指南。根据你的具体需求,可能还需要进行其他配置,如设置高可用性、配置安全选项等。建议参考Microsoft的官方文档以获取更详细的指导。

0