Achieve my little laboratory of the easiest jump

Requirements: Due to the need, I have a lot to build sets of experimental environment on your own workstation, but in a particular scene, I need to pass the default terminal connected ready to jump to switch to a temporary test use in other circumstances, because only my own use, without introducing a complicated jump system, do not need to audit.
Environment: both Linux servers
to achieve: I want some of the most simple operation and maintenance knowledge, build a set of the most simple jump program, to enhance their work efficiency.

1. There are combing the environmental information needs to jump

First, I connected the default environment itself is an Oracle environment, the default is the oracle user connections, IP address is 192.168.1.61. First sort out the current list of all need to jump into the experimental environment IP address:
Here I edit / home / oracle / jump_server / server_list file, as follows:

Oracle:
        Oracle 9i:
                9 -> 192.168.1.9

        Oracle 10g:
                10 -> 192.168.1.10

        Oracle 11g:
                11 -> 192.168.1.11

        Oracle 10g RAC:
                171 -> 192.168.1.171
                173 -> 192.168.1.173

        Oracle 11g RAC:
                61 -> 192.168.1.61
                63 -> 192.168.1.63

        Oracle 11g RAC(xData):
                107 -> 192.168.1.107
                108 -> 192.168.1.108
                109 -> 192.168.1.109

        Oracle EM 13c(12.1.0.2 RAC):
                111 -> 192.168.1.111
                112 -> 192.168.1.112

        Oracle 19c RAC:
                193 -> 192.168.1.193
                195 -> 192.168.1.195
MySQL & PostgreSQL: 
        99 -> 192.168.1.99

We can see a clear description of the summary information and the corresponding IP address environment.

2. Add the user's environment variables

Editing environment variable configuration file, increase as follows: vi ~ / .bash_profile

###################
##  跳转主机列表  ## 
###################
alias j='cat /home/oracle/jump_server/server_list'
# Alias for my env:
alias 9='ssh 192.168.1.9'
alias 10='ssh 192.168.1.10'
alias 11='ssh 192.168.1.11'
alias 171='ssh 192.168.1.171'
alias 173='ssh 192.168.1.173'
alias 61='ssh 192.168.1.61'
alias 63='ssh 192.168.1.63'
alias 107='ssh 192.168.1.107'
alias 108='ssh 192.168.1.108'
alias 109='ssh 192.168.1.109'
alias 111='ssh 192.168.1.111'
alias 112='ssh 192.168.1.112'
alias 193='ssh 192.168.1.193'
alias 195='ssh 192.168.1.195'
alias 99='ssh [email protected]'

3. Configure ssh without password

Which I have considered whether it is necessary? Whether a configuration without the ssh password will be prone to misuse? But the combination of their needs, in a test environment or personal needs such convenient features to enhance efficiency.
Configuration / etc / hosts file, add:
vi / etc / hosts

#My Oracle Server
192.168.1.9     DB9
192.168.1.10    DB10
192.168.1.11    DB11
192.168.1.61    DB61
192.168.1.63    DB63
192.168.1.171   DB171
192.168.1.173   DB173
192.168.1.107   DB107
192.168.1.108   DB108
192.168.1.109   DB109
192.168.1.111   DB111
192.168.1.112   DB112
192.168.1.193   DB193
192.168.1.195   DB195
192.168.1.99    DB99

Here you can refer to my previous essay:

After you upload two scripts at the beginning of the cluster, configure the environment variables, variable values ​​increase NODE_LIST:

#NODE_LIST:
export NODE_LIST='DB9 DB10 DB11 DB61 DB63 DB171 DB173 DB107 DB108 DB109 DB111 DB112 DB193 DB195 DB99'

Clear ssh trust of all current configuration information (choose to do under the circumstances):

cluster_run_all_nodes "hostname; rm -rf ~/.ssh"
rm -rf ~/.ssh

3.1 cluster_run_all_nodes script quickly and public RSA key at each node ssh-keygen

cluster_run_all_nodes "hostname; ssh-keygen -q -t rsa  -N \"\" -f  ~/.ssh/id_rsa"

3.2 I need to use the shell for loop through the array in combination, as follows:

IP_NET="192.168.1."
a=(9 10 11 61 63 171 173 107 108 109 111 112 193 195 99)
for i in ${a[@]}
do
ssh $IP_NET$i cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
echo Summarize ssh info from $IP_NET$i into a single file.
done

3.3 security, distribution confirmation:

chmod 600 ~/.ssh/authorized_keys
cluster_copy_all_nodes ~/.ssh/authorized_keys ~/.ssh/
cluster_run_all_nodes "hostname; date"

If the configuration is successful, you do not need to enter a password to perform complete:

[oracle@jystdrac1 ~]$ cluster_run_all_nodes "hostname; date"
db09
Wed Dec 25 23:58:31 CST 2019
db10
Wed Dec 25 23:58:42 CST 2019
OEL-ASM
Wed Dec 25 23:58:28 CST 2019
jystdrac1
Wed Dec 25 23:58:47 CST 2019
jystdrac2
Wed Dec 25 23:58:48 CST 2019
rac1-server
Wed Dec 25 23:50:24 CST 2019
rac2-server
Wed Dec 25 23:50:47 CST 2019
db01
Wed Dec 25 23:58:48 CST 2019
db02
Wed Dec 25 23:58:48 CST 2019
db03
Wed Dec 25 23:58:49 CST 2019
oemapp1
Wed Dec 25 23:58:42 CST 2019
oemapp2
Wed Dec 25 23:58:44 CST 2019
db193
Wed Dec 25 23:56:53 CST 2019
db195
Wed Dec 25 23:56:54 CST 2019
alfred
Wed Dec 25 23:56:38 CST 2019

In addition, special attention due to the installation of 99 machine a variety of database products, in order to facilitate that I jump to the root user, so do not need to switch to any other user to enter a password, as ssh trust here need special configuration, simply the root user on the input 99 ssh-keygen generated id_rsa.pub authorized_keys file append to the oracle user 61, 61, then this resynchronization root authorized_keys back to the user 99.

4 shows the effect of the jump machine

Finally, look at the effect of jump machine actually used:

4.1 j Enter the server information display can jump:

[oracle@jystdrac1 ~]$ j
Oracle:
        Oracle 9i:
                9 -> 192.168.1.9

        Oracle 10g:
                10 -> 192.168.1.10

        Oracle 11g:
                11 -> 192.168.1.11

        Oracle 10g RAC:
                171 -> 192.168.1.171
                173 -> 192.168.1.173

        Oracle 11g RAC:
                61 -> 192.168.1.61
                63 -> 192.168.1.63

        Oracle 11g RAC(xData):
                107 -> 192.168.1.107
                108 -> 192.168.1.108
                109 -> 192.168.1.109

        Oracle EM 13c(12.1.0.2 RAC):
                111 -> 192.168.1.111
                112 -> 192.168.1.112

        Oracle 19c RAC:
                193 -> 192.168.1.193
                195 -> 192.168.1.195
MySQL & PostgreSQL: 
        99 -> 192.168.1.99

4.2 a selection input corresponding to the host can be realized Jump:
such a selection input 107 to jump to the host 192.168.1.107:

[oracle@jystdrac1 ~]$ 107
Last login: Wed Dec 25 22:31:16 2019 from db02
[oracle@db01 ~]$ ps -ef|grep pmon
grid     19592     1  0 Dec22 ?        00:00:52 asm_pmon_+ASM1
oracle   20315 20293  0 00:02 pts/0    00:00:00 grep --color=auto pmon
oracle   21339     1  0 Dec22 ?        00:00:58 ora_pmon_orcl1
[oracle@db01 ~]$ exit
logout
Connection to 192.168.1.107 closed.

Such a selection input 193 to jump to the host 192.168.1.193:

[oracle@jystdrac1 ~]$ 193
Last login: Wed Dec 25 22:30:01 2019 from 192.168.1.61
[oracle@db193 ~]$ ps -ef|grep pmon
grid     16918     1  0 Nov07 ?        00:05:33 asm_pmon_+ASM1
oracle   17329     1  0 Nov07 ?        00:06:51 ora_pmon_jydb1
oracle   28698 28674  0 00:00 pts/0    00:00:00 grep --color=auto pmon
[oracle@db193 ~]$ exit
logout
Connection to 192.168.1.193 closed.

Such as selection input 99, to jump to 192.168.1.99 host (because special treatment, it is possible to jump to the root user successfully):

[oracle@jystdrac1 ~]$ 99
Last login: Thu Dec 26 00:24:57 2019 from 192.168.1.61
[root@alfred ~]# ps -ef|grep postgres
postgres 17659     1  0 Dec23 ?        00:00:18 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
postgres 17662 17659  0 Dec23 ?        00:00:00 postgres: logger process   
postgres 17664 17659  0 Dec23 ?        00:00:00 postgres: checkpointer process   
postgres 17665 17659  0 Dec23 ?        00:00:04 postgres: writer process   
postgres 17666 17659  0 Dec23 ?        00:00:05 postgres: wal writer process   
postgres 17667 17659  0 Dec23 ?        00:00:15 postgres: autovacuum launcher process   
postgres 17668 17659  0 Dec23 ?        00:00:32 postgres: stats collector process   
postgres 17669 17659  0 Dec23 ?        00:00:00 postgres: bgworker: logical replication launcher   
root     19218 19196  0 00:28 pts/0    00:00:00 grep --color=auto postgres
[root@alfred ~]# su - postgres
Last login: Tue Dec 24 09:23:16 CST 2019 on pts/0
-bash-4.2$ psql
psql (10.11)
输入 "help" 来获取帮助信息.

postgres=# \q
-bash-4.2$ exit
登出
[root@alfred ~]# exit
logout
Connection to 192.168.1.99 closed.

It can be seen so easily jump function, so that I can quickly connect to all kinds of learning environments for testing.

Guess you like

Origin www.cnblogs.com/jyzhao/p/12099875.html