开发者学堂课程【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:
Last
login:Sun Dec 18 23:04:36 2016 from 192. 168.99.1
[root@localhost ~]# clear
二、START
启动服务代码如下:
[
root@localhost ~]# whoami
r
oot
[
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
d
ec 18 23:09:15 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:15.88 spid6s Starting up database ' tempdb'.
d
ec 18 23:09:16 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:16.12 spid6s
The tempdb database has 1 data file(s).
d
ec 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.
d
ec 18 23:09:16 localhost. localdomain sqlservr[4856]: 2016-12-18 15:09:16.14 spid20s
he Database Mirroring endpoint is in...tate.
d
ec 18 23:09:16 loca lhost. localdomain sqlservr[4856]: 2016- -12-18 15:09:16.19 spid20s
Service Broker manager has started.
d
ec 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.
d
ec 18 23:14:29 localhost. localdomain sqlservr[4856]: 2016-12-18 15:14:29.87 spid51
Attempting to load library 'xplog70.d... ired.
d
ec 18 23:14:29 loca lhost. localdomain sqlservr [4856]: 2016-12-18 15:14:29.90 spid51
Using 'xplog70.dll' version '201
d
ec 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 命令也可以启动服务,但是会有一个提示信息 R
edirecting 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)
d
ec 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...
d
ec 18 23:18:42 localhost. localdomain sqlservr[4856: 2016-12-18 15:18:42.82 spid5s
SQL Server is terminating in response...ired.
d
ec 18 23:18:43 localhost. localdomain sqlservr[4856]: 2016-12-18 15:18:43.14 spid20s
Service Broker manager has shut down.
d
ec 18 23:18:43 localhost. loca ldomain sqlservr [4856]: 2016-12-18 15:18:43.22 spid5s
SQL Server shutdown has been initiated
d
ec 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.
d
ec 18 23:18:43 localhost. localdomain systemd[1]: mssql-server.service: main process exited, code=exited, status=1/FAILURE
d
ec 18 23:18:43 localhost. localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Database Engine.
d
ec 18 23:18:43 localhost. localdomain systemd[1]: Unit mssql-server.service entered failed state.
d
ec 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.