searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

Centos8源码编译Mongodb

2024-10-17 09:34:35
4
0

从git下载源码

git clone ,这里下载4.0版本的

安装相关依赖

yum install -y libcurl-devel
yum install libcurl openssl
python3 -m pip install poetry
yum install openssl openssl-devel

执行编译

解压然后进入到源码目录,执行:

python3 buildscripts/scons.py --link-model=static --opt=on all
[root mongo]# python3 buildscripts/scons.py --link-model=static --opt=on all
Checking required python packages...
Traceback (most recent call last):
File "buildscripts/scons.py", line 25, in
verify_requirements()
File "/data/mongo/mongo/site_scons/mongo/pip_requirements.py", line 48, in verify_requirements
capture_output=True, text=True)
File "/usr/lib64/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError:
init() got an unexpected keyword argument 'capture_output'

问题解决

python3版本是3.6的,升级为3.7:

wget https://mirrors.huaweicloud.com/python/3.7.2/Python-3.7.2.tgz
tar -zxvf Python-3.7.2.tgz
cd Python-3.7.2
./configure prefix=/usr/local/python3 
yum install libffi-devel
make && make install

/usr/local/python3/bin/python3 -m pip install --upgrade pip
/usr/local/python3/bin/python3 -m pip install 'poetry==1.5.1'

/usr/local/python3/bin/python3 buildscripts/scons.py --link-model=static --opt=on all

[root@localhost mongo]# /usr/local/python3/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
Checking required python packages...
Traceback (most recent call last):
  File "buildscripts/scons.py", line 25, in <module>
    verify_requirements()
  File "/data/mongo/mongo/site_scons/mongo/pip_requirements.py", line 48, in verify_requirements
    capture_output=True, text=True)
  File "/usr/local/python3/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/python3/bin/python3', '-m', 'poetry', 'install', '--no-root', '--sync', '--dry-run']' returned non-zero exit status 1.

手动执行下面命令:

[root@localhost mongo]# /usr/local/python3/bin/python3 -m poetry install --no-root --sync --dry-run
The currently activated Python version 3.7.2 is not supported by the project (>=3.9,<4.0).
Trying to find and use a compatible version. 

Poetry was unable to find a compatible version. If you have one, you can explicitly use it via the "env use" command.

问了chatgpt,要升级python版本大于等于3.9

升完级后,继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示安装:
/usr/local/python3.9/bin/python3 -m pip install 'poetry==1.5.1'
/usr/local/python3.9/bin/python3 -m pip install --upgrade pip

继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示下面错误:

Detected one or more packages are out of date. Try running:
    export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
    /usr/local/python3.9/bin/python3 -m poetry install --no-root --sync

按要求执行下面命令:

export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
/usr/local/python3.9/bin/python3 -m poetry install --no-root --sync

提示下面错误:

ModuleNotFoundError: No module named 'mongo_tooling_metrics':
  File "/data/mongo/mongo/SConstruct", line 28:
    from mongo_tooling_metrics.lib.top_level_metrics import SConsToolingMetrics

问ChatGPT,执行下面命令:
/usr/local/python3.9/bin/python3 -m pip install mongo_tooling_metrics

继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示下面错误:

scons: Reading SConscript files ...
ModuleNotFoundError: No module named 'psutil':
  File "/data/mongo/mongo/SConstruct", line 61:
    import psutil

执行下面命令:
/usr/local/python3.9/bin/python3 -m pip install psutil

提示下面错误:

scons: Reading SConscript files ...
scons: running with args /usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named 'memory_profiler'
Invalid MONGO_VERSION '', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons

/usr/local/python3.9/bin/python3 -m pip install memory-profiler

提示下面错误:

WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named 'puremagic'
Invalid MONGO_VERSION '', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons

/usr/local/python3.9/bin/python3 -m pip install puremagic
/usr/local/python3.9/bin/python3 -m pip install networkx

/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all MONGO_VERSION=7.1.2

/usr/local/python3.9/bin/python3 -m pip install bz2file
/usr/local/python3.9/bin/python3 -m pip install PyYAML
yum install bzip2-devel

scons: running with args /usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all MONGO_VERSION=7.1.2
WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named '_bz2'
scons version: 3.1.2
python version: 3 9 16 'final' 0
Mkdir("build/tmp_test_data")
CC is gcc
gcc found in $PATH at /usr/bin/gcc
CXX is g++
g++ was not found in $PATH
g++ resolves to /data/mongo/mongo/g++
Checking if C++ compiler "g++" is GCC... no
Checking if C++ compiler "g++" is clang... no
Couldn't identify the C++ compiler
See /data/mongo/mongo/build/scons/config.log for details

接着安装gcc12

下载gcc 12的包

ln -s /usr/local/gcc-12.2.0/bin/gcc gcc

ln -s /usr/local/gcc-12.2.0/bin/g++ g++

0条评论
0 / 1000
9****m
15文章数
1粉丝数
9****m
15 文章 | 1 粉丝
原创

Centos8源码编译Mongodb

2024-10-17 09:34:35
4
0

从git下载源码

git clone ,这里下载4.0版本的

安装相关依赖

yum install -y libcurl-devel
yum install libcurl openssl
python3 -m pip install poetry
yum install openssl openssl-devel

执行编译

解压然后进入到源码目录,执行:

python3 buildscripts/scons.py --link-model=static --opt=on all
[root mongo]# python3 buildscripts/scons.py --link-model=static --opt=on all
Checking required python packages...
Traceback (most recent call last):
File "buildscripts/scons.py", line 25, in
verify_requirements()
File "/data/mongo/mongo/site_scons/mongo/pip_requirements.py", line 48, in verify_requirements
capture_output=True, text=True)
File "/usr/lib64/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError:
init() got an unexpected keyword argument 'capture_output'

问题解决

python3版本是3.6的,升级为3.7:

wget https://mirrors.huaweicloud.com/python/3.7.2/Python-3.7.2.tgz
tar -zxvf Python-3.7.2.tgz
cd Python-3.7.2
./configure prefix=/usr/local/python3 
yum install libffi-devel
make && make install

/usr/local/python3/bin/python3 -m pip install --upgrade pip
/usr/local/python3/bin/python3 -m pip install 'poetry==1.5.1'

/usr/local/python3/bin/python3 buildscripts/scons.py --link-model=static --opt=on all

[root@localhost mongo]# /usr/local/python3/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
Checking required python packages...
Traceback (most recent call last):
  File "buildscripts/scons.py", line 25, in <module>
    verify_requirements()
  File "/data/mongo/mongo/site_scons/mongo/pip_requirements.py", line 48, in verify_requirements
    capture_output=True, text=True)
  File "/usr/local/python3/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/python3/bin/python3', '-m', 'poetry', 'install', '--no-root', '--sync', '--dry-run']' returned non-zero exit status 1.

手动执行下面命令:

[root@localhost mongo]# /usr/local/python3/bin/python3 -m poetry install --no-root --sync --dry-run
The currently activated Python version 3.7.2 is not supported by the project (>=3.9,<4.0).
Trying to find and use a compatible version. 

Poetry was unable to find a compatible version. If you have one, you can explicitly use it via the "env use" command.

问了chatgpt,要升级python版本大于等于3.9

升完级后,继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示安装:
/usr/local/python3.9/bin/python3 -m pip install 'poetry==1.5.1'
/usr/local/python3.9/bin/python3 -m pip install --upgrade pip

继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示下面错误:

Detected one or more packages are out of date. Try running:
    export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
    /usr/local/python3.9/bin/python3 -m poetry install --no-root --sync

按要求执行下面命令:

export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
/usr/local/python3.9/bin/python3 -m poetry install --no-root --sync

提示下面错误:

ModuleNotFoundError: No module named 'mongo_tooling_metrics':
  File "/data/mongo/mongo/SConstruct", line 28:
    from mongo_tooling_metrics.lib.top_level_metrics import SConsToolingMetrics

问ChatGPT,执行下面命令:
/usr/local/python3.9/bin/python3 -m pip install mongo_tooling_metrics

继续编译:
/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
提示下面错误:

scons: Reading SConscript files ...
ModuleNotFoundError: No module named 'psutil':
  File "/data/mongo/mongo/SConstruct", line 61:
    import psutil

执行下面命令:
/usr/local/python3.9/bin/python3 -m pip install psutil

提示下面错误:

scons: Reading SConscript files ...
scons: running with args /usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all
WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named 'memory_profiler'
Invalid MONGO_VERSION '', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons

/usr/local/python3.9/bin/python3 -m pip install memory-profiler

提示下面错误:

WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named 'puremagic'
Invalid MONGO_VERSION '', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons

/usr/local/python3.9/bin/python3 -m pip install puremagic
/usr/local/python3.9/bin/python3 -m pip install networkx

/usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all MONGO_VERSION=7.1.2

/usr/local/python3.9/bin/python3 -m pip install bz2file
/usr/local/python3.9/bin/python3 -m pip install PyYAML
yum install bzip2-devel

scons: running with args /usr/local/python3.9/bin/python3 buildscripts/scons.py --link-model=static --opt=on all MONGO_VERSION=7.1.2
WARNING: The build_metrics tool might not work as intended due to a failed import:
No module named '_bz2'
scons version: 3.1.2
python version: 3 9 16 'final' 0
Mkdir("build/tmp_test_data")
CC is gcc
gcc found in $PATH at /usr/bin/gcc
CXX is g++
g++ was not found in $PATH
g++ resolves to /data/mongo/mongo/g++
Checking if C++ compiler "g++" is GCC... no
Checking if C++ compiler "g++" is clang... no
Couldn't identify the C++ compiler
See /data/mongo/mongo/build/scons/config.log for details

接着安装gcc12

下载gcc 12的包

ln -s /usr/local/gcc-12.2.0/bin/gcc gcc

ln -s /usr/local/gcc-12.2.0/bin/g++ g++

文章来自个人专栏
实战
3 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0