当前位置:Gxlcms > mysql > 用srvctl命令配置service

用srvctl命令配置service

时间:2021-07-01 10:21:17 帮助过:371人阅读

.用srvctl命令配置service 除了用DBCA图形方式,还可以使用命令方式配置service,这种方法对于维护远程尤其有用。无论是创建还是维护都是用一个命令srvctl,先看一下srvctl命令和service相关的语法,如下: 创建service [oracle@felix1 ~]$ srvctl add servi

.用srvctl命令配置service

除了用DBCA图形方式,还可以使用命令方式配置service,这种方法对于维护远程尤其有用。无论是创建还是维护都是用一个命令srvctl,先看一下srvctl命令和service相关的语法,如下:

创建service

[oracle@felix1 ~]$ srvctl add service -h

Usage: srvctl add service -d -s -r "" [-a""] [-P ]

-d Unique name forthe database

-s Service name

-r"" List ofpreferred instances

-a"" List ofavailable instances

-P TAF policy (NONE,BASIC, or PRECONNECT)

Usage: srvctl add service -d -s -u {-r "" | -a""}

-d Unique name forthe database

-s Service name

-u Add a new instance to serviceconfiguration

-r Name of newpreferred instance

-a Name of new available instance

-h Print usage

[oracle@felix1 ~]$

示例如下:

Felix1,felix2为实例名;Felix是数据库名;策略是:BASIC

[oracle@felix1~]$ srvctl add service -d felix -s taf_srvctl -r felix2 -a felix1 -P BASIC

[oracle@felix1~]$

查看service配置

[oracle@felix1 ~]$ srvctl config service -d felix-a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

taf_srvctl PREF: felix2 AVAIL: felix1 TAF: BASIC

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl config service -d felix-h

Usage: srvctl config service -d [-s] [-a] [-S ]

-d Unique name forthe database

-s Service name

-a Additional attributes

-S Additionalinformation for EM Console

-h Print usage

[oracle@felix1 ~]$

如果不指定“-s service_name”,就会显示所有的service配置,这些配置只包括preferred和avilable instance。使用-a选项,还会显示TAF的信息。

是否自动运行

数据库启动时,会自动启动所有的service。有时为了维护的需要,需要禁用这个特性。在维护完成之后再启动这个特性。

[oracle@felix1 ~]$ srvctl disable service -h

Usage: srvctl disable service -d -s"" [-i ]

-d Unique name forthe database

-s"" Commaseparated service names

-i Instance name

-h Print usage

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl disable service -d felix-s taf_server -i felix1

[oracle@felix1 ~]$ srvctl config service -d felix-a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

Service taf_server is disabled on instance(s) felix1.

taf_srvctl PREF: felix2 AVAIL: felix1 TAF: BASIC

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl disable service -d felix-s taf_server

PRKP-1024 : The service taf_server is stillrunning.

关闭服务service并diable:

[oracle@felix1 ~]$ srvctl stop service -h

Usage: srvctl stop service -d [-s"" [-i ]] [-f]

-d Unique name forthe database

-s"" Commaseparated service names

-i Instance name

-f Disconnect all sessionsduring stop or relocate service operations

-h Print usage

[oracle@felix1 ~]$ srvctl stop service -d felix -staf_server

[oracle@felix1 ~]$ srvctl config service -d felix-a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

taf_srvctl PREF: felix2 AVAIL: felix1 TAF: BASIC

[oracle@felix1 ~]$ srvctl disable service -d felix-s taf_server

[oracle@felix1 ~]$ srvctl config service -d felix-a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

Service taf_server is disabled.

taf_srvctl PREF: felix2 AVAIL: felix1 TAF: BASIC

[oracle@felix1 ~]$

启动service

[oracle@felix1 ~]$ srvctl start service -h

Usage: srvctl start service -d [-s"" [-i ]] [-o]

-d Unique name forthe database

-s"" Commaseparated service names

-i Instance name

-o Options to startupcommand (e.g. open, mount, or nomount)

-h Print usage

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl start service -d felix -s taf_server

[oracle@felix1 ~]$

查看service状态。

[oracle@felix1 ~]$ srvctl status service -h

Usage: srvctl status service -d [-s""] [-f] [-v] [-S ]

-d Unique name forthe database

-s"" Commaseparated service names

-f Include disabled applications

-v Verbose output

-S Additionalinformation for EM Console

-h Print usage

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl status service -d felix -s taf_server -f -v

Service taf_server is running on instance(s)felix2

[oracle@felix1 ~]$ srvctl status service -d felix -s taf_server -f -v -S 3

#@=info: operation={status} config={full}ver={10.2.0.0.0}

#@=service[0]: name={taf_server} enabled={true}pref={felix1} avail={felix2} disabled_insts={felix1} tafpolicy={basic}type={user}

#@=service[1]: name={felix} enabled={true}pref={felix1, felix2} avail={} disabled_insts={} tafpolicy={NONE}type={internal}

Service taf_server is running on instance(s)felix2

#@=result[0]: up={felix2} down={felix1}disabled={felix1} unknown={}

#@=result[1]: up={felix1, felix2} down={}disabled={} unknown={}

#@=done: status={0}

[oracle@felix1 ~]$

删除service。

[oracle@felix1 ~]$ srvctl remove service -h

Usage: srvctl remove service -d -s [-i ] [-f]

-d Unique name forthe database

-s Service name

-i Instance name

-f Force remove

-h Print usage

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl status service -d felix

Service taf_server is running oninstance(s) felix1

Service taf_srvctl is not running.

[oracle@felix1 ~]$ srvctl remove service -d felix-s taf_server -i felix1

taf_server PREF: felix1 AVAIL: felix2

Remove service taf_server from the instancefelix1? (y/[n]) y

PRKP-1024 : The service taf_server is still running.

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl remove service -d felix-s taf_srvctl -i felix1

taf_srvctl PREF: felix2 AVAIL: felix1

Remove service taf_srvctl from the instancefelix1? (y/[n]) y

PRKP-1067 : Instance felix1 is the last availableinstance for service taf_srvctl. Try modify service instead.

[oracle@felix1 ~]$ srvctl config service -d felix -a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

taf_srvctl PREF: felix2 AVAIL: felix1 TAF: BASIC

[oracle@felix1 ~]$

[oracle@felix1 ~]$ srvctl remove service -d felix -staf_srvctl -f

[oracle@felix1 ~]$ srvctl config service -d felix -a

taf_server PREF: felix1 AVAIL: felix2 TAF: basic

[oracle@felix1 ~]$ srvctl remove service -d felix-s taf_server -f

PRKP-1024: The service taf_server is still running.

[oracle@felix1 ~]$ srvctl stop service -d felix -staf_server

[oracle@felix1 ~]$ srvctl remove service -d felix-s taf_server -f

[oracle@felix1 ~]$ srvctl config service -d felix -a

[oracle@felix1 ~]$

修改服务

[oracle@felix1 ~]$ srvctl modify service -h

Usage: srvctl modify service -d -s -i -t [-f]

-d Unique name forthe database

-s Service name

-i Old instance name

-t New instance name

-f Disconnect all sessionsduring stop or relocate service operations

Usage: srvctl modify service -d -s -i -r [-f]

-d Unique name forthe database

-s Service name

-i Instance name

-r Upgrade instance to preferred

-f Disconnect all sessionsduring stop or relocate service operations

Usage: srvctl modify service -d -s -n -i [-a ][-f]

-d Unique name forthe database

-s Service name

-n Modify service configuration

-r "" List of preferred instances

-a"" List ofavailable instances

-f Disconnect all sessionsduring stop or relocate service operations

Usage: srvctl modify service -d -s -P [-f]

-d Unique name forthe database

-s Service name

-P TAF policy (NONE,BASIC, or PRECONNECT)

-f Disconnect all sessionsduring stop or relocate service operations

-h Print usage

[oracle@felix1 ~]$

[oracle@felix2 ~]$ srvctl modify service -d felix-s taf_srvctl -n -i felix1,felix2 -f

[oracle@felix2 ~]$ srvctl config service -d felix -a

taf_srvctlPREF: felix1 felix2 AVAIL: TAF: basic

[oracle@felix2 ~]$

【参考大话RAC--张晓明】

人气教程排行