Centos7安装jupyter并配置多个Python版本

安装python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
useradd mds
passwd mds
vi /etc/ssh/sshd_config 
systemctl sshd restart
systemctl restart sshd
vi /etc/ssh/sshd_config 
systemctl restart sshd
passwd root
systemctl status firewalld
systemctl disable firewalld
vi /etc/selinux/config 
yum install epel-release
yum install python-pip python-devel vim openssl-devel readline-devel
pip install jupyter
pip install --upgrade pip
pip install -y setuptools
pip install setuptools
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
rm -f Python-3.6.1.tgz 
cd /usr/local/src/
mv /home/mds/Python-3.6.1.tgz .
tar xf Python-3.6.1.tgz 
cd Python-3.6.1
./configure --prefix=/usr/local/python-3.6.1
echo $?
make && make install
ln -sf /usr/local/python-3.6.1/bin/python3 /usr/bin/python3
ln -sf /usr/local/python-3.6.1/bin/pip3 /usr/bin/pip3 
mkdir /var/notebook
su mds

jupyter 配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
jupyter notebook --generate-config
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout notebook_cert.key -out notebook_cert.pem
python -c "import IPython;print(IPython.lib.passwd())"
vim .jupyter/jupyter_notebook_config.py
mkdir /var/notebook
su -
jupyter-kernelspec list
pip3 install ipykernel
python3 -m ipykernel install --name python3 --display-name "Python3.6.1"
jupyter notebook

配置jupyter_notebook_config.py

1
2
3
4
5
6
7
8
9
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.notebook_dir = u'/var/notebook'
c = get_config()
c.NotebookApp.certfile = u'/root/.jupyter/notebook_cert.pem'
c.NotebookApp.keyfile = u'/root/.jupyter/notebook_cert.key'
c.NotebookApp.password = u'sha1:510190c22a9d:c0586d6c41af93a939bd23f3d4cb06de6ec8df9f'
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8080
c.NotebookApp.open_browser = False

启动jupyter

1
jupyter-notebook --ip=0.0.0.0 --allow-root

Rsync Server/Client配置

服务端

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mkdir /etc/rsyncd

vi /etc/rsyncd/rsyncd.conf

uid = root
gid = root
hosts allow = *
use chroot = yes
max connections = 10
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
logf ile = /var/log/rsyncd.log
timeout = 600
port = 873

[sh1]
path = /data1
read only = yes
comment = Rsync File
write only = no
list = no
auth users = rsync
secrets file = /etc/.rsyncd.secrets

[sz1]
path = /data2
read only = yes
comment = Rsync File
write only = no
list = no
auth users = rsync
secrets file = /etc/.rsyncd.secrets
  

vi /etc/.rsyncd.secrets

rsync:passwd
  

cat /etc/xinetd.d/rsync

# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#	allows crc checksumming etc.
service rsync
{
 disable	= no
 flags	= IPv6
 socket_type = stream
 wait = no
 user = root
 #server = /usr/local/bin/rsync
 server = /usr/bin/rsync
 server_args = --daemon --config=/etc/rsyncd/rsyncd.conf
 log_on_failure += USERID
}
 

/etc/init.d/xinetd restart

客户端

密码

1
2
cat /etc/.rsyncd.secrets
passwd

上传

rsync -vzrtopg --delete --progress test.sh rsync@192.168.2.221::sh1 --password-file=/etc/.rsyncd.secrets

Java Web Keytool Ssl

keytool导入/移除证书

1
2
3
4
5
6
7
导入:keytool -import -keystore "C:\Program Files (x86)\Java\jre6\lib\security\cacerts"  -storepass changeit -keypass changeit -alias emailcert -file test.cer
移除:keytool -delete -alias emailcert -keystore "C:\Program Files (x86)\Java\jre6\lib\security\cacerts" -storepass changeit

keytool -import -alias cacerts -keystore cacerts -file /etc/pki/tls/certs/sha256.cer -trustcacerts
keytool -import -alias otrskey -file otrs/server.crt

keytool -import -alias otrscert -keystore cacerts -file /etc/pki/tls/certs/server.crt -trustcacerts

Linux Python2.6 Upgrade Python2

下载并编译

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
python-V
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
rm-rfPython-2.7.3.tar.bz2 
tar jxfPython-2.7.3.tar.bz2 
cdPython-2.7.3
./configure 
make all
make install
make clean
make distclean
/usr/local/bin/python2.7-V
mv/usr/bin/python/usr/bin/python2.6.6
ln-s/usr/local/bin/python2.7/usr/bin/python
python-V

Expect批量添加ssh免密登录

编写脚本deploy_ssh_key.exp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/expect -f

set timeout 2
set ipaddress [lindex $argv 0]
set passwd "password"

spawn ssh-copy-id "-p2522 mds@$ipaddress"

expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "#"

批量执行

for x in cat ip.txt | awk ‘{print $1}’;do ./deploy_ssh_key.exp $x;done