Mac修改主机名和计算机名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac修改主机名和计算机名相关的知识,希望对你有一定的参考价值。
参考技术A 通常意义上的主机名就是指在同一局域网内用来标识不同主机的名称。对于 Windows 用户来说,就是在“网络”内可以让同一局域网内其他用户看到的自己的计算机名称。所以自己的计算机名称,也就是主机名,用户可以在“计算机”的属性设置内自定义。但对于 Mac OS 来说,主机名和计算机名是不同的概念,因为 Mac OS 可以通过“计算机名”来自定义主机在局域网内显示的名称,也就是我们前面所说的通常意义上的主机名。而 Mac OS 下的“主机名”才是主机真正的名称。
如果你了解 Unix 或者 Linux,应该很清楚,终端下的命令提示符是可以自定义的,通常命令提示符包含主机名,也就是当前终端连接的主机的名称。
对于 Mac OS 下的终端来说,此时显示的“主机名”就是 HostName,也就是主机真正的名称,我们可以通过命令查看当前的“主机名”:
如果要修改主机名,可以使用下面的命令:
执行命令后,再输入 exit 结束当前终端进程。重新打开终端,就会发现主机名已经修改为新的主机名了。
那么怎么自定义当前主机在局域网内显示的主机名呢?
我们通过自定义 Mac OS 下的“计算机名”,即 ComputerName 值来实现。有两种方法:
1.在“设置”——“共享”下,修改电脑名称。
2.在终端下,通过命令实现。
具体实现过程为:
方法1 - 在“设置”——“共享”下,修改电脑名称:
方法2 - 在终端下输入命令:
修改后,再在“设置”——“共享”下勾选“远程登录”,同一局域网内的其他终端就能通过 ssh 命令登录该主机了。这不在本文的讨论范围,所以不具体说明了。
单实例asm,修改主机名和ip地址后的重配置
修改主机名和ip地址之后的reconfigure asm
参考资料:How to Reconfigure Oracle Restart (文档 ID 986740.1)
[[email protected] bin]# ./crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘lxtrac04‘
CRS-2673: Attempting to stop ‘ora.cdb.db‘ on ‘lxtrac04‘
CRS-2673: Attempting to stop ‘ora.LISTENER.lsnr‘ on ‘lxtrac04‘
CRS-2677: Stop of ‘ora.LISTENER.lsnr‘ on ‘lxtrac04‘ succeeded
CRS-2677: Stop of ‘ora.cdb.db‘ on ‘lxtrac04‘ succeeded
CRS-2673: Attempting to stop ‘ora.TEST.dg‘ on ‘lxtrac04‘
CRS-2677: Stop of ‘ora.TEST.dg‘ on ‘lxtrac04‘ succeeded
CRS-2673: Attempting to stop ‘ora.asm‘ on ‘lxtrac04‘
CRS-2677: Stop of ‘ora.asm‘ on ‘lxtrac04‘ succeeded
CRS-2673: Attempting to stop ‘ora.evmd‘ on ‘lxtrac04‘
CRS-2677: Stop of ‘ora.evmd‘ on ‘lxtrac04‘ succeeded
CRS-2673: Attempting to stop ‘ora.cssd‘ on ‘lxtrac04‘
CRS-2677: Stop of ‘ora.cssd‘ on ‘lxtrac04‘ succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘lxtrac04‘ has completed
CRS-4133: Oracle High Availability Services has been stopped.
[[email protected] bin]#
1.修改主机名:
[[email protected] bin]# hostnamectl --static set-hostname erwadba.co.com
2.修改ip地址 将ip地址有172.32.231.235修改到10.10.10.10
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
BOOTPROTO=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=ens32
UUID=5d220321-604c-4d09-b30f-78fc7d088fca
DEVICE=ens32
ONBOOT=yes
#IPADDR=172.32.231.235
IPADDR=10.10.10.10
NETMASK=255.255.255.0
GATEWAY=172.32.231.193
[[email protected] ~]#
3.执行deconfig
# $GRID_HOME/crs/install/roothas.pl -deconfig -force
在执行roothas.pl的时候报如下错误,说明环境参数不对
[[email protected] ~]# /u01/app/12.2.0.1/grid/crs/install/roothas.pl -deconfig -force
Can‘t locate Env.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /u01/app/12.2.0.1/grid/crs/install /u01/app/12.2.0.1/grid/crs/install/../../perl/lib) at /u01/app/12.2.0.1/grid/crs/install/crsinstall.pm line 286.
BEGIN failed--compilation aborted at /u01/app/12.2.0.1/grid/crs/install/crsinstall.pm line 286.
Compilation failed in require at /u01/app/12.2.0.1/grid/crs/install/roothas.pl line 97.
BEGIN failed--compilation aborted at /u01/app/12.2.0.1/grid/crs/install/roothas.pl line 97.
[[email protected] ~]#
++++++++++++++++++++++++++++++++++++++++++++++++++++++
查询mos。需要使用GI自己的perl
rootcrs.pl/roothas.pl Fails With Can‘t locate Env.pm (文档 ID 2019784.1)
The fix is included in 12.1.0.2, the workaround is to use the perl in GI home.
Example :
/u01/app/oracle/product/11.2.0.4/grid/perl/bin/perl /u01/app/oracle/product/11.2.0.4/grid/crs/install/roothas.pl -deconfig -force
++++++++++++++++++++++++++++++++++++++++++++++++++++++
[[email protected] ~]# /u01/app/12.2.0.1/grid/perl/bin/perl /u01/app/12.2.0.1/grid/crs/install/roothas.pl -deconfig -force
Using configuration parameter file: /u01/app/12.2.0.1/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/erwadba/crsconfig/hadeconfig.log
PRCR-1070 : Failed to check if resource ora.ons is registered
CRS-0184 : Cannot communicate with the CRS daemon.
2018/04/27 17:05:38 CLSRSC-180: An error occurred while executing the command ‘/u01/app/12.2.0.1/grid/bin/srvctl config ons‘
2018/04/27 17:05:52 CLSRSC-337: Successfully deconfigured Oracle Restart stack
[[email protected] ~]#
4.重新配置crs
# $GRID_HOME/crs/install/roothas.pl
[[email protected] ~]# /u01/app/12.2.0.1/grid/perl/bin/perl /u01/app/12.2.0.1/grid/crs/install/roothas.pl
Using configuration parameter file: /u01/app/12.2.0.1/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/erwadba/crsconfig/roothas_2018-04-28_08-10-05AM.log
Oracle Clusterware infrastructure error in OCRCONFIG (OS PID 24897): CLSD/ADR initialization failed with return value -1
1: clskec:has:CLSU:910 4 args[clsdAdrInit_CLSK_err][mod=clsdadr.c][loc=(:CLSD00281:)][msg=clsdAdrInit: Additional diagnostic data returned by the ADR component for dbgc_init_all failure:
DIA-49802: missing read, write, or execute permission on specified ADR home directory [/u01/app/grid/diag/crs/erwadba/crs/log]
DIA-49801: actual permissions [rwxrwx---], expected minimum permissions [rwxrwxrwx] for effective user [grid]
DIA-48188: user missing read, write, or exec permission on specified directory
Linux-x86_64 Error: 13: Permission denied <<<<<<<<<<权限不对
Additional information: 2
Additional information: 511
Additional information: 16888
([all diagnostic data retrieved from ADR])]
2: clskec:has:CLSU:910 4 args[clsdAdrInit_CLSK_err][mod=clsdadr.c][loc=(:CLSD00050:)][msg=clsdAdrInit: call to dbgc_init_all failed. facility:[CRS] product:[CRS] line number:[1422] return code: [ORA-49802] Oracle Base: [/u01/app/grid] Product Type: [CRS] Host Name: [erwadba] Instance ID: [crs] User Name: [grid]]
Oracle Clusterware infrastructure error in CLSCFG (OS PID 24907): CLSD/ADR initialization failed with return value -1
1: clskec:has:CLSU:910 4 args[clsdAdrInit_CLSK_err][mod=clsdadr.c][loc=(:CLSD00281:)][msg=clsdAdrInit: Additional diagnostic data returned by the ADR component for dbgc_init_all failure:
DIA-49802: missing read, write, or execute permission on specified ADR home directory [/u01/app/grid/diag/crs/erwadba/crs/log]
DIA-49801: actual permissions [rwxrwx---], expected minimum permissions [rwxrwxrwx] for effective user [grid]
DIA-48188: user missing read, write, or exec permission on specified directory
Linux-x86_64 Error: 13: Permission denied <<<<<<<<<<权限不对
Additional information: 2
Additional information: 511
Additional information: 16888
([all diagnostic data retrieved from ADR])]
2: clskec:has:CLSU:910 4 args[clsdAdrInit_CLSK_err][mod=clsdadr.c][loc=(:CLSD00050:)][msg=clsdAdrInit: call to dbgc_init_all failed. facility:[CRS] product:[CRS] line number:[1422] return code: [ORA-49802] Oracle Base: [/u01/app/grid] Product Type: [CRS] Host Name: [erwadba] Instance ID: [crs] User Name: [grid]]
LOCAL ADD MODE
Creating OCR keys for user ‘grid‘, privgrp ‘oinstall‘..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user ‘root‘, privgrp ‘root‘..
Operation successful.
CRS-4664: Node erwadba successfully pinned.
2018/04/28 08:10:16 CLSRSC-330: Adding Clusterware entries to file ‘oracle-ohasd.service‘
2018/04/28 08:12:21 CLSRSC-214: Failed to start the resource ‘ohasd‘
Failed to start the Clusterware. Last 20 lines of the alert log follow:
2018-04-28 08:10:59.407
[client(26857)]CRS-8500:Oracle Clusterware OHASD process is starting with operating system process ID 26857
2018-04-28 08:10:59.418
[client(26857)]CRS-2112:The OLR service started on node erwadba.
2018-04-28 08:11:01.003
[client(26949)]CRS-8500:Oracle Clusterware OHASD process is starting with operating system process ID 26949
2018-04-28 08:11:01.014
[client(26949)]CRS-2112:The OLR service started on node erwadba.
2018-04-28 08:11:02.613
[client(27040)]CRS-8500:Oracle Clusterware OHASD process is starting with operating system process ID 27040
2018-04-28 08:11:02.623
[client(27040)]CRS-2112:The OLR service started on node erwadba.
2018-04-28 08:11:04.208
[client(27132)]CRS-8500:Oracle Clusterware OHASD process is starting with operating system process ID 27132
2018-04-28 08:11:04.219
[client(27132)]CRS-2112:The OLR service started on node erwadba.
2018-04-28 08:11:05.849
[client(27229)]CRS-8500:Oracle Clusterware OHASD process is starting with operating system process ID 27229
2018-04-28 08:11:05.861
[client(27229)]CRS-2112:The OLR service started on node erwadba.
2018/04/28 08:12:22 CLSRSC-318: Failed to start Oracle OHASD service
Died at /u01/app/12.2.0.1/grid/crs/install/crsinstall.pm line 2775.
[[email protected] ~]#
从上面输出的结果,发现文件目录的权限不对。修改为正确的属主。再次执行roothas.pl。配置成功
[[email protected] crs]# ll
total 12
drwxrwx--- 2 root root 20 Apr 27 16:30 alert
drwxrwx--- 2 root root 6 Apr 27 14:59 cdump
drwxrwx--- 2 root root 6 Apr 27 14:59 incident
drwxrwx--- 2 root root 6 Apr 27 14:59 incpkg
drwxrwx--- 2 root root 4096 Apr 27 14:59 lck
drwxrwx--- 4 root root 29 Apr 27 14:59 log
drwxrwx--- 2 root root 4096 Apr 27 14:59 metadata
drwxrwx--- 2 root root 6 Apr 27 14:59 metadata_dgif
drwxrwx--- 2 root root 6 Apr 27 14:59 metadata_pv
drwxrwx--- 2 root root 6 Apr 27 14:59 stage
drwxrwx--- 2 root root 6 Apr 27 14:59 sweep
drwxrwx--- 2 root root 4096 Apr 28 08:10 trace
[[email protected] crs]# shown grid:oinstall * -R
[[email protected] ~]# /u01/app/12.2.0.1/grid/perl/bin/perl /u01/app/12.2.0.1/grid/crs/install/roothas.pl
Using configuration parameter file: /u01/app/12.2.0.1/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/erwadba/crsconfig/roothas_2018-04-28_08-17-32AM.log
LOCAL ADD MODE
Creating OCR keys for user ‘grid‘, privgrp ‘oinstall‘..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user ‘root‘, privgrp ‘root‘..
Operation successful.
CRS-4664: Node erwadba successfully pinned.
2018/04/28 08:17:43 CLSRSC-330: Adding Clusterware entries to file ‘oracle-ohasd.service‘
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘erwadba‘
CRS-2673: Attempting to stop ‘ora.evmd‘ on ‘erwadba‘
CRS-2677: Stop of ‘ora.evmd‘ on ‘erwadba‘ succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘erwadba‘ has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
erwadba 2018/04/28 08:18:54 /u01/app/12.2.0.1/grid/cdata/erwadba/backup_20180428_081854.olr 0
2018/04/28 08:18:55 CLSRSC-327: Successfully configured Oracle Restart for a standalone server
[[email protected] ~]#
5.添加asm资源
$ srvctl add asm
[[email protected] ~]$ srvctl add asm
6.启动asm资源
$ srvctl start asm
[[email protected] ~]$ srvctl start asm
[[email protected] ~]$
7.创建asm的spfile
[[email protected] ~]$ sqlplus / as sysasm
SQL*Plus: Release 12.2.0.1.0 Production on Sat Apr 28 08:24:37 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
TEST DISMOUNTED
SQL> alter diskgroup test mount;
Diskgroup altered.
SQL> ho cat asm.txt
+ASM.__oracle_base=‘/u01/app/grid‘#ORACLE_BASE set from in memory value
*.asm_diskstring=‘/dev/sd*‘
*.asm_power_limit=1
*.large_pool_size=12M
*.remote_login_passwordfile=‘EXCLUSIVE‘
SQL> create spfile=‘+TEST‘ from pfile=‘/home/grid/asm.txt‘;
File created.
SQL>
8.重启has stack
[[email protected] ~]# /u01/app/12.2.0.1/grid/bin/crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘erwadba‘
CRS-2673: Attempting to stop ‘ora.evmd‘ on ‘erwadba‘
CRS-2673: Attempting to stop ‘ora.TEST.dg‘ on ‘erwadba‘
CRS-2677: Stop of ‘ora.TEST.dg‘ on ‘erwadba‘ succeeded
CRS-2673: Attempting to stop ‘ora.asm‘ on ‘erwadba‘
CRS-2677: Stop of ‘ora.evmd‘ on ‘erwadba‘ succeeded
CRS-2677: Stop of ‘ora.asm‘ on ‘erwadba‘ succeeded
CRS-2673: Attempting to stop ‘ora.cssd‘ on ‘erwadba‘
CRS-2677: Stop of ‘ora.cssd‘ on ‘erwadba‘ succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘erwadba‘ has completed
CRS-4133: Oracle High Availability Services has been stopped.
[[email protected] ~]# /u01/app/12.2.0.1/grid/bin/crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[[email protected] ~]#
9.添加数据库资源,并启动
[[email protected] ~]$ srvctl add database -db CDB -oraclehome $ORACLE_HOME -spfile +TEST/CDB/PARAMETERFILE/spfile.274.974547727
[[email protected] ~]$ srvctl start database -db cdb
10.添加listener,并启动
[[email protected] admin]$ srvctl add listener
[[email protected] admin]$ srvctl start listener
[[email protected] admin]$
以上是关于Mac修改主机名和计算机名的主要内容,如果未能解决你的问题,请参考以下文章
Mac 修改主机名计算机名本地主机名xcode作者名终端前缀
Linux CentOS7.0 (02)修改主机名和ip地址