通过SSH工具或是XShell工具进入远程Linux下。
其中,通过SSH工具登录的界面如下:
其中Host Name是远程服务器的ip地址。User Name是服务器的一个用户名,端口号默认22,Connect进去后可以填写服务器的密码。
通过XShell工具登录的界面如下:
点击上面的New按钮,填写HOST主机地址,即服务器的IP地址,点击OK即可。
输入命令: cd / 到根目录下
启动tomcat
usr/local/tomcat/bin/startup.sh(这是tomcat所在的路径)
关闭tomcat
usr/local/tomcat/bin/shutdown.sh(这个是tomcat所在的路径)
Linux下创建Oracle用户和表空间,赋予权限等操作
通过sqlplus远程连接Oracle,其表示:sqlplus 用户名/密码@远程Oracle服务器地址:Oracle端口号/Oracle的service_name
sqlplus sys/nmc601@10.28.17.129:1521/nmcdb. as sysdba;
如果存在TS_MISPS表空间,则删除此表空间和其附带的文件
drop tablespace TS_MISPS including contentsand datafiles cascade constraints;
查看连接着的用
select username,sid,serial# from v$session;
例如
##删除当前连接的用户MISPS.
alter system kill session '119,45';
alter system kill session '139,243';
//级联删除用户
drop user MISPS cascade;
//创建表空间,文件放在Oracle安装目录内部的oradata目录下
create tablespace TS_MISPS datafile '/home/oracle/app/oracle/oradata/TS_MISPS.dbf'size 500m;
//让表空间自动变化
alter database datafile '/home/oracle/app/oracle/oradata/TS_MISPS.dbf'autoextend on next 500m;
create user MISPS identified by ‘MISPS;
//让用户使用这个表空间
alter user MISPS default tablespaceTS_MISPS;
//分配session的权限
grant create session to MISPS;
//分配创建表的权限
grant create table to MISPS;
//分配创建视图的权限
grant create view to MISPS;
//分配创建触发器的权限
grant create trigger to MISPS;
//这行必须有
grant unlimited tablespace to MISPS;
//分配创建索引的权限
grant create any index to MISPS;
//分配创建序列的权限
grant create any sequence to MISPS;
//分配修改表的权限
grant alter any table to misps;
//分配修改存储过程的权限
grant alter any procedure to MISPS;
//分配删除表的权限
grant drop any table to MISPS;
//赋予删除视图的权限
grant drop any view to MISPS;
//赋予删除索引的权限
grant drop any INDEX to MISPS;
//赋予删除存储过程的权限
grant drop any procedure to MISPS;
//赋予查询,插入,更新,删除表的权限
grant select any table,insert anytable,update any table,delete any table to MISPS;
//让表unlock,没有这句会出现ORA-28000: the account is locked错误
alter user MISPS account unlock;
//必须赋予connect,resource权限
grant connect,resource,DBA to MISPS;
//这一句是修改密码的sql
alter user MISPS identified by MISPS;
ORA-01940无法删除当前用户的解决方案
1)查看用户的连接状况
select username,sid,serial# from v$session
(2)找到要删除用户的sid,和serial,并删除
-------------------------------------------
如:你要删除用户'MISPS',可以这样做:(532,4562)这个代表sid,serial
alter system kill session'532,4562';
(3)删除用户
drop user MISPS cascade;
(**)如果在drop后还提示ORA-01940:无法删除当前已链接的用户,说明还有连接的session,可以通过查看session的状态来确定该session是否被kill了,用如下语句查看:
selectsaddr,sid,serial#,paddr,username,status from v$session where username is notnull;
结果如下(以我的库为例):
saddr sid serial# paddr username status
564A1E28 513 22974 569638F4 NETBNEW ACTIVE
564A30DC 514 18183 569688CC NETBNEWINACTIVE
564A5644 516 21573 56963340 NETBNEWINACTIVE
564B6ED0 531 9 56962D8C NETBNEW INACTIVE
564B8184 532 4562 WUZHQ KILLED
status 为要删除用户的session状态,如果还为inactive,说明没有被kill掉,如果状态为killed,说明已kill。
由此可见,MISPS这个用户的session已经被杀死。此时可以安全删除用户。
Windows下创建用户和表空间
sqlplussys/nmc601@10.28.17.129:1521/nmcdb. as sysdba;
drop tablespace TS_MISPS including contentsand datafiles cascade constraints;
select username,sid,serial# from v$session;
drop user MISPS cascade;
create tablespace TS_MISPS datafile 'D:\TS_MISPS.dbf'size 500m;
alter database datafile ' D:\TS_MISPS.dbf'autoextend on next 500m;
create user MISPS identified by MISPS;
alter user MISPS default tablespaceTS_MISPS;
grant create session to MISPS;
grant create table to MISPS;
grant create view to MISPS;
grant create trigger to MISPS;
grant unlimited tablespace to MISPS;
grant create session to MISPS;
grant create any index to MISPS;
grant create any sequence to MISPS;
grant alter any table to misps;
grant alter any procedure to MISPS;
grant drop any table to MISPS;
grant drop any view to MISPS;
grant drop any INDEX to MISPS;
grant drop any procedure to MISPS;
grant select any table,insert anytable,update any table,delete any table to MISPS;
alter user MISPS account unlock;
grantconnect,resource,DBA to MISPS;
alter user MISPSidentified by MISPS;
commit;
先以sysdba的方式登录一次,再按照创建的用户登录一次。
alter user MISPSidentified by MISPS;
通过这种方式创建的用户仍然不可以用,出现的错误是:
如果出现了无法删除当前连接的用户,可以关闭PL/SQL,可能是PL/SQL正在连接着这个用户和。
另外附上:如何查看Linux服务的代码:
1. 查看Linux启动的服务
chkconfig --list 查询出所有当前运行的服务
chkconfig --list atd 查询atd服务的当前状态
2.停止所有服务并且在下次系统启动时不再启动,如下所示:
chkconfig --levels 12345 NetworkManager off
如果想查看当前处于运行状态的服务,用如下语句过滤即可
chkconfig --list |grep on
3.如果只是想当前的设置状态有效,在系统重启动后即不生效的话,可以用如下命令停止服务
service sshd stop