sql如何重命名实例

In my previous articles, we installed the SQL Server 2019 CTP 2.1 on Ubuntu Linux. You can follow the below articles to prepare the SQL instance on Linux.

在我之前的文章中,我们在Ubuntu Linux上安装了SQL Server 2019 CTP 2.1。 您可以按照以下文章在Linux上准备SQL实例。

  • SQL Server 2019 on Linux with Ubuntu Linux与Ubuntu上SQL Server 2019
  • SQL Server 2019 on Linux with a Docker container on Ubuntu Linux上SQL Server 2019和Ubuntu上的Docker容器
  • SQL Server 2019 on Linux with Ubuntu and Azure Data Studio 具有Ubuntu和Azure Data Studio的Linux上SQL Server 2019

Sometimes we build the server without worrying about the server name. This might be just for the testing purpose. We give it some name but later we might need to change the hostname of the server. It might be due to the naming convention being followed up in the organization. If we rename the hostname of the instance in the Linux operating system, we might need to worry about the SQL instance as well. By default, SQL instance runs on the hostname of the server. Therefore, if we change the hostname, will there be any impact on the application connecting with the SQL Server with the hostname? If we change the hostname of the server, we will definitely want to change the SQL Server name as well to avoid any confusion.

有时,我们在构建服务器时无需担心服务器名称。 这可能只是出于测试目的。 我们给它起一个名字,但是稍后我们可能需要更改服务器的主机名。 这可能是由于组织中遵循了命名约定。 如果在Linux操作系统中重命名实例的主机名,则可能还需要担心SQL实例。 默认情况下,SQL实例在服务器的主机名上运行。 因此,如果我们更改主机名,对使用该主机名与SQL Server连接的应用程序有什么影响? 如果我们更改服务器的主机名,那么我们肯定也会更改SQL Server名称,以免造成混淆。

In this article, we will explore these scenarios

在本文中,我们将探讨这些场景

  • Temporary and Permanent methods to change the hostname of the Ubuntu server 临时和永久方法来更改Ubuntu服务器的主机名
  • Rename SQL Server instance on Ubuntu 在Ubuntu上重命名SQL Server实例
  • View the system error logs 查看系统错误日志

You need to launch the virtual machine configured earlier with SQL instance on it. Launch the terminal from the applications in Ubuntu server.

您需要启动之前配置了SQL实例的虚拟机。 从Ubuntu服务器中的应用程序启动终端。

Run the command ‘hostname’ to get the current hostname. We can see here our current hostname is ‘rajendra-VirtualBox’

运行命令“主机名”以获取当前主机名。 我们可以在这里看到我们当前的主机名是“ rajendra-VirtualBox”

We can change the hostname of Ubuntu with the two methods

我们可以通过两种方法更改Ubuntu的主机名

  1. Temporary change 临时变更
  2. Permanent change 永久变更

在Ubuntu中临时更改主机名 (Temporary change the hostname in Ubuntu )

We can change the hostname using the command ‘hostname NewName’. This command needs to be run under the root permissions i.e. sudo. We will get below error message if we try to run the command without sudo permission ‘hostname: you must be root to change the hostname’

我们可以使用命令“主机名NewName”来更改主机名。 该命令需要在root权限(即sudo)下运行。 如果我们尝试在没有sudo权限的情况下运行命令,则会收到以下错误消息:“主机名:您必须是root用户才能更改主机名”

Let us change the hostname from ‘rajendra-VirtualBox’ to ‘rajendra-SQLLinux’ with the below command.

让我们使用以下命令将主机名从“ rajendra-VirtualBox”更改为“ rajendra-SQLLinux”。

$ Sudo hostname rajendra-SQLLinux

$ Sudo主机名rajendra-SQLLinux

Verify the hostname and we can see the new name for the server. You can notice here the command line still says ‘rajendra@rajendra-VirtualBox’

验证主机名,我们可以看到服务器的新名称。 您可以在此处注意到命令行仍然显示“ rajendra @ rajendra-VirtualBox”

If we try to connect the SQL Server with the new hostname, we get an error message that the server was not found or not accessible. This is due to the instance name is not configured with the SQL Server.

如果尝试使用新的主机名连接SQL Server,则会收到一条错误消息,指出找不到或无法访问该服务器。 这是由于没有使用SQL Server配置实例名称。

We can connect to the SQL instance using the IP address and the old instance name ‘rajendra-VirtualBox’ in SQL Server Management Studio as shown below. This shows there is no impact on SQL Server even we have changed the Ubuntu hostname.

我们可以使用IP地址和SQL Server Management Studio中的旧实例名称“ rajendra-VirtualBox”连接到SQL实例,如下所示。 这表明即使我们更改了Ubuntu主机名,对SQL Server也没有影响。

Let us restart the server using the command ‘shutdown -r’. This command schedules the restart of the server. You can see the message ‘Shutdown scheduled for sat 2018-12-08 08:28:56 IST, use shutdown -c to cancel’

让我们使用命令'shutdown -r'重新启动服务器。 此命令安排服务器的重新启动。 您可以看到以下消息:``计划于2018年12月8日星期六停产IST,请使用shutdown -c取消''

If we want to cancel the shutdown, we can run the command ‘shutdown -c’

如果要取消关闭,可以运行命令'shutdown -c'

We get the broadcast message at the scheduled time and the system starts the reboot process.

我们在计划的时间收到广播消息,系统开始重新启动过程。

Once the server reboot is completed, verify the hostname and we are again back to old hostname ‘rajendra-VirtualBox’

服务器重新启动完成后,验证主机名,然后我们又回到旧的主机名'rajendra-VirtualBox'

Ubuntu中的永久更改主机名 (Permanent change hostname in Ubuntu)

We can change hostname permanently using the GUI as well as the command line mode. Click on the ‘system settings’ icon in Ubuntu followed by the details.

我们可以使用GUI和命令行模式永久更改主机名。 单击Ubuntu中的“系统设置”图标,然后单击详细信息。

In details, it opens the device detail and you can see device name as highlighted.

在详细信息中,它将打开设备详细信息,您可以看到突出显示的设备名称。

Device name section is having a text box, therefore enter the new name and close it with the ‘x’ icon on top left side.

设备名称部分有一个文本框,因此请输入新名称并使用左上角的“ x”图标将其关闭。

We are done now. We are having the new server name for our virtual machine.

现在完成。 我们正在为虚拟机使用新的服务器名称。

From the command line, we can run the below command and edit the hostname.

在命令行中,我们可以运行以下命令并编辑主机名。

sudo vi /etc/hostname

须藤vi / etc / hostname

You can restart the server again and verify it. It changes the hostname permanently.

您可以再次重新启动服务器并进行验证。 它将永久更改主机名。

Now, connect to the SQL instance and check the instance name using command ‘select @@servername’. We are still having an old hostname for the SQL Server.

现在,连接到SQL实例,并使用命令'select @@ servername'检查实例名称。 我们仍然有一个旧SQL Server主机名。

We need to drop this server name using the command

我们需要使用以下命令删除该服务器名称

sp_dropserver ‘server name’

sp_dropserver'服务器名称'

In our case, execute the below command in the SSMS.

在我们的情况下,在SSMS中执行以下命令。

Sp_dropserver ‘rajendra-VirtualBox’

Sp_dropserver'rajendra-VirtualBox'

Now, register the new instance name using the sp_addserver command.

现在,使用sp_addserver命令注册新的实例名称。

Sp_addserever ‘server name’,’local’

Sp_addserever'服务器名称','本地'

Therefore run the command as below

因此,如下运行命令

Sp_addserver ‘rajendra-sqllinuxDemo’,’local’

Sp_addserver'rajendra-sqllinuxDemo','本地'

We need to restart SQL Server on Linux to apply this new hostname.

我们需要在Linux上重新启动SQL Server才能应用此新主机名。

Restart the mssql-server services

重新启动mssql服务器服务

Sudo systemctl restart mssql-server

Sudo systemctl 重新启动 mssql-server

Verify the service status, it should be ‘active (running)’

验证服务状态,它应该是“活动的(正在运行)”

Sudo systemctl status mssql-server

sudo systemctl 状态 mssql-server

Connect to SQL instance and verify the instance name. Yes, it is now pointing the new hostname similar to the hostname we have configured at the operating system level.

连接到SQL实例并验证实例名称。 是的,它现在指向的新主机名类似于我们在操作系统级别配置的主机名。

You can now connect to SQL Server using both IP address and the new hostname.

现在,您可以使用IP地址和新的主机名连接到SQL Server。

If you look at the SQL Server logs and filter the results for the server name, you get the below message.

如果查看SQL Server日志并过滤服务器名称的结果,则会收到以下消息。

I found out the issue with this message in the SQL Server logs. If you look carefully, the message says ‘ Server name is ‘rajendra-sqllin’. This is an informational message only. No user action is required.’

我在SQL Server日志中发现了此消息的问题。 如果仔细查看,该消息将显示“服务器名称为'rajendra-sqllin'。 这仅是参考消息。 无需用户操作。'

It shows the server name ‘rajendra-sqllin’ while our actual server name is ”rajendra-sqllinuxDemo’. We can connect to the server name ”rajendra-sqllinuxDemo”’ as shown above. It truncates the server name in the error logs. This feature might be improved in the upcoming releases of SQL Server.

它显示了服务器名称“ rajendra-sqllin”,而我们的实际服务器名称是“ rajendra-sqllinuxDemo”。 我们可以连接到服务器名称“ rajendra-sqllinuxDemo”,如上所示。 它会在错误日志中截断服务器名称。 即将发布SQL Server版本中可能会改进此功能。

We can verify the new instance name using the ‘sp_helpserver’ command as well. In below screenshot, we can see both the commands return the new hostname.

我们也可以使用“ sp_helpserver”命令来验证新实例名称。 在下面的屏幕截图中,我们可以看到两个命令都返回了新的主机名。

结论 (Conclusion)

It is an important thing for the database administrators to know the process of changing the SQL Server instance name. You should explore this article in your test instance. Please note this article applies on the standalone SQL Server instance only. If you are running cluster SQL instance, you need to follow additional steps that I will explore in my future articles.

对于数据库管理员来说,了解更改SQL Server实例名称的过程是很重要的。 您应该在测试实例中浏览本文。 请注意,本文仅适用于独立SQL Server实例。 如果您正在运行群集SQL实例,则需要执行其他步骤,这些步骤我将在以后的文章中进行探讨。

目录 (Table of contents)

SQL Server 2019 on Linux with Ubuntu and Azure Data Studio
SQL Server 2019 on Linux with a Docker container on Ubuntu
SQL Server 2019 on Linux with Ubuntu
SQL Server 2019 installation on Ubuntu without a Docker Container
Renaming Logical and Physical file names in SQL Server on Linux
Rename SQL Server instance on Ubuntu Linux
具有Ubuntu和Azure Data Studio的Linux上SQL Server 2019
Linux上SQL Server 2019和Ubuntu上的Docker容器
Linux与Ubuntu上SQL Server 2019
在没有Docker容器的Ubuntu上安装SQL Server 2019
在Linux上SQL Server中重命名逻辑和物理文件名
在Ubuntu Linux上重命名SQL Server实例

翻译自: https://www.sqlshack.com/renaming-a-sql-server-instance-on-ubuntu-linux/

sql如何重命名实例

sql如何重命名实例_重命名Ubuntu Linux上SQL Server实例相关推荐

  1. linux generic什么意思_如何在 Ubuntu Linux 上释放 /boot 分区的空间? | Linux 中国

    导读:前几天,我收到一个警告,/boot 分区已经几乎满了,没有剩余空间了. 本文字数:2868,阅读时长大约:4分钟https://linux.cn/article-12779-1.html作者:A ...

  2. sql server重命名_在Linux上SQL Server中重命名逻辑和物理文件名

    sql server重命名 Each database in SQL Server contains at least two files i.e. Data file (*.mdf) and log ...

  3. 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置

    转储sql文件 In this article, we will talk about SQL Dump files and the process to change the dump direct ...

  4. sql数据库备份默认路径_在Linux上SQL Server中更改默认数据库文件和备份路径

    sql数据库备份默认路径 In a previous article, we explored the process to change default SQL dump file location ...

  5. Linux上SQL Server 2019和Ubuntu上的Docker容器

    In the first article of the series on SQL Server 2019 and Ubuntu, we prepared the virtual machine en ...

  6. 具有Ubuntu和Azure Data Studio的Linux上SQL Server 2019

    In the previous articles of this series on using SQL Server 2019 on Ubuntu, we have explored the fol ...

  7. linux设置默认终端模拟器,ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器...

    ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置 Ubuntu has a ...

  8. python驼峰命名法_蛇形命名,驼峰命名,你的选择?

    关于今天要讲的,小编想想还有点小激动.那就是关于变量的命名,这个一直都是容易引起程序员论战的话题.如何命名才更具可读性.易写性以及明义性? 程序命名常使用的是英文单词,当他们被作为变量名时,有全小写. ...

  9. java 连接池实例_功能完善的Java连接池调用实例

    /** * Title: ConnectPool.java * Description: 连接池管理器 * Copyright: Copyright © 2002/12/25 * Company: * ...

最新文章

  1. nutz oracle配置,nutz的框架NutzDao-自定义SQL
  2. html轮播图鼠标可以暂停,为什么better scroll轮播鼠标点击就会暂停?
  3. Programming Computer Vision with Python (学习笔记五)
  4. clone远程代码 在不同电脑上git_用树莓派3搭建私有git代码仓库
  5. 在阿里云上以Daemon进程方式运行SAP Cloud Connector portable版本的尝试
  6. 高级组件——弹出式菜单JPopupMenu
  7. pytorch张量操作基础
  8. 用开源组件jcaptcha做jsp彩色验证码
  9. 【Linux】系统移植篇一--linux系统移植导学
  10. PreScan第一课:软件简介和基础
  11. InstallShield 2020中文版
  12. mysql 中 字典表设计_数据库怎么设计字典表
  13. 《我喜欢生命本来的样子》周国平 .mobi .epub .pdf .azw3 电子版下载 读书笔记
  14. Cache tier使用文档
  15. TOC和TOB产品的区别是什么
  16. Django 一文看懂urls.py与views.py的联系
  17. 关于travis scott的网名_异地恋情侣网名甜蜜秀恩爱
  18. 大寰机器人通讯转换系统(CTS-B1.0) 操作说明
  19. python做运动控制_用 Python 写一个跟踪运动对象系统
  20. bzoj 2121 字符串游戏

热门文章

  1. 403 forbidden nginx_5,Logstash正则提取Nginx日志 - pwcc
  2. jdbc连接oracle_Oracle数据库性能监控|使用SiteScope 监控Oracle
  3. Android多线程的使用
  4. Oracle中动态SQL详解
  5. Hadoop伪分布安装配置
  6. 我就喜欢不用图片做圆角之山顶角方法
  7. 计算机网络学习笔记(30. DNS记录和消息)
  8. Error: listen EADDRINUSE: address already in use :::5000
  9. Linux系统是什么
  10. 现在农村有比较多老了的丝瓜,这些老了的丝瓜有什么作用吗?