今天的主要学习任务呢就是
1.python版本3的安装
2.安装Redis
3.安装MongDB
linux网络管理配置步骤
1.下载源码
2.tar -zxvf 压缩文件名
3.在解压的目录中找到configure可执行文件
4.配置安装路径
/root/python3.12.4/configure -prefix=/usr/local/py3214
5.进入目录中,运行make,编译编码make
6.安装make insatll
7.在/usr/local/py3124/bin/python3.12可执行文件
8. ./python3.12
主要代码为下面所示
tar -zxf Python-3.12.4.tgz
cd Python-3.12.4/
ls
./configure prefix=/usr/local/py3124
make & make install
[root@localhost bin]# vim /etc/profile
[root@localhost bin]# source /etc/profile
[root@localhost bin]# python3.12
Python 3.12.4 (main, Jul 10 2024, 18:01:43) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
二.安装
1.进入要下载的文件夹
cd /usr/local/
2.在linux命令行中下载redis(.tar.gz),需要联网
wget https://download.redis.io/releases/redis-7.2.0.tar.gz
3.解压redis-7.2.0.tar.gz文件
tar -zxvf redis-7.2.0.tar.gz
4.进入redis安装目录
cd redis-7.2.0
5.安装
make && make install
6.进入/usr/local/bin/检查是否安装成功
cd /usr/local/bin/
ll 或者 ls
1
2
7.可以在任意目录下运行redis
redis-server
Redis配置:
先将redis的配置文件(redis.conf)备份,防止修改错误
cp redis.conf redis.conf.bck
进入redis.conf
vi redis.conf
3.要修改的内容
搜索功能:/+要搜索的内容,n:下一个搜索结果,N:上一个搜索结果
bind 127.0.0.1 -::1 ---> bind 0.0.0.0
daemonize no ---> daemonize yes
requirepass foobared注释去掉并在后加上密码(注意中间加个空格)
requirepass foobared ---> requirepass 123456
设置redis记录日志,默认不记录日志(redis.log为文件名)
logfile " " ---> logfile "redis.log"
4.进入redis安装路径
(1)可以启动的时候不写redis.conf的全限定名称
redis-server redis.conf
(2)这次启动并没有任何的日志输出,因为已经启动后台运行了,怎么知道有没有进行后台运行呢?
ps -ef | grep redis
(3)如何停止呢?
kill -9 67859
开机自启
1.新建文件
vi /etc/systemd/system/redis.service
2.进入之后将以下信息复制进去:(注意ExecStart的内容为你们自己的redis.conf文件的路径)
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-7.2.0/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
之后便保存退出。
3.退出之后要让文件生效
systemctl daemon-reload
4.然后重启redis
systemctl start redis
5.查看redis状态
systemctl status redis
6.停止Redis服务
systemctl stop redis
7.再次查看redis的状态
systemctl status redis
三.安装MongoDB:
1.配置yum源
[root@mongodb ~]# cat /etc/yum.repos.d/mongodb.repo
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/7.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-7.0.asc
2.安装MongoDB包
(默认安装MongoDB最新版本(7.0.1))
[root@mongodb ~]# yum install -y mongodb-org
(如果需要安装指定版本,需要单独指定每个组件包,并在包名后附加版本号)
yum install -y mongodb-org-7.0.1 mongodb-org-database-7.0.1 mongodb-org-server-7.0.1 mongodb-mongosh-7.0.1 mongodb-org-mongos-7.0.1 mongodb-org-tools-7.0.1
3.启动MongoDB服务
[root@mongodb ~]# systemctl start mongod
4.查看MongoDB服务状态
(它这里有个报错先忽略掉,应该不影响后续的操作)(因为它只是一个提示信息,表明该环境变量被设置为false。通常情况下,这个环境变量不会影响MongoDB的运行)
[root@mongodb ~]# systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2023-09-15 16:14:11 CST; 57s ago
Docs: https://docs.mongodb.org/manual
Main PID: 11031 (mongod)
CGroup: /system.slice/mongod.service
└─11031 /usr/bin/mongod -f /etc/mongod.conf
9月 15 16:14:11 mongodb systemd[1]: Started MongoDB Database Server.
9月 15 16:14:11 mongodb systemd[1]: Starting MongoDB Database Server...
9月 15 16:14:11 mongodb mongod[11031]: {"t":{"$date":"2023-09-15T08:14:11.618Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CO..." to false"}
Hint: Some lines were ellipsized, use -l to show in full.
5.看看能否正常进入数据库
(成功进入mongodb数据库,安装成功!)
[root@mongodb ~]# mongosh
Current Mongosh Log ID: 6504226fe792ed88c3dd64f6
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.0.1
Using MongoDB: 7.0.1
Using Mongosh: 2.0.1
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
------
The server generated these startup warnings when booting
2023-09-15T17:21:51.287+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2023-09-15T17:21:51.287+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
2023-09-15T17:21:51.288+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
2023-09-15T17:21:51.288+08:00: vm.max_map_count is too low
------
Deprecation warnings:
- Using mongosh on the current operating system is deprecated, and support may be removed in a future release.
See https://www.mongodb.com/docs/mongodb-shell/ for documentation on supported platforms.
test>
6.目录路径了解一下
(默认目录如下)
/var/lib/mongo(数据目录)
/var/log/mongodb(日志目录)