SQLServer On Linux 常用操作(启动、停止、启用、禁用、浏览)|学习笔记

本文涉及的产品
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
云数据库 RDS SQL Server,基础系列 2核4GB
简介: 快速学习 SQLServer On Linux 常用操作(启动、停止、启用、禁用、浏览)

开发者学堂课程【SQL Server on Linux入门教程SQLServer On Linux 常用操作(启动、停止、启用、禁用、浏览)】学习笔记,与课程紧密联系,让用户快速学习知识

课程地址:https://developer.aliyun.com/learning/course/386/detail/4840


SQLServer On Linux 常用操作(启动、停止、启用、禁用、浏览)


内容介绍

STATUS

START

STOP

ENABLE/DISABLE

 

一、STATUS

1、查看状态 SQLServer On Linux打开 terminal 连接虚拟机,启动停止服务或者设置属性是需要 root 权限的如果没有 root 用户密码最好使用一个有输入权限的用户去检查状态

2、代码如下

Last login:Sat Dec 24 14:51:52 on ttys000

[cherishs-MacBook-Pro:~ cherish$ ssh root@192.168.99.101

[root@192.168.99.101's password:

Lastlogin:Sun Dec 18 23:04:36 2016 from 192. 168.99.1

[root@localhost ~]# clear

 

二、START

启动服务代码如下:

[root@localhost ~]# whoami

root

[root@localhost ~]# systemctl status mssql-server 使用status命令mssql-server 是服务的名字

mssql-server.service - Microsoft(R) SQL Server(R) Database Engine

Loaded:loaded(/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)内部的状态是enabled

Active:active(running)sinceSun2016-12-18 23:09:09 CST; 8min ago  服务是 running 的状态

Main PID: 4856 (sqlservr)

CGroup: /system.slice/mssql-server.service

- 4856 /opt/mssql/bin/sqlservr

-4858 /opt/mssql/bin/sqlservr

dec 18 23:09:15 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:15.88 spid6s Starting up database ' tempdb'.

dec 18 23:09:16 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:16.12 spid6s

The tempdb database has 1 data file(s).

dec 18 23:09:16 loca lhost. localdomain sqlservr [4856]: 2016-12-18 15:09:16.13 spid20s

The Service Broker endpoint is in dis...tate.

dec 18 23:09:16 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:16.14 spid20s

he Database Mirroring endpoint is in...tate.

dec 18 23:09:16 loca lhost. localdomain sqlservr[4856]: 2016- -12-18 15:09:16.19 spid20s

Service Broker manager has started.

dec 18 23:09:16 loca lhost. loca ldomain sqlservr [4856]: 2016-12-18 15:09:16.19 spid5s

Recovery is complete. This is an info...ired.

dec 18 23:14:29 localhost. localdomain sqlservr[4856]: 2016-12-18 15:14:29.87 spid51

Attempting to load library 'xplog70.d... ired.

dec 18 23:14:29 loca lhost. localdomain sqlservr [4856]: 2016-12-18 15:14:29.90 spid51

Using 'xplog70.dll' version '201

dec 18 23:15:25 localhost. localdomain systemd[1]: [/usr/lib/systemd/system/mssql-server . service:15] Unknown lvalue 'TasksMax' ...rvice' ec 18 23:15:57 localhost. localdomain systemd[1]: [/usr/lib/systemd/ system/mssql-server . service:15] Unknown lvalue 'TasksMax' ... rvice'

Hint: Some lines were ellipsized, use -l to show in full.

用 service 命令也可以启动服务是会有一个提示信息 Redirecting to /bin/ systemctl status mssql-server.service

redirect 到 bin 目录下 systemctl 命令下面并且是 systemctl status 这个服务加服务名字这种方式

 

三、STOP

停止服务代码如下

[root@localhost ~]# systemctl stop mssql-server

systemctl 命令加停止单词加服务的名字

[root@localhost ~]# systemctl status mssql-server

mssql-server.service - Microsoft(R) SQL Server(R) Database Engine

Loaded:loaded(/usr/lib/systemd/system/mssql-server. service; enabled; vendor preset: disabled)

Active: faild (Result: exit-code) since Sun 2016-12-18 23:18:43 CST; 3s ago在这里可以看到服务已经被停止了

Main PID: 4856 (code=exited, status=1/FAILURE)

dec 18 23:15:57 localhost. localdomain systemd [1]: [/usr/lib/systemd/system/mssql-server. service:15] Unknown lvalue 'TasksMax' ...rvice' ec 18 23:18:42 localhost. localdomain systemd[1: Stopping Microsoft(R) SQL Server(R) Database Engine...

dec 18 23:18:42 localhost. localdomain sqlservr[4856: 2016-12-18 15:18:42.82 spid5s

SQL Server is terminating in response...ired.

dec 18 23:18:43 localhost. localdomain sqlservr[4856]: 2016-12-18 15:18:43.14 spid20s

Service Broker manager has shut down.

dec 18 23:18:43 localhost. loca ldomain sqlservr [4856]: 2016-12-18 15:18:43.22 spid5s

SQL Server shutdown has been initiated

dec 18 23:18:43 localhost. localdomain sqlservr[4856]: 2016-12-18 15:18:43.22 spid5s

SQL Trace was stopped due to server s...ired.

dec 18 23:18:43 localhost. localdomain systemd[1]: mssql-server.service: main process exited, code=exited, status=1/FAILURE

dec 18 23:18:43 localhost. localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Database Engine.

dec 18 23:18:43 localhost. localdomain systemd[1]: Unit mssql-server.service entered failed state.

dec 18 23:18:43 localhost. localdomain systemd[1]: mssql-server . service failed.

Hint: Some lines were ellipsized, use -l to show in full.

 

四、ENABLE/DISABLE

1、disabled 服务代码如下

[root@localhost ~]# systemctl disable mssql-server

Removed symlink /etc/systemd/system/multi-user. target . wants/mssql-server .service.

[root@localhost ~]# systemctl status mssql-server

mssql-server.service - Microsoft(R) SQL Server(R) Database Engine

Loaded:loaded(/usr/lib/systemd/system/mssql-server.service; disabled; vendor preset: disabled)这里可以看到服务已经被 disabled

Active: failed (Result: exit-code) since Sun 2016-12-18 23:18:43 CST; 29s ago

Main PID: 4856 (code=exited, status=1/FAILURE )

Dec 18 23:18:42 localhost. localdomain systemd[1]: Stopping Microsoft(R) SQL Server(R) Database Engine...

Dec 18 23:18:42 localhost. loca ldomain sqlservr[4856] : 2016-12-18 15:18:42.82 spid5s

SQL Server is terminating in response..ired.

Dec 18 23:18:43 localhost. localdomain sqlservr(4856]: 2016-12-18 15:18:43.14 spid20s

Service Broker manager has shut down.

Dec 18 23:18:43 localhost. localdomain sqlservr[4856]: 2016-12-18 15:18:43.22 spid5s

SQL Server shutdown has been initiated

Dec 18 23:18:43 localhost. localdomain sqlservr(4856): 2016-12-18 15:18:43.22 spid5s

SQL Trace was stopped due to server s... ired.

Dec 18 23:18:43 localhost. loca ldomain systemd [1]: mssql-server.service: main process exited, code-exited, status=1/FAILURE

Dec 18 23:18:43 localhost. localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Database Engine.

Dec 18 23:18:43 localhost. localdomain systemd(1]: Unit mssql-server. service entered failed state.

Dec 18 23:18:43 localhost. localdomain systemd[1]: mssql-server .service failed.

Dec 18 23:19:11 loca lhost. localdomain systemd[1]: [/usr/lib/systemd/system/mssql-server. service:151 Unknown lvalue ' TasksMax' ...rvice "

Hint: Some lines were ellipsized, use -l to show in full.

2、enable 代码如下

[rootglocalhost ]# systemctl enable nssql-server

Created symlink from /etc/ sys temd/system/multi-user. target . wants/mssql-server.service to /usr/lib/sys temd/system/mssql-server. service.

[root@localhost ~]# systemctl status mssql-server

mssql-server.service · Microsoft(R) SQL Server(R) Database Engine

Loaded: loaded (/usr/lib/systemd/ system/mssql-server. service; enabled; vendor preset: disabled)在这可以看到 enabled

Active: failed (Result: exit-code) since Sun 2016-12-18 23:18:43 CST; 40s ago

Main PID: 4856 (code=exited, status=1/FAILURE)

Dec 18 23:18:42 localhost. localdomain sqlservr [4856]: 2016-12-18 15:18:42.82 spid5s

SQL Server is terminating in response... ired.

Dec 18 23:18:43 loca lhost. localdomain sqlservr [4856]: 2016-12-18 15:18:43.14 spid20s

Service Broker manager has shut down.

Dec 18 23:18:43 localhost. loca ldomain sqlservr [4856]: 2016-12-18 15:18:43.22 spid5s

SQL Server shutdown has been initiated

Dec 18 23:18:43 localhost. loca ldomain sqlservr [4856]: 2016-12-18 15:18:43.22 spid5s

SQL Trace was stopped due to server S...ired.

Dec 18 23:18:43 loca lhost. localdomain systemd[1): mssql-server.service: main process exited, code=exited, status= 1/FAILURE

Dec 18 23:18:43 localhost. loca ldomain systemd[1): Stopped Microsoft(R) SQL Server(R) Database Eng ine .

Dec 18 23:18:43 localhost. localdomain systemd[1]: Unit mssql-server. service entered failed state.

Dec 18 23:18:43 localhost. localdomain systemd[1l: mssql-server , service failed.

Dec 18 23:19:11 localhost. localdomain systemd [1]: [/usr/lib/systemd/system/m . service:15] Unknown lvalue 'TasksMax' ...rvice'

Dec 18 23:19:22 localhost. localdomain systemdI1): [ /usr/lib/ systemd/system/ms sql-server , service:15] Unknown lvalue 'TasksMax' ... rvice'

Hint: Some lines were ellipsized, use -l to show in full.

相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情: https://www.aliyun.com/product/rds/sqlserver
相关文章
|
5月前
|
Linux Shell
入职必会-开发环境搭建36-Linux常用操作-Linux环境变量
环境变量的作用是指定到哪个目录去找你输入的命令执行。环境变量的设置分为:临时设置和永久设置两种。
|
7月前
|
网络协议 Java Linux
Linux学习笔记
Linux学习笔记
111 0
|
7月前
|
SQL
sqlserver 常用操作
sqlserver 常用操作
|
3月前
|
Shell Linux
Linux shell编程学习笔记30:打造彩色的选项菜单
Linux shell编程学习笔记30:打造彩色的选项菜单
|
5月前
|
域名解析 网络协议 Linux
入职必会-开发环境搭建38-Linux常用操作-Linux设置IP
目前安装的Linux操作系统默认是动态获取IP地址,IP地址可能会发生变动,需要把IP地址设置为静态的。
入职必会-开发环境搭建38-Linux常用操作-Linux设置IP
|
1月前
|
缓存 网络协议 Linux
Linux ip命令常用操作
Linux的 `ip`命令是一个强大且灵活的网络管理工具,能够执行从基本的网络接口配置到高级的路由和VLAN管理等多种操作。通过熟练掌握这些常用操作,用户可以更加高效地管理和配置Linux系统的网络环境。无论是在日常管理还是故障排除中,`ip`命令都是必不可少的工具。
22 2
|
2月前
|
并行计算 Ubuntu Linux
Ubuntu学习笔记(三):Linux下操作指令大全
Ubuntu学习笔记,介绍了Linux操作系统中常用的命令和操作,如文件管理、系统信息查看、软件安装等。
47 3
|
3月前
|
Shell Linux
Linux shell编程学习笔记82:w命令——一览无余
Linux shell编程学习笔记82:w命令——一览无余
|
5月前
|
网络协议 Linux 网络安全
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
在CentOS 7中,新引入了firewalld服务(防火墙),取代了CentOS 6之前的iptables服务(防火墙)。
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
|
5月前
|
Linux
入职必会-开发环境搭建37-Linux常用操作-Linux服务管理
系统启动以后一直存在且常驻内存没有界面的进程就是服务。Linux系统中的所有服务都保存在下列目录中:/usr/lib/systemd/system,进入该目录就能看到所有的服务。
入职必会-开发环境搭建37-Linux常用操作-Linux服务管理