常用命令-

Linux服务器命令

scp -P 1122 expdp_aram_prod230903_* [email protected].7:/oracle/app/oracle/move_data   

//跨服务器传输

chown -R oracle:oinstall /app/move_data   

//更改所属组

date -s '2022-11-11 18:58:30'   

//修改服务器时间

top   

//CPU使用率

df -h   

//磁盘使用情况

df -ih

lscpu

lsmem

ntpdate -u 190.2.86.115   

//时间同步时钟服务器

du -sh *

du -sh * | sort -rn  ##按MB大小排序

du -s * | sort -rn  ##按字节大小排序(比较准确)

du -sh * | sort -rn |head  ##按大小排序并选出排在前面的10个

du -sh * | sort -rn |tail  ##按大小排序并选出排在末尾的10个

telnet IP 端口

for i in /*; do echo $i; find $i |wc -l; done  ##查/目录文件数

ls | xargs -n 500 rm -rf  ##500一组循环删除文件

find /washome/apbm/log -name "*" -mtime +? -exec rm -rf {} \;  ##删除?天前的文件

ls -t | grep -w *.log | sed -n '6,$p' | xargs -I {} rm -rf {}  ##删除所有“*.log”文件,只保留最新的五个

nslookup 域名  ##解析域名ip

cat /etc/ntp.conf  ##时钟服务器

ls -altr

free -h

echo 1 >/proc/sys/vm/drop_caches  ##清缓存

cat /etc/passwd  ##查看所有用户

uname -a  ##查看当前操作系统内核信息

cat /proc/version  ##查看当前操作系统版本信息

lsb_release -a  ##查看版本号

lsof -i:3658  ##查看端口是否开放

lsof -i -Pn | grep -i listen  ##查开了哪些监听

netstat -aptn|grep -i 1122  ##查看监听是否在

netstat -ano|grep -i 1523

systemctl status SuSEfirewall2.service  ##检查防火墙的状态

tar -zcvf test.tar file1 dir2  ##压缩文件file1和目录dir2到test.tar  -z用gzip压缩 -c打包 -v过程 -f指定文件名

tar -zxvf test.tar  ##解压test.tar  -x解压 -C解压到指定目录

tar -ztcf test.tar  ##列出压缩文件的内容

zip test.zip test/

unzip test.zip test [-d <目录>]   ##-d <目录>指定文件解压缩后要存储的目录

ps -ef|grep tns  ##查数据库监听

useradd -d /home/read -m -g read read  ##新增用户,-d指定主目录,如此目录不存在可使用-m选项,-g指定所属组

userdel -r cbatch  ##-r删除用户主目录

passwd read

ssh -p 1122 [email protected]  ##ssh

netstat -tunpl |grep 1122  ##查看1122监听状态

service sshd status  ##查看ssh状态

history | grep

curl http://190.2.36.118:7001/HttpGateway/HttpGateway

groups  ##查当前用户属组

id  ##查当前用户用户id、所属组id、附加组id

groupadd read  ##添加用户组

groupdel cbatch

whereis gsql

which gsql  ##查找某命令位置

env  ##查看环境变量

vim ~/.bashrc

source ~/.bashrc

find / -name cmbill_follow_dtl.js*

ulimit -a

$BATCH_GJ_HOME/shell/gcm_b_gj_cryptography.sh 数据库密码 0  ##数据库密码加密(批量服务器操作)

chmod 4571 extjob  ##4000:u+s 2000:g+s 1000:o+t s权限:设置uid(仅对文件有效)后,使文件在执行阶段具有文件所有者的权限,设置gid(仅对目录有效)后,任何用户在此目录下创建的文件都具有和该目录所属的组相同的组 t权限:设置sticky(仅对文件有效)后,用户对目录拥有写权限也不能删除

Oracle数据库命令

linux:

impdp \'/as sysdba\' directory=move_data dumpfile=expdp_acbm_prod230903_%u.dmp include=grant sqlfile=grant.sql

crsctl stat res -t or /oracle/app/19c/grid/bin/crsctl status resource -t  ##查看RAC集群状态

srvctl status listener

lsnrctl status

which crsctl

/oracle/app/19c/grid/bin/crsctl stop crs -f  ##强制执行,谨慎使用

/oracle/app/19c/grid/bin/crsctl check crs  ##检查集群服务状态

srvctl status database -d acbmdb

srvctl start instance -d acbmdb -i acbmdb1

srvctl status asm -n ptacbmdb1

ps -ef|grep -i asm  ##-i忽略字母大小写

ps -ef|grep -i ora  ##查看oracle相关服务

Oracle:

show parameter name;

select name from v$database;  --查询Oracle数据库名

select instance_name,status from gv$instance;

sqlplus nongfahang/[email protected]:1521/ircsdb  --连接Oracle数据库

drop user SQM cascade;   --删除数据库用户

select t.directory_path From dba_directories t Where t.directory_name = 'MOVE_DATA'; --查看MOVE_DATA所指目录

select username from dba_users where inherited ='NO';  --查用户(查系统用户用YES,否则用NO)

alter user query identified by "Acms*0826";  --修改用户密码

select total.tablespace_name,round(total.GB,2) as Total_GB,round(total.GB - free.GB,2) as Used_GB,round((1-free.GB / total.GB)* 100,2) || '%' as Used_Pct

from (select tablespace_name,sum(bytes)/1024/1024/1024 as GB

from dba_free_space group by tablespace_name) free,

(select tablespace_name,sum(bytes)/1024/1024/1024 as GB

from dba_data_files group by tablespace_name) total

where free.tablespace_name = total.tablespace_name

order by used_pct desc; --查看表空间使用率

select status from v$instance;  --查实例状态

@?/rdbms/admin/awrrpt.sql  --生成awr报告

@$ORACLE_HOME/rdbms/admin/utlrp.sql  --重编译数据库

select username,account_status,expiry_date,profile from dba_users;  --查询用户状态(密码过期时间)

select * from dba_sys_privs;

create table 表名_temp_日期 as  select * from 表名 where 条件; --备份表

select value from v$parameter where name = 'cluster_database';

select * from gmag.sys_dict_data where bean_code = 'CRS_SYSTEMINFO#CREDIT_CODE';

select username,default_tablespace from dba_users;

select file_name,tablespace_name,round(bytes/(1024*1024*1024)) from dba_data_files;

select username,account_status,default_tablespace,temporary_tablespace,created from dba_users where account_status = 'open';

GRANT SELECT ON all TABLES in schema "gmag" to GBATCH; --按用户赋予查询权限

--重建undo表空间

create undo tablespace undotbs5 datafile '+DATADG' size 30G autoextend on maxsize 30g;

alter system set undo_tablespace='UNDOTBS5' sid='acbmdb';

drop tablespace undotbs4 including contents and datafiles;

--例:

create undo tablespace undotbs2 datafile '/app/oradata/ACBMDB/undotbs2_01.dbf' size 100M autoextend on;

alter system set undo_tablespace='UNDOTBS2' sid='acbmdb';

drop tablespace undotbs1 including contents and datafiles;

RAC环境日常删除归档日志
在grid用户下执行,查看归档空间剩余大小
su - grid
asmcmd
lsdg
切换到oracle 用户
su - oracle
rman target /
执行如下删除归档日志
crosscheck archivelog all;
delete expired archivelog all;
delete archivelog until time 'sysdate-1'

--Oracle增加后端监听

下述标黄位置的IP和实例名需按实际修改,节点1和节点2不一样

使用Grid用户: vi /oracle/app/19c/grid/network/admin/listener.ora

MGMTLISTENER =

    (DESCRIPTION_LIST =

        (DESCRIPTION =

                (ADDRESS = (PROTOCOL = TCP)(HOST = 204.108.5.1)(PORT = 1523))

                (ADDRESS = (PROTOCOL = TCP)(HOST = 194.108.5.1)(PORT = 1523))

        )

     )

lsnrctl stop MGMTLISTENER

lsnrctl status MGMTLISTENER or lsnrctl stat MGMTLISTENER  ##查看监听状态

启动监听> lsnrctl start MGMTLISTENER

使用Oracle用户登陆数据库

$ sqlplus / as sysdba

SQL> show parameter local_listener

NAME                                 TYPE                   VALUE

------------------------------------ ---------------------- ------------------------------

local_listener                       string                  (ADDRESS=(PROTOCOL=TCP)(HOST=191.8.10.3)(PORT=1523))

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=204.108.5.2)(PORT=1523))','(ADDRESS=(PROTOCOL=TCP)(HOST=194.108.5.2)(PORT=1523))' scope=both sid='accmdb2';

System altered.

SQL> alter system register;

System altered.

SQL> exit

  1. 创建只读用户
    create user query identified by "Acms*0826";
    2、赋予用户连接数据库等基本权限
    grant connect to query;
    grant create view to query;
    grant create session to query;
    grant create synonym to query;

--grant select any table to query;
--grant select any dictionary to query;
3、获取原用户的查询权限
select 'grant select on '||owner||'.'||object_name||' to query;' from dba_objects where owner in ('原用户') and object_type='TABLE';
--查询结果为新账号的赋值语句
4、将原用户权限赋值为新用户
在原用户下执行步骤3的查询结果
5、在新用户端创建同位显示表
因为新创建的只读用户,tables栏中显示为空,需要在PL/SQL显示栏中为新用户登录界面添加显示同位素
在原用户下执行,获取需要显示的表名称
select 'create or replace SYNONYM query.'||object_name||' for '||owner||'.'||object_name||';' from dba_objects where owner in ('原用户') and object_type='TABLE';
6、查询结果在新用户端执行
在只读用户下执行步骤5的查询结果
7、执行完成后登录新用户,查看结果
新用户可以查询原用户的所有表结构,但是无法执行增删改相关操作
执行删除、修改sql语句测试

--压缩表空间

select total.tablespace_name,round(total.GB,2) as Total_GB,round(total.GB - free.GB,2) as Used_GB,round((1-free.GB / total.GB)* 100,2) || '%' as Used_Pct
from (
select tablespace_name,sum(bytes)/1024/1024/1024 as GB
from dba_free_space group by tablespace_name) free,
(select tablespace_name,sum(bytes)/1024/1024/1024 as GB
from dba_data_files group by tablespace_name) total
where free.tablespace_name = total.tablespace_name

--and total.tablespace_name = 'GMIS_DAT'
order by Total_GB desc;


Select a.file#,
a.name,
a.bytes / 1024 / 1024 currentmb,
ceil(hwm * a.block_size) / 1024 / 1024 resizeto,
(a.bytes - hwm * a.block_size) / 1024 / 1024 releasemb,
'alter database datafile ''' || a.name || ''' resize ' ||
ceil(hwm * a.block_size / 1024 / 1024) || 'M;' resizecmd
From v$datafile a,
(Select file_id, Max(block_id + blocks - 1) hwm
From dba_extents
Where tablespace_name = 'CMIS3_DAT'
Group By file_id) b
Where a.file# = b.file_id(+)
And (a.bytes - hwm * block_size) > 0
Order By 5;

--查表空间使用率

select total.tablespace_name,round(total.GB,2) as Total_GB,round(total.GB - free.GB,2) as Used_GB,round((1-free.GB / total.GB)* 100,2) || '%' as Used_Pct

from (

select tablespace_name,sum(bytes)/1024/1024/1024 as GB

from dba_free_space group by tablespace_name) free,

(select tablespace_name,sum(bytes)/1024/1024/1024 as GB

from dba_data_files group by tablespace_name) total

where free.tablespace_name = total.tablespace_name

order by used_pct desc;

开启数据库归档

--查看归档模式

archive log list;

--关闭数据库

shutdown immediate

--mount模式启动数据库

startup mount;

--开启数据库归档

alter database archivelog;

--打开正常模式数据库

alter database open;

--检查归档状态是否为enabled

archive log list;

关闭数据库归档

--查看归档模式

archive log list;

--关闭数据库

shutdown immediate

--mount模式启动数据库

startup mount;

--关闭数据库归档

alter database noarchivelog;

--打开正常模式数据库

alter database open;

--检查归档状态是否为enabled

archive log list;

mysql数据库命令

mysql -h localhost -u root -p123  ##连接mysql数据库

service mysql status  ##查看mysql服务状态

select * from information_schema.schemata;  ##查询当前mysql实例中所有数据库

use mysql  ##mysql为实例名

高斯数据库命令

linux:

gsql -d postgres -p 8000 -h 193.108.10.46 -U root -W Huawei@1qaz -r  //gsql连接串

Gauss:

\x  ##切换横式显示和竖式显示

select schema_name from information_schema.schemata;  ##查当前数据库所有schema

select a.pid, a.sessionid, a.datname, a.usename, a.client_addr, a.xact_start, a.query_start, (now() - a.query_start)::text as query_runtime, w.wait_status,w.wait_event,w.locktag,w.lockmode,w.block_sessionid,a.query from pg_stat_activity a join pg_thread_wait_status w on a.sessionid = w.sessionid where a.pid <> pg_backend_pid() and a.state = 'active' and a.client_addr is not null order by query_runtime desc;  ##查询常事务

alter role omm identified by 'Sysadmin!@#$1234' replace 'O123456mm';

ALTER USER drs ACCOUNT UNLOCK;

select schema_name from information_schema.schemata;  --查schema

drop user drs cascade;

\du  --查用户

\d

\di

\d+

drop database aramdb;

clean connection to all force for database aramdb;   --清理数据库连接

\l  --查数据库

select nspname as schema_name, relname as object_name, obj_description(c.oid) as description, pg_size_pretty(pg_total_relation_size(c.oid)) as total_size

from pg_class c

left join pg_namespace n on n.oid = c.relnamespace

where relkind in ('r', 'v', 'm', 'i') and relname not like 'pg_%' and relname not like 'sql_%' and not pg_is_other_temp_schema(c.relnamespace) and not relispartition and not exists (select 1 from pg_depend where objid = c.oid and deptype = 'i')

order by schema_name, object_name;  --查无效对象(暂不可用)

----g库查询锁表

--查询被锁表

select b.relname , a.pid from pg_locks a , pg_class b  where a.relation = b.oid;

--释放表

select pg_cancel_backend(281219273924224);  --括号输入上面查出pid

Excel

=VLOOKUP(A2,Sheet2!A:F,2,FALSE)

GIT命令

git pull old-origin 2302_bug --allow-unrelated-histories  //合并老仓库代码

git diff origin/master 2307_pjgz  --name-only  //比对分支

git clone ssh://[email protected]:29418/gcms/ccm

git checkout master

git pull --rebase --progress "origin"

git status

git merge --no-ff origin/master

git commit -F "E:\CODE\gcms\gcm\.git\COMMITMESSAGE"

git push --recurse-submodules=check --progress "origin" refs/heads/master:refs/heads/master

git fetch --progress "--all"

git branch -a

git branch --set-upstream-to=origin/legend_dev legend_dev

git push origin HEAD:lpm_2401dev_temp

git push origin --delete legend_dev

git checkout -b "2309_bug" "1e86ba98c9c432c75126c97a56261252d9e3c0c0"  //以提交哈希“dbba32e91258fc5637882ad3402fc27e5f4ad5f4”创建分支

git add '<目录名或文件名>'

git stash

git stash drop "stash@{0}"

git push -u --recurse-submodules=check --progress "origin" refs/heads/2309_bug:refs/heads/2309_bug  //推送新分支并添加跟踪参考

git checkout -B "2311_wbdj" "origin/2311_wbdj"

git push --progress "origin" tag gcms/gcm_2309_bug_20230925_INIT

git branch -d <本地分支>

git branch -D <本地分支>  ##强制删除

git revert --no-commit -m 2 09e7a934ed47730482ab5e701d2b1603ada8246e

git reset --hard "b1e6a918fd8026d58f09ea6c1666fe1274f732d6"

git tag -d 'gcms/gcm_2309_bug_20230925_INIT'

git status --ignored ##查看被忽略文件

git add -f '<目录名或文件名>' ##恢复被忽略文件

git ls-files -v|grep "^h" ##查看“假定没有变化”文件

git update-index --no-assume-uinchanged ##取消“假定没有变化”文件

git clone -v --progress "ssh://[email protected]:29418/icbc/watchman" "E:/CODE/icbc/watchman"  ##克隆版本库

git cherry-pick 7663b8320e422d1b4b7d6e615d1ff3ba743b1276  ##复制某提交到当前分支

git revert --abort

git config --global core.autocrlf false  ##设置自动切换换行符格式为false

git config --unset user.name  ##删除配置变量

拉代码时提示ssl认证失败,可关闭ssl认证

git bash下执行:

export GIT_SSL_NO_VERIFY=true

git config --global http.sslVerify "false"

cmd进入git所在目录执行:

git config --global http.sslVerify false

创建空分支

git checkout --orphan lpm_2401dev_temp

新建文件并提交推送

Node.js命令

npm -v

npm get registry

npm config set registry http://190.2.37.136:8081/repository/npm-public/

npm install [email protected]

npm uninstall XXX

npm cache clean --force

npm config get cache

npm config list --json

npm ls -g

npm fund

Maven命令

mvn -v

mvn -s D:\MAVEN\MavenRepository\settings.xml [maven goals and options]  ##以此settings文件执行命令,[maven goals and options]替换为实际命令

Windows命令

wmic bios get serialnumber

wmic diskdrive get serialnumber

你可能感兴趣的:(笔记,命令)